Add __repr__ for Collection and CollectionItem
This commit is contained in:
parent
a6570fae03
commit
4f1a5148cb
@ -20,7 +20,6 @@ TODO: indexes on foreignkeys, where useful.
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import base64
|
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, Unicode, UnicodeText, DateTime, \
|
from sqlalchemy import Column, Integer, Unicode, UnicodeText, DateTime, \
|
||||||
Boolean, ForeignKey, UniqueConstraint, PrimaryKeyConstraint, \
|
Boolean, ForeignKey, UniqueConstraint, PrimaryKeyConstraint, \
|
||||||
@ -727,6 +726,14 @@ class Collection(Base, CollectionMixin):
|
|||||||
return CollectionItem.query.filter_by(
|
return CollectionItem.query.filter_by(
|
||||||
collection=self.id).order_by(order_col)
|
collection=self.id).order_by(order_col)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
safe_title = self.title.encode('ascii', 'replace')
|
||||||
|
return '<{classname} #{id}: {title} by {creator}>'.format(
|
||||||
|
id=self.id,
|
||||||
|
classname=self.__class__.__name__,
|
||||||
|
creator=self.creator,
|
||||||
|
title=safe_title)
|
||||||
|
|
||||||
|
|
||||||
class CollectionItem(Base, CollectionItemMixin):
|
class CollectionItem(Base, CollectionItemMixin):
|
||||||
__tablename__ = "core__collection_items"
|
__tablename__ = "core__collection_items"
|
||||||
@ -756,6 +763,13 @@ class CollectionItem(Base, CollectionItemMixin):
|
|||||||
"""A dict like view on this object"""
|
"""A dict like view on this object"""
|
||||||
return DictReadAttrProxy(self)
|
return DictReadAttrProxy(self)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<{classname} #{id}: Entry {entry} in {collection}>'.format(
|
||||||
|
id=self.id,
|
||||||
|
classname=self.__class__.__name__,
|
||||||
|
collection=self.collection,
|
||||||
|
entry=self.media_entry)
|
||||||
|
|
||||||
|
|
||||||
class ProcessingMetaData(Base):
|
class ProcessingMetaData(Base):
|
||||||
__tablename__ = 'core__processing_metadata'
|
__tablename__ = 'core__processing_metadata'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user