Author: jmorliaguet Date: Tue Oct 4 21:36:45 2005 New Revision: 27938 Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/renderers/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py Log:
- simpler code: the information about the rendering context is store in the 'info' Context object Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/renderers/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/renderers/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/renderers/__init__.py Tue Oct 4 21:36:45 2005 @@ -182,6 +182,11 @@ request = info.request element = info.element + # context info + info.location = kw.get('location') + info.template = kw.get('template') + info.view = kw.get('view') + # XXX this can be cached. tmutil = getThemeManager() theme = tmutil.getThemeInContext(element) @@ -190,10 +195,7 @@ data = [] if element.isLeaf(): - location = kw.get('location') - view = kw.get('view') - template = kw.get('template') - data = element.getDisplayData(location, request, view, template) + data = element.getDisplayData(info=info) else: nodes = element.getChildNodes(info=info) # XXX avoid inserting kw arguments here Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py Tue Oct 4 21:36:45 2005 @@ -34,9 +34,9 @@ self.category = category Portlet.__init__(self, **kw) - def getDisplayData(self, location, request, view, template): + def getDisplayData(self, info): try: - menu = getMenu(self.category, location, request) + menu = getMenu(self.category, info.location, info.request) except ComponentLookupError: items = [] else: Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py Tue Oct 4 21:36:45 2005 @@ -33,8 +33,8 @@ def __init__(self, **kw): Portlet.__init__(self, **kw) - def getDisplayData(self, location, request, view, template): - url = getMultiAdapter((location, request), IAbsoluteURL) + def getDisplayData(self, info): + url = getMultiAdapter((info.location, info.request), IAbsoluteURL) items = [ Item( title=bc['name'], Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py Tue Oct 4 21:36:45 2005 @@ -57,13 +57,13 @@ markup = html_quote(e) return markup - def getDisplayData(self, location, request, view, template): + def getDisplayData(self, info): format = self.format if format in page_factories: page = page_factories[format]() - page = contained(page, location) + page = contained(page, info.location) page.setSource(self.source) - markup = self._renderPage(page, request) + markup = self._renderPage(page, info.request) else: markup = _("Page not configured.") Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py Tue Oct 4 21:36:45 2005 @@ -47,6 +47,7 @@ self.text = text Portlet.__init__(self, **kw) - def getDisplayData(self, location, request, view, template): + def getDisplayData(self, info): markup = '<p>%s</p>' % self.text return DisplayData(title=self.title, content=HTML(markup)) + Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py Tue Oct 4 21:36:45 2005 @@ -35,7 +35,7 @@ Portlet.__init__(self, **kw) self.link = '' - def getDisplayData(self, location, request, view, template): + def getDisplayData(self, info): path = '' if self.data: path = zapi.getPath(self) Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py Tue Oct 4 21:36:45 2005 @@ -37,13 +37,14 @@ def __init__(self, **kw): Portlet.__init__(self, **kw) - def getDisplayData(self, location, request, view, template): - # Get the original view + def getDisplayData(self, info): + view, template, request = info.view, info.template, info.request + if view is not None: # Switch to the macroless skin before rendering the view applySkin(request, IMacrolessSkin) # Render the view - markup = template(instance=view) + markup = info.template(instance=view) else: macro_slot_editor = zapi.queryMultiAdapter( (self, request), name='macroSlotEditor') -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins