aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/models.py
diff options
context:
space:
mode:
authorOdin Hørthe Omdal <odin.omdal@gmail.com>2014-09-07 12:56:13 +0200
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-09-07 09:42:07 -0500
commit4f1a5148cb9b64f7086d047359f612a84f3d4c9c (patch)
treeae947c26f72dd82cbafeb63a9f9bb47adc209ee8 /mediagoblin/db/models.py
parenta6570fae0303eec403034bbea61235c85cdb0654 (diff)
downloadmediagoblin-4f1a5148cb9b64f7086d047359f612a84f3d4c9c.tar.lz
mediagoblin-4f1a5148cb9b64f7086d047359f612a84f3d4c9c.tar.xz
mediagoblin-4f1a5148cb9b64f7086d047359f612a84f3d4c9c.zip
Add __repr__ for Collection and CollectionItem
Diffstat (limited to 'mediagoblin/db/models.py')
-rw-r--r--mediagoblin/db/models.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index b910e522..2ff30d22 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -20,7 +20,6 @@ TODO: indexes on foreignkeys, where useful.
import logging
import datetime
-import base64
from sqlalchemy import Column, Integer, Unicode, UnicodeText, DateTime, \
Boolean, ForeignKey, UniqueConstraint, PrimaryKeyConstraint, \
@@ -727,6 +726,14 @@ class Collection(Base, CollectionMixin):
return CollectionItem.query.filter_by(
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):
__tablename__ = "core__collection_items"
@@ -756,6 +763,13 @@ class CollectionItem(Base, CollectionItemMixin):
"""A dict like view on this object"""
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):
__tablename__ = 'core__processing_metadata'