a set of minor tweakings; prepare type management for consequent inclusion of resources/resource types
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1256 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
714e00bbfc
commit
f2d9bc9af8
4 changed files with 96 additions and 38 deletions
|
@ -125,13 +125,13 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<addMenuItem
|
<!--<addMenuItem
|
||||||
class="loops.concept.ConceptManager"
|
class="loops.concept.ConceptManager"
|
||||||
title="Concept Manager"
|
title="Concept Manager"
|
||||||
description="A concept manager manages concepts"
|
description="A concept manager manages concepts"
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
view="AddLoopsConceptManager.html"
|
view="AddLoopsConceptManager.html"
|
||||||
/>
|
/>-->
|
||||||
|
|
||||||
<containerViews
|
<containerViews
|
||||||
for="loops.interfaces.IConceptManager"
|
for="loops.interfaces.IConceptManager"
|
||||||
|
@ -218,13 +218,13 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<addMenuItem
|
<!--<addMenuItem
|
||||||
class="loops.resource.ResourceManager"
|
class="loops.resource.ResourceManager"
|
||||||
title="Resource Manager"
|
title="Resource Manager"
|
||||||
description="A resource manager manages resources"
|
description="A resource manager manages resources"
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
view="AddLoopsResourceManager.html"
|
view="AddLoopsResourceManager.html"
|
||||||
/>
|
/>-->
|
||||||
|
|
||||||
<containerViews
|
<containerViews
|
||||||
for="loops.interfaces.IResourceManager"
|
for="loops.interfaces.IResourceManager"
|
||||||
|
@ -377,13 +377,13 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<addMenuItem
|
<!--<addMenuItem
|
||||||
class="loops.view.ViewManager"
|
class="loops.view.ViewManager"
|
||||||
title="View Manager"
|
title="View Manager"
|
||||||
description="A view manager manages views, like nodes, menu items, ..."
|
description="A view manager manages views, like nodes, menu items, ..."
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
view="AddLoopsViewManager.html"
|
view="AddLoopsViewManager.html"
|
||||||
/>
|
/>-->
|
||||||
|
|
||||||
<containerViews
|
<containerViews
|
||||||
for="loops.interfaces.IViewManager"
|
for="loops.interfaces.IViewManager"
|
||||||
|
|
|
@ -185,7 +185,7 @@ get a type manager from all loops objects, always with the same context:
|
||||||
True
|
True
|
||||||
|
|
||||||
>>> types = typeManager.types
|
>>> types = typeManager.types
|
||||||
>>> sorted(t.token for t in types)
|
>>> sorted((t.token) for t in types)
|
||||||
['.loops/concepts/predicate', '.loops/concepts/topic',
|
['.loops/concepts/predicate', '.loops/concepts/topic',
|
||||||
'.loops/concepts/type', 'loops.resource.Document',
|
'.loops/concepts/type', 'loops.resource.Document',
|
||||||
'loops.resource.MediaAsset']
|
'loops.resource.MediaAsset']
|
||||||
|
|
|
@ -516,6 +516,34 @@ class ITypeConcept(Interface):
|
||||||
source="loops.TypeInterfaceSource",
|
source="loops.TypeInterfaceSource",
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
# viewName = schema.TextLine()
|
||||||
|
|
||||||
|
|
||||||
|
class IResourceAdapter(Interface):
|
||||||
|
""" Base interface for adapters for resources. This is the base interface
|
||||||
|
of the interfaces to be used as typeInterface attribute on type concepts
|
||||||
|
specifying resource types.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class IFile(IResourceAdapter):
|
||||||
|
""" A media asset that is not shown on a (web) page like an image but
|
||||||
|
may be downloaded instead.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class IImage(IResourceAdapter):
|
||||||
|
""" A media asset that may be embedded in a (web) page as an image.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ITextDocument(IResourceAdapter):
|
||||||
|
""" A resource containing some sort of plain text that may be rendered and
|
||||||
|
edited without necessarily involving a special external application
|
||||||
|
(like e.g. OpenOffice); typical content types are text/html, text/xml,
|
||||||
|
text/restructured, etc.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
# view configurator stuff
|
# view configurator stuff
|
||||||
|
|
||||||
|
|
88
type.py
88
type.py
|
@ -31,13 +31,18 @@ from zope import schema
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
from cybertools.typology.type import BaseType, TypeManager
|
from cybertools.typology.type import BaseType, TypeManager
|
||||||
from loops.interfaces import ILoopsObject, IConcept, IResource
|
from loops.interfaces import ILoopsObject, IConcept, IResource
|
||||||
from loops.interfaces import ITypeConcept
|
from loops.interfaces import ITypeConcept, IResourceAdapter, IFile, IImage
|
||||||
from loops.concept import Concept
|
from loops.concept import Concept
|
||||||
from loops.resource import Document, MediaAsset
|
from loops.resource import Resource, Document, MediaAsset
|
||||||
|
|
||||||
|
|
||||||
class LoopsType(BaseType):
|
class LoopsType(BaseType):
|
||||||
|
|
||||||
|
adapts(ILoopsObject)
|
||||||
|
|
||||||
|
factoryMapping = dict(concept=Concept, resource=Resource)
|
||||||
|
containerMapping = dict(concept='concepts', resource='resources')
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def title(self):
|
def title(self):
|
||||||
tp = self.typeProvider
|
tp = self.typeProvider
|
||||||
|
@ -52,55 +57,79 @@ class LoopsType(BaseType):
|
||||||
def tokenForSearch(self):
|
def tokenForSearch(self):
|
||||||
tp = self.typeProvider
|
tp = self.typeProvider
|
||||||
typeName = tp is None and 'unknown' or str(zapi.getName(tp))
|
typeName = tp is None and 'unknown' or str(zapi.getName(tp))
|
||||||
return ':'.join(('loops:concept', typeName,))
|
return ':'.join(('loops', self.qualifiers[0], typeName,))
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def typeInterface(self):
|
||||||
|
adapter = zapi.queryAdapter(self.typeProvider, ITypeConcept)
|
||||||
|
if adapter is not None:
|
||||||
|
return adapter.typeInterface
|
||||||
|
else:
|
||||||
|
conceptType = self.typeProvider
|
||||||
|
typeConcept = self.root.getConceptManager().getTypeConcept()
|
||||||
|
if conceptType is typeConcept:
|
||||||
|
return ITypeConcept
|
||||||
|
return None
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def qualifiers(self):
|
||||||
|
ti = self.typeInterface
|
||||||
|
if ti is None or not issubclass(ti, IResourceAdapter):
|
||||||
|
return ('concept',)
|
||||||
|
return ('resource',)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def factory(self):
|
||||||
|
return self.factoryMapping.get(self.qualifiers[0], Concept)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def defaultContainer(self):
|
||||||
|
return self.root[self.containerMapping.get(self.qualifiers[0], 'concept')]
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def root(self):
|
def root(self):
|
||||||
return self.context.getLoopsRoot()
|
return self.context.getLoopsRoot()
|
||||||
|
|
||||||
|
|
||||||
class ConceptType(LoopsType):
|
|
||||||
""" The IType adapter for concept objects.
|
|
||||||
"""
|
|
||||||
|
|
||||||
adapts(IConcept)
|
|
||||||
|
|
||||||
qualifiers = ('concept',)
|
|
||||||
factory = Concept
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def typeProvider(self):
|
def typeProvider(self):
|
||||||
return self.context.conceptType
|
return self.context.conceptType
|
||||||
|
|
||||||
@Lazy
|
|
||||||
def defaultContainer(self):
|
|
||||||
return self.root.getConceptManager()
|
|
||||||
|
|
||||||
@Lazy
|
class LoopsTypeInfo(LoopsType):
|
||||||
def typeInterface(self):
|
""" The type info class used by the type manager for listing types.
|
||||||
adapter = zapi.queryAdapter(self.typeProvider, ITypeConcept)
|
"""
|
||||||
if adapter is not None: # always gives TypeConcept
|
|
||||||
return adapter.typeInterface
|
|
||||||
else:
|
|
||||||
conceptType = self.typeProvider
|
|
||||||
if conceptType is conceptType.getLoopsRoot().getConceptManager().getTypeConcept():
|
|
||||||
return ITypeConcept
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class ConceptTypeInfo(ConceptType):
|
|
||||||
|
|
||||||
def __init__(self, typeProvider):
|
def __init__(self, typeProvider):
|
||||||
self.typeProvider = self.context = typeProvider
|
self.typeProvider = self.context = typeProvider
|
||||||
|
|
||||||
|
|
||||||
|
class ConceptType(LoopsType):
|
||||||
|
""" The IType adapter for concept objects.
|
||||||
|
Probably obsolete because all real stuff has gone to LoopsType.
|
||||||
|
"""
|
||||||
|
|
||||||
|
adapts(IConcept)
|
||||||
|
|
||||||
|
|
||||||
|
class ConceptTypeInfo(LoopsTypeInfo):
|
||||||
|
""" The type info class used by the type manager for listing types.
|
||||||
|
Probably obsolete because all real stuff has gone to LoopsTypeInfo.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ResourceType(LoopsType):
|
class ResourceType(LoopsType):
|
||||||
|
""" The 'old-style' resource type - different classes (Document, MediaAsset)
|
||||||
|
per type. Will be replaced by new style types that are governed by
|
||||||
|
type concepts as is already the case for concepts.
|
||||||
|
"""
|
||||||
|
|
||||||
adapts(IResource)
|
adapts(IResource)
|
||||||
|
|
||||||
typeTitles = {'MediaAsset': u'Media Asset'}
|
typeTitles = {'MediaAsset': u'Media Asset'}
|
||||||
|
|
||||||
|
typeInterface = None
|
||||||
qualifiers = ('resource',)
|
qualifiers = ('resource',)
|
||||||
|
typeProvider = None
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def title(self):
|
def title(self):
|
||||||
|
@ -204,6 +233,7 @@ class TypeInterfaceSourceList(object):
|
||||||
|
|
||||||
implements(schema.interfaces.IIterableSource)
|
implements(schema.interfaces.IIterableSource)
|
||||||
|
|
||||||
|
#typeInterfaces = (ITypeConcept, IFile, IImage,)
|
||||||
typeInterfaces = (ITypeConcept,)
|
typeInterfaces = (ITypeConcept,)
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
|
|
Loading…
Add table
Reference in a new issue