Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Static Private Attributes
CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin Class Reference
Inheritance diagram for CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin:
Inheritance graph
[legend]
Collaboration diagram for CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def defaultView
def __call__
def getDefaultPage
def getLayout
def canSetDefaultPage
def setDefaultPage
def setLayout
def getDefaultLayout
def canSetLayout
def getAvailableLayouts

Static Public Attributes

dictionary aliases
string default_view = "base_view"
tuple suppl_views = ()
tuple security = ClassSecurityInfo()

Static Private Attributes

tuple __implements__ = (ZopeTwoISelectableBrowserDefault, )
 _at_fti_meta_type = fti_meta_type

Detailed Description

Mixin class for content types using the dynamic view FTI

Allow the user to select a layout template (in the same way as
TemplateMixin in Archetypes does), and/or to set a contained
object's id as a default_page (acting in the same way as index_html)

Note: folderish content types should overwrite HEAD like ATContentTypes

Definition at line 31 of file browserdefault.py.


Member Function Documentation

Resolve and return the selected view template applied to the object.
This should not consider the default page.

Definition at line 72 of file browserdefault.py.

00072 
00073     def __call__(self):
00074         """
00075         Resolve and return the selected view template applied to the object.
00076         This should not consider the default page.
00077         """
00078         template = self.unrestrictedTraverse(self.getLayout())
00079         context = aq_inner(self)
00080         template = template.__of__(context)
00081         return template(context, context.REQUEST)

Here is the call graph for this function:

Here is the caller graph for this function:

Check if the user has permission to select a default page on this
(folderish) item, and the item is folderish.

Definition at line 111 of file browserdefault.py.

00111 
00112     def canSetDefaultPage(self):
00113         """Check if the user has permission to select a default page on this
00114         (folderish) item, and the item is folderish.
00115         """
00116         if not self.isPrincipiaFolderish:
00117             return False
00118         mtool = getToolByName(self, 'portal_membership')
00119         member = mtool.getAuthenticatedMember()
00120         return member.has_permission(ModifyViewTemplate, self)

Here is the call graph for this function:

Check if the current authenticated user is permitted to select a layout.

Definition at line 198 of file browserdefault.py.

00198 
00199     def canSetLayout(self):
00200         """Check if the current authenticated user is permitted to select a layout.
00201         """
00202         mtool = getToolByName(self, 'portal_membership')
00203         member = mtool.getAuthenticatedMember()
00204         return member.has_permission(ModifyViewTemplate, self)

Here is the call graph for this function:

Get the actual view to use. If a default page is set, its id will
be returned. Else, the current layout's page template id is returned.

Definition at line 60 of file browserdefault.py.

00060 
00061     def defaultView(self, request=None):
00062         """
00063         Get the actual view to use. If a default page is set, its id will
00064         be returned. Else, the current layout's page template id is returned.
00065         """
00066         fti = self.getTypeInfo()
00067         if fti is None:
00068             return self.default_view
00069         else:
00070             return fti.defaultView(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Get the layouts registered for this object from its FTI.

Definition at line 206 of file browserdefault.py.

00206 
00207     def getAvailableLayouts(self):
00208         """Get the layouts registered for this object from its FTI.
00209         """
00210         fti = self.getTypeInfo()
00211         if fti is None:
00212             return ()
00213         result = []
00214         method_ids = fti.getAvailableViewMethods(self)
00215         for mid in method_ids:
00216             view = zope.component.queryMultiAdapter((self, self.REQUEST),
00217                                                     zope.interface.Interface,
00218                                                     name=mid)
00219 
00220             if view is not None:
00221                 menu = zope.component.getUtility(
00222                     IBrowserMenu, 'plone_displayviews')
00223                 item = menu.getMenuItemByAction(self, self.REQUEST, mid)
00224                 title = item and item.title or mid
00225                 result.append((mid, title))
00226             else:
00227                 method = getattr(self, mid, None)
00228                 if method is not None:
00229                     # a method might be a template, script or method
00230                     try:
00231                         title = method.aq_inner.aq_explicit.title_or_id()
00232                     except AttributeError:
00233                         title = mid
00234                     result.append((mid, title))
00235         return result
00236 
00237 InitializeClass(BrowserDefaultMixin)

Here is the call graph for this function:

Here is the caller graph for this function:

Get the default layout method.

Definition at line 188 of file browserdefault.py.

00188 
00189     def getDefaultLayout(self):
00190         """Get the default layout method.
00191         """
00192         fti = self.getTypeInfo()
00193         if fti is None:
00194             return "base_view" # XXX
00195         else:
00196             return fti.getDefaultViewMethod(self)

Here is the call graph for this function:

Return the id of the default page, or None if none is set.

The default page must be contained within this (folderish) item.

Definition at line 83 of file browserdefault.py.

00083 
00084     def getDefaultPage(self):
00085         """Return the id of the default page, or None if none is set.
00086 
00087         The default page must be contained within this (folderish) item.
00088         """
00089         fti = self.getTypeInfo()
00090         if fti is None:
00091             return None
00092         else:
00093             plone_utils = getToolByName(self, 'plone_utils', None)
00094             if plone_utils is not None:
00095                 return plone_utils.getDefaultPage(self)
00096             else:
00097                 return fti.getDefaultPage(self, check_exists=True)

Here is the call graph for this function:

Here is the caller graph for this function:

Get the selected view method.

Note that a selected default page will override the view method.

Definition at line 99 of file browserdefault.py.

00099 
00100     def getLayout(self, **kw):
00101         """Get the selected view method.
00102 
00103         Note that a selected default page will override the view method.
00104         """
00105         fti = self.getTypeInfo()
00106         if fti is None:
00107             return None
00108         else:
00109             return fti.getViewMethod(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Set the default page to display in this (folderish) object.

The objectId must be a value found in self.objectIds() (i.e. a contained
object). This object will be displayed as the default_page/index_html object
of this (folderish) object. This will override the current layout
template returned by getLayout(). Pass None for objectId to turn off
the default page and return to using the selected layout template.

Definition at line 122 of file browserdefault.py.

00122 
00123     def setDefaultPage(self, objectId):
00124         """Set the default page to display in this (folderish) object.
00125 
00126         The objectId must be a value found in self.objectIds() (i.e. a contained
00127         object). This object will be displayed as the default_page/index_html object
00128         of this (folderish) object. This will override the current layout
00129         template returned by getLayout(). Pass None for objectId to turn off
00130         the default page and return to using the selected layout template.
00131         """
00132         new_page = old_page = None
00133         if objectId is not None:
00134             new_page = getattr(self, objectId, None)
00135         if self.hasProperty('default_page'):
00136             pages = self.getProperty('default_page','')
00137             if isinstance(pages, (list, tuple)):
00138                 for page in pages:
00139                     old_page = getattr(self, page, None)
00140                     if page is not None: break
00141             elif isinstance(pages, str):
00142                 old_page = getattr(self, pages, None)
00143 
00144             if objectId is None:
00145                 self.manage_delProperties(['default_page'])
00146             else:
00147                 self.manage_changeProperties(default_page = objectId)
00148         else:
00149             if objectId is not None:
00150                 self.manage_addProperty('default_page', objectId, 'string')
00151         if new_page != old_page:
00152             if new_page is not None:
00153                 new_page.reindexObject(['is_default_page'])
00154             if old_page is not None:
00155                 old_page.reindexObject(['is_default_page'])

Here is the call graph for this function:

Here is the caller graph for this function:

Set the layout as the current view.

'layout' should be one of the list returned by getAvailableLayouts(), but it
is not enforced. If a default page has been set with setDefaultPage(), it is
turned off by calling setDefaultPage(None).

Definition at line 157 of file browserdefault.py.

00157 
00158     def setLayout(self, layout):
00159         """Set the layout as the current view.
00160 
00161         'layout' should be one of the list returned by getAvailableLayouts(), but it
00162         is not enforced. If a default page has been set with setDefaultPage(), it is
00163         turned off by calling setDefaultPage(None).
00164         """
00165         if not (layout and isinstance(layout, basestring)):
00166             raise ValueError, ("layout must be a non empty string, got %s(%s)" %
00167                                (layout, type(layout)))
00168 
00169         defaultPage = self.getDefaultPage()
00170         if defaultPage is None and layout == self.getLayout():
00171             return
00172 
00173         if self.hasProperty('layout'):
00174             self.manage_changeProperties(layout = layout)
00175         else:
00176             if getattr(aq_base(self), 'layout', _marker) is not _marker:
00177                 # Archetypes remains? clean up
00178                 old = self.layout
00179                 if old and not isinstance(old, basestring):
00180                     raise RuntimeError, ("layout attribute exists on %s and is"
00181                                          "no string: %s" % (self, type(old)))
00182                 delattr(self, 'layout')
00183 
00184             self.manage_addProperty('layout', layout, 'string')
00185 
00186         self.setDefaultPage(None)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin.__implements__ = (ZopeTwoISelectableBrowserDefault, ) [static, private]

Definition at line 41 of file browserdefault.py.

Definition at line 43 of file browserdefault.py.

Initial value:
{
        '(Default)'  : '(dynamic view)',
        'view'       : '(selected layout)',
        'edit'       : 'base_edit',
        'properties' : 'base_metadata',
        'sharing'    : 'folder_localrole_form',
        'gethtml'    : '',
        'mkdir'      : '',
        }

Definition at line 44 of file browserdefault.py.

Definition at line 54 of file browserdefault.py.

Definition at line 57 of file browserdefault.py.

Definition at line 55 of file browserdefault.py.


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