Anonymous avatar Anonymous committed 5ace0ec

Added custom attachment file

Comments (0)

Files changed (1)

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'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.