[Zope-CVS] CVS: Products/PageDesign - ElementReference.py:1.3 PageDesign.py:1.12
Matthew T. Kromer
matt@zope.com
Wed, 5 Mar 2003 15:01:56 -0500
Update of /cvs-repository/Products/PageDesign
In directory cvs.zope.org:/tmp/cvs-serv14175
Modified Files:
ElementReference.py PageDesign.py
Log Message:
Move supplemental data storage on per-element references to a more permanent
home, ie on the Element Reference object itself rather than in the crufty
interim place of a supplemental PersistentMapping object.
=== Products/PageDesign/ElementReference.py 1.2 => 1.3 ===
--- Products/PageDesign/ElementReference.py:1.2 Thu Aug 15 21:17:47 2002
+++ Products/PageDesign/ElementReference.py Wed Mar 5 15:01:55 2003
@@ -29,8 +29,11 @@
__implements__ = IElementReference
+ _data = None
+
def __init__(self, ob):
self._path = ob.getPhysicalPath()
+ self._data = None
def dereference(self):
try:
@@ -60,6 +63,13 @@
bp = self.getBaseObject().getPhysicalPath()
self._path = makeAbsolutePath(bp, self._path)
+ def getData(self):
+ """Returns our associated data"""
+ return self._data
+
+ def setData(self, value):
+ """Sets our associated data"""
+ self._data = value
# Utility tuple-path converters
=== Products/PageDesign/PageDesign.py 1.11 => 1.12 ===
--- Products/PageDesign/PageDesign.py:1.11 Thu Feb 27 11:55:40 2003
+++ Products/PageDesign/PageDesign.py Wed Mar 5 15:01:55 2003
@@ -60,7 +60,6 @@
"""Base class for page designs.
"""
_slots = None # { slot_name -> (element_id,) }
- _supplemental = None # Supplemental slot data
template_id = None
title = ''
pre_expand = 0
@@ -146,7 +145,6 @@
def __init__(self, id, title=''):
self._slots = PersistentMapping()
- self._supplemental = PersistentMapping()
self.id = id
if title:
self.title = title
@@ -166,25 +164,28 @@
"""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
+ try:
+ return self._slots[name].getElementReference(
+ int(index)).setData(data)
+ except (AttributeError, TypeError, KeyError):
+ return
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)
+ print self._slots[name].getElementReference(int(index))
+
+ try:
+ return self._slots[name].getElementReference(int(index)).getData()
+ except (AttributeError, TypeError, KeyError):
+ return None
security.declareProtected(change_page_designs, 'moveElement')
def moveElement(self, source_path, target_path, RESPONSE=None):