[Zope-CVS] CVS: Products/CompositePage - composite.py:1.5
transformers.py:1.4
Shane Hathaway
shane at zope.com
Thu Oct 9 17:29:45 EDT 2003
Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv9150
Modified Files:
composite.py transformers.py
Log Message:
Added a basic CMF UI to composites.
Refactored the ZMI interface somewhat, moving common elements down.
=== Products/CompositePage/composite.py 1.4 => 1.5 ===
--- Products/CompositePage/composite.py:1.4 Wed Oct 8 14:05:00 2003
+++ Products/CompositePage/composite.py Thu Oct 9 17:29:15 2003
@@ -38,6 +38,8 @@
class SlotGenerator (Acquisition.Explicit):
"""Automatically makes slots available to the template.
"""
+ _slot_class = Slot
+
def __getitem__(self, name):
composite = aq_parent(aq_inner(self))
slots = composite.filled_slots
@@ -45,7 +47,7 @@
return slots[name]
except (KeyError, AttributeError):
# Generate a new slot.
- s = Slot(name)
+ s = self._slot_class(name)
if composite._v_generating:
# Persist the slot immediately.
slots._setObject(s.getId(), s)
=== Products/CompositePage/transformers.py 1.3 => 1.4 ===
--- Products/CompositePage/transformers.py:1.3 Thu Oct 9 12:27:12 2003
+++ Products/CompositePage/transformers.py Thu Oct 9 17:29:15 2003
@@ -31,6 +31,7 @@
_common = os.path.join(os.path.dirname(__file__), "common")
_zmi = os.path.join(os.path.dirname(__file__), "zmi")
+_cmf = os.path.join(os.path.dirname(__file__), "cmf")
start_of_head_search = re.compile("(<head[^>]*>)", re.IGNORECASE).search
start_of_body_search = re.compile("(<body[^>]*>)", re.IGNORECASE).search
@@ -68,6 +69,7 @@
top_templates = ()
bottom_templates = (PageTemplateFile("bottom.pt", _common),)
+ workspace_view_name = "" # To be overridden
security.declarePublic("transform")
def transform(self, composite, text):
@@ -118,26 +120,6 @@
return text
-Globals.InitializeClass(CommonTransformer)
-
-
-
-class ZMITransformer (CommonTransformer):
- """Zope management interface page transformer.
-
- Adds editing features to a rendered composite.
- """
- security = ClassSecurityInfo()
-
- security.declarePublic("zmi_edit_js")
- zmi_edit_js = RawFile("zmi_edit.js", "text/javascript", _zmi)
-
- header_templates = CommonTransformer.header_templates + (
- PageTemplateFile("header.pt", _zmi),)
- top_templates = CommonTransformer.top_templates + (
- PageTemplateFile("top.pt", _zmi),)
- bottom_templates = (PageTemplateFile("bottom.pt", _zmi),
- ) + CommonTransformer.bottom_templates
security.declarePublic("showElement")
def showElement(self, path, RESPONSE):
@@ -145,7 +127,9 @@
"""
root = self.getPhysicalRoot()
obj = root.restrictedTraverse(path)
- RESPONSE.redirect(obj.absolute_url() + "/manage_workspace")
+ RESPONSE.redirect("%s/%s" % (
+ obj.absolute_url(), self.workspace_view_name))
+
security.declarePublic("showSlot")
def showSlot(self, path, RESPONSE):
@@ -164,11 +148,36 @@
if is_comp:
gen = guarded_getattr(obj, "generateSlots")
gen()
- RESPONSE.redirect(obj.absolute_url() + "/manage_workspace")
+ RESPONSE.redirect("%s/%s" % (
+ obj.absolute_url(), self.workspace_view_name))
+
+Globals.InitializeClass(CommonTransformer)
+
+
+
+class ZMITransformer (CommonTransformer):
+ """Zope management interface page transformer.
+
+ Adds editing features to a rendered composite.
+ """
+ security = ClassSecurityInfo()
+
+ workspace_view_name = "manage_workspace"
+
+ security.declarePublic("zmi_edit_js")
+ zmi_edit_js = RawFile("zmi_edit.js", "text/javascript", _zmi)
+
+ header_templates = CommonTransformer.header_templates + (
+ PageTemplateFile("header.pt", _zmi),)
+ top_templates = CommonTransformer.top_templates + (
+ PageTemplateFile("top.pt", _zmi),)
+ bottom_templates = (PageTemplateFile("bottom.pt", _zmi),
+ ) + CommonTransformer.bottom_templates
Globals.InitializeClass(ZMITransformer)
+
class CMFTransformer (CommonTransformer):
"""CMF page transformer.
@@ -176,9 +185,15 @@
"""
security = ClassSecurityInfo()
- header_templates = CommonTransformer.header_templates + ()
- top_templates = CommonTransformer.top_templates + ()
- bottom_templates = CommonTransformer.bottom_templates + ()
+ workspace_view_name = "view"
+
+ security.declarePublic("cmf_edit_js")
+ cmf_edit_js = RawFile("cmf_edit.js", "text/javascript", _cmf)
+
+ header_templates = CommonTransformer.header_templates + (
+ PageTemplateFile("header.pt", _cmf),)
+ bottom_templates = (PageTemplateFile("bottom.pt", _cmf),
+ ) + CommonTransformer.bottom_templates
Globals.InitializeClass(CMFTransformer)
More information about the Zope-CVS
mailing list