from zope.interface import implements from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from Products.ATContentTypes.content.file import ATFile from Products.Archetypes.public import registerType from Products.Quills.interfaces import IWeblogEntry from Products.Archetypes.public import TextField, RichWidget, Schema from p4a.audio import interfaces try: from zope.app.annotation import interfaces as annointerfaces except ImportError, err: # Zope 2.10 support from zope.annotation import interfaces as annointerfaces FileEntrySchema = ATFile.schema + Schema( TextField('text', searchable=1, default_output_type='text/x-html-safe', default_content_type = 'text/html', allowable_content_types=( 'text/structured', 'text/restructured', 'text/plain', 'text/html', ), widget=RichWidget(label='Entry Text', rows=30, label_msgid="label_text", i18n_domain="quills"), ), ) FileEntrySchema.moveField('text', -1) class FileEntry(ATFile): implements(IWeblogEntry) security = ClassSecurityInfo() meta_type = 'FileEntry' archetype_name = 'Weblog File Entry' schema = FileEntrySchema security.declareProtected('View', 'getCategories') def getCategories(self): """Return the categories/topics for this entry. """ qt = getToolByName(self, 'quills_tool') weblog = qt.getParentWeblog(self) topics = [] keywords = self.Subject() for kw in keywords: topics.append( Topic(kw).__of__(weblog) ) return topics def getExcerpt(self): """Return an excerpt/description of the post. """ return self.Description() def setTitle(self, value): ATFile.setTitle(self, value) audio = interfaces.IAudio(self) annotations = annointerfaces.IAnnotations(self) data = annotations.get(audio.ANNO_KEY, None) data['title'] = self.title annotations[audio.ANNO_KEY] = data registerType(FileEntry, 'Plone4ArtistsPodcast')