Back to index

plone3  3.1.7
Public Member Functions
five.customerize.browser.CustomizationView Class Reference
Inheritance diagram for five.customerize.browser.CustomizationView:
Inheritance graph
[legend]
Collaboration diagram for five.customerize.browser.CustomizationView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def templateViewRegistrations
def templateViewRegInfo
def viewClassFromViewName
def templateFromViewName
def templateCodeFromViewName
def permissionFromViewName
def doCustomizeTemplate
def customizeTemplate

Detailed Description

Definition at line 64 of file browser.py.


Member Function Documentation

Definition at line 155 of file browser.py.

00155 
00156     def customizeTemplate(self, viewname):
00157         viewzpt = self.doCustomizeTemplate(viewname)
00158         # to get a "direct" URL we use aq_inner for a straight
00159         # acquisition chain
00160         url = absoluteURL(aq_inner(viewzpt), self.request) + "/manage_workspace"
00161         self.request.response.redirect(url)

Here is the call graph for this function:

Definition at line 118 of file browser.py.

00118 
00119     def doCustomizeTemplate(self, viewname):
00120         # find the nearest site
00121         site = findSite(self.context, IObjectManagerSite)
00122         if site is None:
00123             raise TypeError("No site found")  # TODO find right exception
00124 
00125         # we're using the original filename of the template, not the
00126         # view name to avoid potential conflicts and/or confusion in
00127         # URLs
00128         template = self.templateFromViewName(viewname)
00129         zpt_id = basename(template.filename)
00130 
00131         template_file = self.templateCodeFromViewName(viewname)
00132         viewclass = self.viewClassFromViewName(viewname)
00133         permission = self.permissionFromViewName(viewname)
00134         viewzpt = TTWViewTemplate(zpt_id, template_file, view=viewclass,
00135                                   permission=permission)
00136         container = queryUtility(IViewTemplateContainer)
00137         if container is not None:
00138             viewzpt = container.addTemplate(zpt_id, viewzpt)
00139         else:
00140             site._setObject(zpt_id, viewzpt) #XXXthere could be a naming conflict
00141             viewzpt = getattr(site, zpt_id)
00142 
00143         # find out the view registration object so we can get at the
00144         # provided and required interfaces
00145         for reg in getViews(providedBy(self.context), IBrowserRequest):
00146             if reg.name == viewname:
00147                 break
00148 
00149         components = site.getSiteManager()
00150         components.registerAdapter(viewzpt, required=reg.required,
00151                                    provided=reg.provided, name=viewname
00152                                    ) #XXX info?
00153 
00154         return viewzpt

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file browser.py.

00111 
00112     def permissionFromViewName(self, viewname):
00113         view = getMultiAdapter((self.context, self.request), name=viewname)
00114         permissions = view.__class__.__ac_permissions__
00115         for permission, methods in permissions:
00116             if methods[0] in ('', '__call__'):
00117                 return permission

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 105 of file browser.py.

00105 
00106     def templateCodeFromViewName(self, viewname):
00107         template = self.templateFromViewName(viewname)
00108         #XXX: we can't do template.read() here because of a bug in
00109         # Zope 3's ZPT implementation.
00110         return open(template.filename, 'rb').read()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file browser.py.

00101 
00102     def templateFromViewName(self, viewname):
00103         view = getMultiAdapter((self.context, self.request), name=viewname)
00104         return view.index

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 77 of file browser.py.

00077 
00078     def templateViewRegInfo(self):
00079         def regkey(reg):
00080             return reg.name
00081         for reg in sorted(self.templateViewRegistrations(), key=regkey):
00082             yield {
00083                 'viewname': reg.name,
00084                 'for': reg.required[0].__identifier__,
00085                 'type': reg.required[1].__identifier__,
00086                 'zptfile': mangleAbsoluteFilename(reg.factory.index.filename),
00087                 'zcmlfile': mangleAbsoluteFilename(reg.info.file)
00088                 }

Here is the call graph for this function:

Definition at line 66 of file browser.py.

00066 
00067     def templateViewRegistrations(self):
00068         for reg in getViews(providedBy(self.context), IBrowserRequest):
00069             factory = reg.factory
00070             while hasattr(factory, 'factory'):
00071                 factory = factory.factory
00072             #XXX this should really be dealt with using a marker interface
00073             # on the view factory
00074             if hasattr(factory, '__name__') and \
00075                    factory.__name__.startswith('SimpleViewClass'):
00076                 yield reg

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 89 of file browser.py.

00089 
00090     def viewClassFromViewName(self, viewname):
00091         view = getMultiAdapter((self.context, self.request), name=viewname)
00092         # The view class is generally auto-generated, we usually want
00093         # the first base class, though if the view only has one base
00094         # (generally object or BrowserView) we return the full class
00095         # and hope that it can be pickled
00096         klass = view.__class__
00097         base = klass.__bases__[0]
00098         if base is BrowserView or base is object:
00099             return klass
00100         return base

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: