loops/integrator/interfaces.py
helmutm be71f62a6e improvements for external collection and media asset: integration now working correctly, with generation of scal variants for media assets
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3105 fd906abe-77d9-0310-91a1-e0d9ade77398
2008-12-31 13:46:18 +00:00

110 lines
4.2 KiB
Python

#
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
#
# 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
#
"""
Integrator interfaces.
$Id$
"""
from zope.interface import Interface, Attribute
from zope import interface, component, schema
from loops.interfaces import IConceptSchema
from loops.util import _
class IExternalSourceInfo(Interface):
""" Provide additional information about the external source
of an object.
"""
externalIdentifier = Attribute('A string that allows to uniquely '
'identify a resource or concept that is provided by an '
'external system, e.g. a client-base loops agent. ')
# external collections
class IExternalCollection(IConceptSchema):
""" A concept representing a collection of resources that may be
actively retrieved from an external system using the parameters
given.
"""
providerName = schema.TextLine(
title=_(u'Provider name'),
description=_(u'The name of a utility that provides the '
u'external objects; default is a directory '
u'collection provider'),
required=False)
baseAddress = schema.TextLine(
title=_(u'Base address'),
description=_(u'A base path or URL for accessing this collection '
u'on the external system'),
required=True)
address = schema.TextLine(
title=_(u'Relative address'),
description=_(u'Optional second (local) part of the '
u'collection\'s address'),
required=False)
pattern = schema.TextLine(
title=_(u'Selection pattern'),
description=_(u'A regular expression for selecting external objects '
u'that should belong to this collection'),
required=False)
exclude = schema.List(
title=_(u'Exclude'),
description=_(u'Names of directories and files that should not '
u'be included.'),
value_type=schema.TextLine(),
required=False)
lastUpdated = Attribute('Date and time of last update.')
def update():
""" Select external objects that should belong to a collection
and check for new, changed, or deleted objects.
Create an 'extfile' resource for new ones, fire appropriate
events for new, changed, or deleted ones.
Resources for deleted objects are not removed but should
be empty; they also should receive some state change.
"""
class IExternalCollectionProvider(Interface):
""" A utility that provides access to an external collection of objects.
"""
def collect(clientCollection):
""" Select objects that should belong to a collection,
return an iterable of tuples of local address parts of the selected external
objects and their last modification date/time.
The object specified by the 'clientCollection' argument
is usually the caller of the method and should provide the
IExternalCollection interface.
"""
def createExtFileObjects(clientCollection, addresses, extFileTypes=None):
""" Create a resource for each of the addresses provided.
Return the list of objects created.
The ``extFileTypes`` argument is a mapping of MIME types to
names of concept types. The MIME types may contain wildcards,
e.g. 'image/*', '*/*'.
"""