- external collection: provide functionality for automatically populate

meta information of media assets
This commit is contained in:
Helmut Merz 2011-08-28 17:04:50 +02:00
parent 3d53026bdf
commit 6c64ba5158
4 changed files with 33 additions and 5 deletions

View file

@ -6,6 +6,8 @@ $Id$
1.1 1.1
--- ---
- external collection: provide functionality for automatically populate
meta information of media assets
- new query for retrieving work items independently of task or user - new query for retrieving work items independently of task or user
- provide additional ``metaInfo`` field, e.g. for storing source and rights - provide additional ``metaInfo`` field, e.g. for storing source and rights
information for media assets; show this in info popup; information for media assets; show this in info popup;

View file

@ -58,6 +58,10 @@ to the external system:
>>> aColl01.baseAddress = dataDir >>> aColl01.baseAddress = dataDir
>>> aColl01.address = 'topics' >>> aColl01.address = 'topics'
>>> aColl01.metaInfo = u'Photograph taken by...'
>>> aColl01.overwriteMetaInfo is None
True
Directory Collection Provider Directory Collection Provider
----------------------------- -----------------------------
@ -128,6 +132,9 @@ can be found.
>>> aXf1.storageName, aXf1.storageParams, aXf1.externalAddress >>> aXf1.storageName, aXf1.storageParams, aXf1.externalAddress
('fullpath', {'subdirectory': '...programming'}, 'BeautifulProgram.pdf') ('fullpath', {'subdirectory': '...programming'}, 'BeautifulProgram.pdf')
>>> aXf1.metaInfo
u'Photograph taken by...'
But if one of the referenced objects is not found any more it will be deleted. But if one of the referenced objects is not found any more it will be deleted.
>>> aColl01.address = os.path.join('topics', 'programming', 'zope') >>> aColl01.address = os.path.join('topics', 'programming', 'zope')

View file

@ -116,6 +116,11 @@ class ExternalCollectionAdapter(AdapterBase):
# not part of the collection any more # not part of the collection any more
# TODO: only remove from collection but keep object? # TODO: only remove from collection but keep object?
self.remove(old[addr]) self.remove(old[addr])
for r in self.context.getResources():
adobj = adapted(r)
if self.metaInfo != adobj.metaInfo and (
not adobj.metaInfo or self.overwriteMetaInfo):
adobj.metaInfo = self.metaInfo
self.lastUpdated = datetime.today() self.lastUpdated = datetime.today()
def clear(self): def clear(self):

View file

@ -51,26 +51,26 @@ class IExternalCollection(IConceptSchema, ILoopsAdapter):
title=_(u'Provider name'), title=_(u'Provider name'),
description=_(u'The name of a utility that provides the ' description=_(u'The name of a utility that provides the '
u'external objects; default is a directory ' u'external objects; default is a directory '
u'collection provider'), u'collection provider.'),
required=False) required=False)
baseAddress = schema.TextLine( baseAddress = schema.TextLine(
title=_(u'Base address'), title=_(u'Base address'),
description=_(u'A base path or URL for accessing this collection ' description=_(u'A base path or URL for accessing this collection '
u'on the external system'), u'on the external system.'),
required=True) required=True)
address = schema.TextLine( address = schema.TextLine(
title=_(u'Relative address'), title=_(u'Relative address'),
description=_(u'Optional second (local) part of the ' description=_(u'Optional second (local) part of the '
u'collection\'s address'), u'collection\'s address.'),
required=False) required=False)
pattern = schema.TextLine( pattern = schema.TextLine(
title=_(u'Selection pattern'), title=_(u'Selection pattern'),
description=_(u'A regular expression for selecting external objects ' description=_(u'A regular expression for selecting external objects '
u'that should belong to this collection'), u'that should belong to this collection.'),
required=False) required=False)
excludeDirectories = schema.Bool( excludeDirectories = schema.Bool(
title=_(u'Exclude directories'), title=_(u'Exclude directories'),
description=_(u'Check this if only object directly at the specified ' description=_(u'Check this if only objects directly at the specified '
u'address should be included in the collection.'), u'address should be included in the collection.'),
default=False, default=False,
required=False) required=False)
@ -80,6 +80,20 @@ class IExternalCollection(IConceptSchema, ILoopsAdapter):
u'be included.'), u'be included.'),
value_type=schema.TextLine(), value_type=schema.TextLine(),
required=False) required=False)
metaInfo = schema.Text(
title=_(u'Meta Information'),
description=_(u'A text giving some background information '
u'about a media asset, like source, rights, etc.'
u'This text will be applied to all resources '
u'belonging to this collection.'),
default=u'',
required=True)
overwriteMetaInfo = schema.Bool(
title=_(u'Overwrite Meta Information'),
description=_(u'Check this if meta information already present '
u'should be overwritten by the new text given above.'),
default=False,
required=False)
lastUpdated = Attribute('Date and time of last update.') lastUpdated = Attribute('Date and time of last update.')
def update(): def update():