[Zope-CVS] CVS: Products/CompositePage - interfaces.py:1.4
slot.py:1.10 slotdef.py:1.2 tool.py:1.6
Shane Hathaway
shane at zope.com
Sat Dec 27 13:40:51 EST 2003
Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv4578
Modified Files:
interfaces.py slot.py slotdef.py tool.py
Log Message:
Added a header to the context menus and began work on inline views.
=== Products/CompositePage/interfaces.py 1.3 => 1.4 ===
--- Products/CompositePage/interfaces.py:1.3 Fri Dec 26 15:43:30 2003
+++ Products/CompositePage/interfaces.py Sat Dec 27 13:40:19 2003
@@ -64,3 +64,25 @@
Generally returns catalog results.
"""
+
+
+class IRenderableInline(Interface):
+ """Interface of objects that can be rendered inline (as page elements).
+ """
+
+ def renderInline(self):
+ """Returns a string rendering of this object.
+ """
+
+ def getInlineView(self):
+ """Returns the name of the inline view this object uses.
+ """
+
+ def setInlineView(self, view):
+ """Sets the inline view for this object.
+ """
+
+ def listAllowableInlineViews():
+ """Returns a list of view names allowable for this object.
+ """
+
=== Products/CompositePage/slot.py 1.9 => 1.10 ===
--- Products/CompositePage/slot.py:1.9 Fri Dec 26 15:43:30 2003
+++ Products/CompositePage/slot.py Sat Dec 27 13:40:19 2003
@@ -43,7 +43,10 @@
_www = os.path.join(os.path.dirname(__file__), "www")
-EDIT_TAG = '''<div class="slot_element" source_path="%s">
+TARGET_TAG = '''<div class="slot_target" title="Slot: %s [%d]"
+target_path="%s" target_index="%d"></div>'''
+
+EDIT_TAG = '''<div class="slot_element" source_path="%s" icon="%s" title="%s">
%s
</div>'''
@@ -134,12 +137,12 @@
items = self.objectItems()
if editing:
mypath = escape('/'.join(self.getPhysicalPath()))
+ myid = self.getId()
for index in range(len(items)):
name, obj = items[index]
if editing and allow_add:
- tag = ('<div class="slot_target" target_path="%s" '
- 'target_index="%d"></div>' % (mypath, index))
+ tag = TARGET_TAG % (myid, index, mypath, index)
res.append(tag)
try:
@@ -163,7 +166,7 @@
msg = "An error occurred. %s" % (
escape(('%s: %s' % (t, v))[:80]))
else:
- # Show viewers a
+ # Show viewers a simplified error with a number
msg = ("An error occurred while generating "
"this part of the page.")
text = "%s (#%d)" % (msg, ref)
@@ -172,15 +175,25 @@
error=sys.exc_info())
if editing:
+ base = aq_base(obj)
+
+ if hasattr(base, 'getIcon'):
+ icon = str(obj.getIcon())
+ elif hasattr(base, 'icon'):
+ icon = str(obj.icon)
+ else:
+ icon = ""
+
+ title = obj.title_and_id()
path = escape('/'.join(obj.getPhysicalPath()))
- res.append(EDIT_TAG % (path, text))
+ res.append(EDIT_TAG % (path,
+ escape(icon), escape(title), text))
else:
res.append(VIEW_TAG % text)
if editing and allow_add:
index = len(items)
- tag = ('<div class="slot_target" target_path="%s" '
- 'target_index="%d"></div>' % (mypath, index))
+ tag = TARGET_TAG % (myid, index, mypath, index)
res.append(tag)
return res
=== Products/CompositePage/slotdef.py 1.1 => 1.2 ===
--- Products/CompositePage/slotdef.py:1.1 Fri Dec 26 15:43:30 2003
+++ Products/CompositePage/slotdef.py Sat Dec 27 13:40:19 2003
@@ -18,7 +18,6 @@
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
@@ -50,8 +49,8 @@
def findAvailableElements(self, slot):
if not self.find_script:
return None
- parent = aq_parent(aq_inner(self))
- s = guarded_getattr(parent, self.find_script)
+ tool = aq_parent(aq_inner(aq_parent(aq_inner(self))))
+ s = tool.restrictedTraverse(self.find_script)
return s(slot)
=== Products/CompositePage/tool.py 1.5 => 1.6 ===
--- Products/CompositePage/tool.py:1.5 Fri Dec 26 15:43:30 2003
+++ Products/CompositePage/tool.py Sat Dec 27 13:40:19 2003
@@ -54,6 +54,14 @@
raise AttributeError, name
+class SlotDefFolder(Folder):
+ """Container of slot definitions.
+ """
+ meta_type = "Slot Definition Folder"
+
+ def all_meta_types(self):
+ return Folder.all_meta_types(self, interfaces=(ISlotDefinition,))
+
class CompositeTool(Folder):
"""Page composition helper tool.
@@ -68,9 +76,11 @@
_check_security = 1 # Turned off in unit tests
-
- def all_meta_types(self):
- return Folder.all_meta_types(self, interfaces=(ISlotDefinition,))
+ def __init__(self):
+ sd = SlotDefFolder()
+ sd._setId("slot_defs")
+ self._setObject(sd.id, sd)
+ self._reserved_names = ('slot_defs',)
security.declarePublic("moveElements")
def moveElements(self, source_paths, target_path, target_index):
More information about the Zope-CVS
mailing list