# ATAudioFolder: container for ATAudio objects # Copyright (c) 2003-2005 Nate Aune # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # """ATAudioFolder provides a container for ATAudio objects. A typical use for this is to represent a compact disc. Gives you a track listing of your audio files and an optional image """ __author__ = 'Nate Aune ' __docformat__ = 'restructuredtext' try: from Products.LinguaPlone.public import * except: # no multilingual support from Products.Archetypes.public import * from Products.CMFCore import permissions from Products.CMFCore.utils import getToolByName from Acquisition import aq_parent, aq_inner, aq_base from config import GENRES ATAudioFolderSchema = BaseFolderSchema + Schema(( StringField('title', required=1, searchable=1, languageIndependent=1, accessor='Title', widget=StringWidget(label="CD Title", label_msgid="label_cd_title", description="The title for this CD", description_msgid="desc_cd_title", i18n_domain="ataudio"), ), StringField('description', required=0, storage=MetadataStorage(), searchable=1, accessor='Description', widget=TextAreaWidget(label='Description', label_msgid="label_cd_description", description='Give a description for this CD.', description_msgid="desc_cd_description", i18n_domain="ataudio"), ), ImageField('coverimage', required = 0, languageIndependent=1, original_size = (600,600), sizes= {'large':(256,256), 'medium':(128,128), 'small':(64,64) }, widget = ImageWidget(label= "CD cover image", label_msgid = "label_cd_coverimage", description = "Upload a CD cover image. It will be automatically resized", description_msgid = "desc_cd_coverimage", i18n_domain = "ataudio") ), StringField('artist', searchable=1, languageIndependent=1, widget=StringWidget(label='Artist', label_msgid="label_cd_artist", description='The artists name.', description_msgid="desc_cd_artist", i18n_domain="ataudio"), ), StringField('label', searchable=1, languageIndependent=1, widget=StringWidget(label='Record Label', label_msgid="label_cd_recordlabel", description='Label this CD was issued on.', description_msgid="desc_cd_recordlabel", i18n_domain="ataudio"), ), IntegerField('year', searchable=1, default='', languageIndependent=1, validators=('isInt',), widget=IntegerWidget(label='Year', label_msgid="label_cd_year", description='Year this CD was issued (i.e. 1999).', description_msgid="desc_cd_year", size="4", i18n_domain="ataudio"), ), LinesField('genre', searchable=1, languageIndependent=1, multiValued=1, widget=MultiSelectionWidget(label="Genre", label_msgid="label_cd_genre", description="Select the genres that this CD compilation contains.", description_msgid="desc_cd_genre", i18n_domain="ataudio", ), vocabulary=GENRES, ), )) class ATAudioFolder(OrderedBaseFolder): """ A folder for containing audio files, i.e. a CD """ schema = ATAudioFolderSchema filter_content_types = 1 allowed_content_types = ['ATAudio'] meta_type = 'ATAudioFolder' archetype_name = 'CD' _at_rename_after_creation = True content_icon = 'cdaudio_icon.png' actions = ({ 'id': 'view', 'name': 'View', 'action': 'string:${object_url}/audiofolder_view', 'permissions': (permissions.View,) }, {'id': 'references', 'name': 'References', 'action': 'string:${object_url}/reference_edit', 'permissions': (permissions.ModifyPortalContent,), 'visible':0}, {'id': 'metadata', 'name': 'Properties', 'action': 'string:${object_url}/base_metadata', 'permissions': (permissions.ModifyPortalContent,), 'visible':0}) def PUT_factory( self, name, typ, body ): """ Factory for PUT requests to objects which do not yet exist. Used by NullResource.PUT. Returns -- Bare and empty object of the appropriate type (or None, if we don't know what to do) """ # workaround for MacOSX braindead behavior of sending the resource fork if name == '.DS_Store' or name.startswith('._'): return None registry = getToolByName(self, 'content_type_registry', None) if registry is None: return None typeObjectName = registry.findTypeName( name, typ, body ) if typeObjectName is None: return None self.invokeFactory( typeObjectName, name ) # invokeFactory does too much, so the object has to be removed again obj = aq_base( self._getOb( name ) ) self._delObject( name ) return obj registerType(ATAudioFolder)