[Zope-CVS] CVS: Products/CompositePage - slotdef.py:1.1
__init__.py:1.4 interfaces.py:1.3 macro.py:1.4 slot.py:1.9
tool.py:1.5
Shane Hathaway
shane at zope.com
Fri Dec 26 15:44:02 EST 2003
Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv18360
Modified Files:
__init__.py interfaces.py macro.py slot.py tool.py
Added Files:
slotdef.py
Log Message:
Added slot definitions.
Slot definitions let you define the meaning of named slots.
=== Added File Products/CompositePage/slotdef.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Slot definition class.
$Id: slotdef.py,v 1.1 2003/12/26 20:43:30 shane Exp $
"""
import os
from AccessControl.ZopeGuards import guarded_getattr
from Acquisition import aq_inner, aq_parent
from OFS.SimpleItem import SimpleItem
from OFS.PropertyManager import PropertyManager
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from interfaces import ISlotDefinition
_www = os.path.join(os.path.dirname(__file__), "www")
class SlotDefinition(SimpleItem, PropertyManager):
"""Parameters and constraints for a slot.
"""
__implements__ = ISlotDefinition
meta_type = "Composite Slot Definition"
find_script = ""
inline_views = ()
manage_options = (PropertyManager.manage_options
+ SimpleItem.manage_options)
_properties = (
{'id': 'find_script', 'mode': 'w', 'type': 'string',
'label': 'Script that finds available elements',},
{'id': 'inline_views', 'mode': 'w', 'type': 'lines',
'label': 'Allowable inline view names',},
)
def findAvailableElements(self, slot):
if not self.find_script:
return None
parent = aq_parent(aq_inner(self))
s = guarded_getattr(parent, self.find_script)
return s(slot)
addSlotDefForm = PageTemplateFile("addSlotDefForm", _www)
def manage_addSlotDef(dispatcher, id, REQUEST=None):
"""Adds a slot definition to a composite tool.
"""
ob = SlotDefinition()
ob._setId(id)
dispatcher._setObject(ob.getId(), ob)
if REQUEST is not None:
return dispatcher.manage_main(dispatcher, REQUEST)
=== Products/CompositePage/__init__.py 1.3 => 1.4 ===
--- Products/CompositePage/__init__.py:1.3 Mon Oct 13 12:12:53 2003
+++ Products/CompositePage/__init__.py Fri Dec 26 15:43:30 2003
@@ -15,7 +15,7 @@
$Id$
"""
-import tool, composite, slot, transformers
+import tool, composite, slot, slotdef, transformers, interfaces
tool.registerTransformer("common", transformers.CommonTransformer())
tool.registerTransformer("zmi", transformers.ZMITransformer())
@@ -31,6 +31,16 @@
)
context.registerClass(
+ slotdef.SlotDefinition,
+ constructors=(slotdef.addSlotDefForm,
+ slotdef.manage_addSlotDef,
+ ),
+ interfaces=(interfaces.ISlotDefinition,),
+ visibility=None,
+ icon="www/slot.gif",
+ )
+
+ context.registerClass(
composite.Composite,
constructors=(composite.addCompositeForm,
composite.manage_addComposite,
@@ -45,5 +55,6 @@
slot.manage_generateSlots,
),
visibility=None,
+ icon="www/slot.gif",
)
=== Products/CompositePage/interfaces.py 1.2 => 1.3 ===
--- Products/CompositePage/interfaces.py:1.2 Wed Oct 1 14:59:31 2003
+++ Products/CompositePage/interfaces.py Fri Dec 26 15:43:30 2003
@@ -17,6 +17,10 @@
from Interface import Interface
+class CompositeError(Exception):
+ """An error in constructing a composite
+ """
+
class ISlot(Interface):
"""A slot in a composite.
"""
@@ -45,8 +49,18 @@
"""
-
-class CompositeError(Exception):
- """An error in constructing a composite
+class ISlotDefinition(Interface):
+ """Parameters and constraints for a slot.
"""
+ # inline_views is an attribute listing allowed view names. If
+ # this list is not empty, it is intersected with the inline views
+ # provided by the object type to determine what views are
+ # available. If this list is empty, all inline views provided by
+ # the object type are available.
+
+ def findAvailableElements():
+ """Returns a list of elements available for this slot.
+
+ Generally returns catalog results.
+ """
=== Products/CompositePage/macro.py 1.3 => 1.4 ===
--- Products/CompositePage/macro.py:1.3 Wed Nov 5 15:04:50 2003
+++ Products/CompositePage/macro.py Fri Dec 26 15:43:30 2003
@@ -93,3 +93,7 @@
TALInterpreter(program, {}, c, output, tal=1, strictinsert=0)()
return output.getvalue()
+
+def getDocumentMacroName(program):
+ raise NotImplementedError
+
=== Products/CompositePage/slot.py 1.8 => 1.9 ===
--- Products/CompositePage/slot.py:1.8 Fri Dec 26 14:00:33 2003
+++ Products/CompositePage/slot.py Fri Dec 26 15:43:30 2003
@@ -143,7 +143,9 @@
res.append(tag)
try:
- if safe_callable(obj):
+ if hasattr(aq_base(obj), "render_inline"):
+ text = obj.render_inline()
+ elif safe_callable(obj):
text = obj()
else:
text = str(obj)
=== Products/CompositePage/tool.py 1.4 => 1.5 ===
--- Products/CompositePage/tool.py:1.4 Mon Oct 13 17:55:24 2003
+++ Products/CompositePage/tool.py Fri Dec 26 15:43:30 2003
@@ -19,10 +19,11 @@
import Globals
from Acquisition import aq_base, aq_parent, aq_inner
from OFS.SimpleItem import SimpleItem
+from OFS.Folder import Folder
from AccessControl import ClassSecurityInfo
from AccessControl.ZopeGuards import guarded_getattr
-from interfaces import ISlot, CompositeError
+from interfaces import ISlot, ISlotDefinition, CompositeError
_transformers = {}
@@ -54,7 +55,7 @@
-class CompositeTool(SimpleItem):
+class CompositeTool(Folder):
"""Page composition helper tool.
"""
meta_type = "Composite Tool"
@@ -67,6 +68,9 @@
_check_security = 1 # Turned off in unit tests
+
+ def all_meta_types(self):
+ return Folder.all_meta_types(self, interfaces=(ISlotDefinition,))
security.declarePublic("moveElements")
def moveElements(self, source_paths, target_path, target_index):
More information about the Zope-CVS
mailing list