Source

tgapp-smallpress / smallpress / model / models.py

Diff from to

File smallpress/model/models.py

 from tg import request, config
 
+import tg
 from sqlalchemy import Table, ForeignKey, Column
 from sqlalchemy.types import Unicode, Integer, DateTime
 from sqlalchemy.orm import backref, relation
 
 import os
 from datetime import datetime
+from tgext.datahelpers.fields import AttachedImage
 from smallpress.model import DeclarativeBase, DBSession
 from tgext.pluggable import app_model, primary_key
-from tgext.datahelpers.fields import Attachment as DataHelpersAttachment
 from tgext.pluggable import call_partial
 
 import mimetypes
 except ImportError:
     sqla_events = False
 
+AttachmentType = tg.config.get('_smallpress',{}).get('attachment_type', AttachedImage)
+
 class Blog(DeclarativeBase):
     __tablename__ = 'smallpress_blogs'
 
 
     uid = Column(Integer, autoincrement=True, primary_key=True)
     name = Column(Unicode(16), nullable=False)
-    content = Column(DataHelpersAttachment)
+    content = Column(AttachmentType)
 
     article_id = Column(Integer, ForeignKey(Article.uid))
     article = relation(Article, backref=backref('attachments', cascade='all, delete-orphan'))