Back to index

plone3  3.1.7
_base.py
Go to the documentation of this file.
00001 from zope.interface import Interface
00002 
00003 from Products.CMFCore.interfaces import ITypeInformation
00004 
00005 class IDynamicViewTypeInformation(ITypeInformation):
00006     """Interface for FTI with dynamic views
00007 
00008     A value of (dynamic view) as alias is replaced by the output of getLayout()
00009     """
00010 
00011     def getAvailableViewMethods(context):
00012         """Get a list of registered view methods
00013         """
00014 
00015     def getViewMethod(context, enforce_available = True):
00016         """Get view method name from context
00017 
00018         Return -- view method from context or default view name
00019         """
00020 
00021     def getDefaultViewMethod(context):
00022         """Get the default view method from the FTI
00023         """
00024 
00025     def getDefaultPage(context, check_exists=False):
00026         """Get the default page from a folderish object
00027 
00028         Non folderish objects don't have a default view.
00029 
00030         If check_exists is enabled the method makes sure the object with the default
00031         page id exists.
00032 
00033         Return -- None for no default page or a string
00034         """
00035 
00036     def defaultView(context):
00037         """Get the layout for an object
00038 
00039         At first it tries to get the default page from the context. A default page
00040         must be listed on the folder or else it is ignored.
00041 
00042         At last it get the view method.
00043 
00044         Return -- a string containing the name of the layout
00045         """
00046 
00047 class IBrowserDefault(Interface):
00048     """Content supporting different views on a per-instance basis.
00049     
00050     This can be either as a page template (a layout), or as the id of a 
00051     contained object (aka a default page, set inside a folderish item only).
00052     """
00053 
00054     def defaultView(request=None):
00055         """Get the actual view to use. 
00056         
00057         If a default page is set, its id will
00058         be returned. Else, the current layout's page template id is returned.
00059         """
00060 
00061     def __call__():
00062         """Resolve and return the selected view template applied to the object.
00063         
00064         This should not consider any default page set.
00065         """
00066 
00067     def getDefaultPage():
00068         """Return the id of the default page, or None if none is set. 
00069         
00070         The default page must be contained within this (folderish) item.
00071         """
00072 
00073     def getLayout(**kw):
00074         """Get the selected layout template. 
00075         
00076         Note that a selected default page will override the layout template.
00077         """
00078 
00079     def getDefaultLayout():
00080         """Get the default layout template.
00081         """
00082 
00083 
00084 class ISelectableBrowserDefault(IBrowserDefault):
00085     """Content supporting operations to explicitly set the default layout 
00086     template or default page object.
00087     """
00088 
00089     def canSetDefaultPage():
00090         """Can a default page be set?
00091         
00092         Return True if the user has permission to select a default page on this
00093         (folderish) item, and the item is folderish.
00094         """
00095 
00096     def setDefaultPage(objectId):
00097         """Set the default page to display in this (folderish) object. 
00098         
00099         The objectId must be a value found in self.objectIds() (i.e. a contained 
00100         object). This object will be displayed as the default_page/index_html 
00101         object of this (folderish) object. This will override the current layout
00102         template returned by getLayout(). Pass None for objectId to turn off
00103         the default page and return to using the selected layout template.
00104         """
00105 
00106     def canSetLayout():
00107         """Return True if the current authenticated user is permitted to select
00108         a layout.
00109         """
00110 
00111     def setLayout(layout):
00112         """Set the layout as the current view. 
00113         
00114         'layout' should be one of the list returned by getAvailableLayouts(). 
00115         If a default page has been set with setDefaultPage(), it is turned off 
00116         by calling setDefaultPage(None).
00117         """
00118 
00119     def getAvailableLayouts():
00120         """Get the layouts registered for this object.
00121 
00122         This should return a list of tuples: (id, title), where id is the id
00123         of the page template providing the layout and title is the title of
00124         that page template as it will be displayed to the user.
00125         """