[Zope-CVS] CVS: Products/PageDesign - BrokenPageElement.py:1.2 IPageElement.py:1.3 PageDesign.py:1.11 SimpleItemAsElement.py:1.2 Slot.py:1.5
Matthew T. Kromer
matt@zope.com
Thu, 27 Feb 2003 11:55:42 -0500
Update of /cvs-repository/Products/PageDesign
In directory cvs.zope.org:/tmp/cvs-serv3165
Modified Files:
BrokenPageElement.py IPageElement.py PageDesign.py
SimpleItemAsElement.py Slot.py
Log Message:
Add slot name support to the options passed to reneded page elements, and add
getSlotData and setSlotData to get/set slot-specific data in the main template
so that slots have a place to store supplemental information.
=== Products/PageDesign/BrokenPageElement.py 1.1 => 1.2 ===
--- Products/PageDesign/BrokenPageElement.py:1.1 Thu Aug 15 21:17:47 2002
+++ Products/PageDesign/BrokenPageElement.py Thu Feb 27 11:55:40 2003
@@ -23,7 +23,7 @@
self._path = path
self._exc = exc
- def render(self, design, editable, index):
+ def render(self, design, editable, index, slot_name):
"""Returns a string.
"""
return '<code>Unable to locate "%s": %s</code>' % (
=== Products/PageDesign/IPageElement.py 1.2 => 1.3 ===
--- Products/PageDesign/IPageElement.py:1.2 Mon Aug 12 10:39:29 2002
+++ Products/PageDesign/IPageElement.py Thu Feb 27 11:55:40 2003
@@ -16,7 +16,7 @@
class IPageElement (Interface):
- def render(design, editable, index):
+ def render(design, editable, index, slot_name):
"""Returns a string.
"""
=== Products/PageDesign/PageDesign.py 1.10 => 1.11 ===
--- Products/PageDesign/PageDesign.py:1.10 Fri Feb 21 10:48:10 2003
+++ Products/PageDesign/PageDesign.py Thu Feb 27 11:55:40 2003
@@ -60,6 +60,7 @@
"""Base class for page designs.
"""
_slots = None # { slot_name -> (element_id,) }
+ _supplemental = None # Supplemental slot data
template_id = None
title = ''
pre_expand = 0
@@ -145,6 +146,7 @@
def __init__(self, id, title=''):
self._slots = PersistentMapping()
+ self._supplemental = PersistentMapping()
self.id = id
if title:
self.title = title
@@ -164,7 +166,25 @@
"""Removes a slot.
"""
del self._slots[name]
+ if self._supplemental and self._supplemental.has_key(name):
+ del self._supplemental[name]
+ security.declareProtected(change_page_designs, 'setSlotData')
+ def setSlotData(self, name, index, data, REQUEST=None):
+ """Sets the supplemental slot data for a slot & index
+ """
+ if not self._supplemental: self._supplemental = PersistentMapping()
+ supplemental = self._supplemental.get(name,PersistentMapping())
+ supplemental[index] = data
+ self._supplemental[name] = supplemental
+
+ security.declarePublic('getSlotData')
+ def getSlotData(self, name, index):
+ """Gets the supplemental data for a slot and index, or None if none
+ was set.
+ """
+ if not self._supplemental: return None
+ return self._supplemental.get(name,{}).get(index, None)
security.declareProtected(change_page_designs, 'moveElement')
def moveElement(self, source_path, target_path, RESPONSE=None):
@@ -293,6 +313,7 @@
sort_order = REQUEST.get('sort_order', '')
for ob in folder.objectValues():
+ __traceback_info__ = ob
base = aq_base(ob)
if hasattr(base, 'Title'):
title = ob.Title()
=== Products/PageDesign/SimpleItemAsElement.py 1.1 => 1.2 ===
--- Products/PageDesign/SimpleItemAsElement.py:1.1 Thu Aug 15 20:29:35 2002
+++ Products/PageDesign/SimpleItemAsElement.py Thu Feb 27 11:55:40 2003
@@ -25,17 +25,19 @@
def __init__(self, ob):
self._ob = ob
- def render(self, design, editable, index):
+ def render(self, design, editable, index, slot_name):
"""Returns a string.
"""
ob = self._ob
if getattr(aq_base(ob), 'isDocTemp', 0):
# DTML
s = ob(self, aq_get(self, 'REQUEST'),
- design=design, editable=editable, index=index)
+ design=design, editable=editable, index=index,
+ slot_name=slot_name)
elif hasattr(ob, '__call__'):
# Other kinds of callable objects
- s = ob(design=design, editable=editable, index=index)
+ s = ob(design=design, editable=editable, index=index,
+ slot_name=slot_name)
else:
s = str(ob)
return s
=== Products/PageDesign/Slot.py 1.4 => 1.5 ===
--- Products/PageDesign/Slot.py:1.4 Thu Aug 15 20:29:35 2002
+++ Products/PageDesign/Slot.py Thu Feb 27 11:55:40 2003
@@ -96,6 +96,12 @@
def getId(self):
return self.id
+ security.declarePublic("getSlotId")
+ def getSlotId(self):
+ """
+ Return our ID for things we are presenting
+ """
+ return self.id
def renderTargetHTML(self, **kw):
kw['target_icon'] = target_icon
@@ -176,7 +182,7 @@
))
try:
- text = e.render(design, editable, index)
+ text = e.render(design, editable, index, self.id)
except:
# Show the exception.
t, v = sys.exc_info()[:2]