[Zope-CVS] CVS: Products/CompositePage - composite.py:1.11
designuis.py:1.4 interfaces.py:1.6 render.py:1.5 slot.py:1.16
tool.py:1.10
Shane Hathaway
shane at zope.com
Tue Mar 2 10:28:38 EST 2004
Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv1462
Modified Files:
composite.py designuis.py interfaces.py render.py slot.py
tool.py
Log Message:
Renamed view to template
=== Products/CompositePage/composite.py 1.10 => 1.11 ===
--- Products/CompositePage/composite.py:1.10 Thu Feb 26 16:38:11 2004
+++ Products/CompositePage/composite.py Tue Mar 2 10:28:38 2004
@@ -228,8 +228,8 @@
'next_index': index + 1,
'can_move_up': (index > 0),
'can_move_down': (index < len(slot_values) - 1),
- 'view': 'xxx',
- 'available_views': ('yyy', 'zzz'),
+ 'template': 'xxx',
+ 'available_templates': ('yyy', 'zzz'),
}
elements.append(element_info)
index += 1
=== Products/CompositePage/designuis.py 1.3 => 1.4 ===
--- Products/CompositePage/designuis.py:1.3 Fri Feb 27 11:18:49 2004
+++ Products/CompositePage/designuis.py Tue Mar 2 10:28:38 2004
@@ -80,7 +80,7 @@
top_templates = ()
bottom_templates = (PageTemplateFile("bottom.pt", _common),)
- changeViewForm = PageTemplateFile("changeViewForm.pt", _common)
+ changeTemplateForm = PageTemplateFile("changeTemplateForm.pt", _common)
workspace_view_name = "view" # To be overridden
@@ -181,56 +181,56 @@
obj.absolute_url(), self.workspace_view_name))
- security.declarePublic("getViewChangeInfo")
- def getViewChangeInfo(self, paths):
- """Returns information for changing the view applied to objects.
+ security.declarePublic("getTemplateChangeInfo")
+ def getTemplateChangeInfo(self, paths):
+ """Returns information for changing the template applied to objects.
"""
root = self.getPhysicalRoot()
tool = aq_parent(aq_inner(self))
obs = []
- all_choices = None # {view -> 1}
+ all_choices = None # {template -> 1}
current = None
for path in str(paths).split(':'):
ob = root.restrictedTraverse(path)
obs.append(ob)
renderer = tool.getRendererFor(ob)
- m = guarded_getattr(renderer, "getInlineView")
- view = m()
+ m = guarded_getattr(renderer, "getInlineTemplate")
+ template = m()
if current is None:
- current = view
- elif current and current != view:
- # The current view isn't the same for all of the elements,
- # so there is no common current view. Spell this condition
+ current = template
+ elif current and current != template:
+ # The current template isn't the same for all of the elements,
+ # so there is no common current template. Spell this condition
# using a non-string value.
current = 0
- m = guarded_getattr(renderer, "listAllowableInlineViews")
- views = m()
+ m = guarded_getattr(renderer, "listAllowableInlineTemplates")
+ templates = m()
d = {}
- for view in views:
- d[view] = 1
+ for template in templates:
+ d[template] = 1
if all_choices is None:
all_choices = d
else:
- for view in all_choices.keys():
- if not d.has_key(view):
- del all_choices[view]
- views = all_choices.keys()
- views.sort()
- return {"obs": obs, "views": views, "current_view": current}
+ for template in all_choices.keys():
+ if not d.has_key(template):
+ del all_choices[template]
+ templates = all_choices.keys()
+ templates.sort()
+ return {"obs": obs, "templates": templates, "current_template": current}
- security.declarePublic("changeView")
- def changeView(self, paths, view, REQUEST=None):
- """Changes the view for objects.
- """
- info = self.getViewChangeInfo(paths)
- if view not in info["views"]:
- raise KeyError("View %s is not among the choices" % view)
+ security.declarePublic("changeTemplate")
+ def changeTemplate(self, paths, template, REQUEST=None):
+ """Changes the template for objects.
+ """
+ info = self.getTemplateChangeInfo(paths)
+ if template not in info["templates"]:
+ raise KeyError("Template %s is not among the choices" % template)
tool = aq_parent(aq_inner(self))
for ob in info["obs"]:
renderer = tool.getRendererFor(ob)
- m = guarded_getattr(renderer, "setInlineView")
- m(view)
+ m = guarded_getattr(renderer, "setInlineTemplate")
+ m(template)
if REQUEST is not None:
return close_dialog_html
=== Products/CompositePage/interfaces.py 1.5 => 1.6 ===
--- Products/CompositePage/interfaces.py:1.5 Sat Dec 27 17:56:43 2003
+++ Products/CompositePage/interfaces.py Tue Mar 2 10:28:38 2004
@@ -53,10 +53,10 @@
"""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
+ # inline_templates is an attribute listing allowed template names. If
+ # this list is not empty, it is intersected with the inline templates
+ # provided by the object type to determine what templates are
+ # available. If this list is empty, all inline templates provided by
# the object type are available.
def findAvailableElements():
@@ -74,16 +74,16 @@
"""Returns a representation of this object as a string.
"""
- def getInlineView():
- """Returns the name of the inline view this object uses.
+ def getInlineTemplate():
+ """Returns the name of the inline template this object uses.
"""
- def setInlineView(view):
- """Sets the inline view for this object.
+ def setInlineTemplate(template):
+ """Sets the inline template for this object.
"""
- def listAllowableInlineViews():
- """Returns a list of inline view names allowable for this object.
+ def listAllowableInlineTemplates():
+ """Returns a list of inline template names allowable for this object.
"""
=== Products/CompositePage/render.py 1.4 => 1.5 ===
--- Products/CompositePage/render.py:1.4 Wed Dec 31 12:32:14 2003
+++ Products/CompositePage/render.py Tue Mar 2 10:28:38 2004
@@ -78,53 +78,53 @@
"""
ob = aq_parent(aq_inner(self))
anns = adapt(ob, IAnnotations)
- name = anns.getAnnotation("inline_view")
+ name = anns.getAnnotation("inline_template")
if not name:
- # Default to the first allowable inline view.
- names = self.listAllowableInlineViews()
+ # Default to the first allowable inline template.
+ names = self.listAllowableInlineTemplates()
if names:
name = names[0]
if name and name != "call":
- view = ob.restrictedTraverse(str(name))
- return view()
- # Special view name "call" means to call the object.
+ template = ob.restrictedTraverse(str(name))
+ return template()
+ # Special template name "call" means to call the object.
if safe_callable(ob):
return ob()
return str(ob)
- security.declareProtected(perm_names.view, "getInlineView")
- def getInlineView(self):
- """Returns the name of the inline view this object uses.
+ security.declareProtected(perm_names.view, "getInlineTemplate")
+ def getInlineTemplate(self):
+ """Returns the name of the inline template this object uses.
"""
ob = aq_parent(aq_inner(self))
anns = adapt(ob, IAnnotations)
- return anns.getAnnotation("inline_view")
+ return anns.getAnnotation("inline_template")
- security.declareProtected(perm_names.change_composites, "setInlineView")
- def setInlineView(self, name):
- """Sets the inline view for this object.
+ security.declareProtected(perm_names.change_composites, "setInlineTemplate")
+ def setInlineTemplate(self, name):
+ """Sets the inline template for this object.
"""
name = str(name)
ob = aq_parent(aq_inner(self))
anns = adapt(ob, IAnnotations)
- anns.setAnnotation("inline_view", name)
+ anns.setAnnotation("inline_template", name)
security.declareProtected(perm_names.change_composites,
- "listAllowableInlineViews")
- def listAllowableInlineViews(self):
- """Returns a list of view names allowable for this object.
+ "listAllowableInlineTemplates")
+ def listAllowableInlineTemplates(self):
+ """Returns a list of template names allowable for this object.
"""
ob = aq_parent(aq_inner(self))
if hasattr(aq_base(ob), "getTypeInfo"):
ti = ob.getTypeInfo()
- if hasattr(aq_base(ti), "inline_views"):
- res = ti.inline_views
+ if hasattr(aq_base(ti), "inline_templates"):
+ res = ti.inline_templates
if res:
return res
tool = aq_get(self, "composite_tool", None, 1)
if tool is not None:
- return tool.default_inline_views
- # No tool found, so no inline views are known.
+ return tool.default_inline_templates
+ # No tool found, so no inline templates are known.
return ()
InitializeClass(SimpleItemInlineRenderer)
@@ -132,13 +132,17 @@
renderer_factory = SimpleItemInlineRenderer().__of__
+
+
def adapt(ob, iface):
# This is a simple substitute for adapter lookup.
if iface.isImplementedBy(ob):
return ob
if isinstance(ob, SimpleItem):
if iface is IRenderableInline:
- return renderer_factory(ob)
+ from Products.base_cms.composite import InlineRenderer
+ return InlineRenderer(ob).__of__(ob)
+ #return renderer_factory(ob)
if iface is IAnnotations:
return SimpleItemAnnotations(ob)
raise LookupError("No adapter found")
=== Products/CompositePage/slot.py 1.15 => 1.16 ===
--- Products/CompositePage/slot.py:1.15 Thu Feb 26 16:38:11 2004
+++ Products/CompositePage/slot.py Tue Mar 2 10:28:38 2004
@@ -135,6 +135,14 @@
objs = [info for info in self._objects if info["id"] != "null_element"]
self._objects = tuple(objs)
+ security.declarePrivate('renderElement')
+ def renderElement(self, obj):
+ """Renders one composite element.
+ """
+ o = adapt(obj, IRenderableInline)
+ text = o.renderInline()
+ return text
+
security.declareProtected(perm_names.view, "renderToList")
def renderToList(self, allow_add):
"""Renders the items to a list.
@@ -157,8 +165,7 @@
res.append(target_tag % (myid, index, mypath, index))
try:
- o = adapt(obj, IRenderableInline)
- text = o.renderInline()
+ text = self.renderElement(obj)
except ConflictError:
# Ugly ZODB requirement: don't catch ConflictErrors
raise
=== Products/CompositePage/tool.py 1.9 => 1.10 ===
--- Products/CompositePage/tool.py:1.9 Thu Feb 26 16:38:11 2004
+++ Products/CompositePage/tool.py Tue Mar 2 10:28:38 2004
@@ -79,11 +79,11 @@
uis = DesignUIs("uis")
_properties = Folder._properties + (
- {'id': 'default_inline_views', 'mode': 'w', 'type': 'lines',
- 'label': 'Default inline view names',},
+ {'id': 'default_inline_templates', 'mode': 'w', 'type': 'lines',
+ 'label': 'Default inline template names',},
)
- default_inline_views = ()
+ default_inline_templates = ()
_check_security = 1 # Turned off in unit tests
More information about the Zope-CVS
mailing list