Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
plone.app.layout.globals.context.ContextState Class Reference
Inheritance diagram for plone.app.layout.globals.context.ContextState:
Inheritance graph
[legend]
Collaboration diagram for plone.app.layout.globals.context.ContextState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def current_page_url
def current_base_url
def canonical_object
def canonical_object_url
def view_url
def view_template_id
def is_view_template
def object_url
def object_title
def workflow_state
def parent
def folder
def is_folderish
def is_structural_folder
def is_default_page
def is_portal_root
def is_editable
def is_locked
def actions
def keyed_actions
def portlet_assignable

Private Member Functions

def _lookupTypeActionTemplate

Detailed Description

Information about the state of the current context

Definition at line 26 of file context.py.


Member Function Documentation

Definition at line 216 of file context.py.

00216 
00217     def _lookupTypeActionTemplate(self, actionId):
00218         context = aq_inner(self.context)
00219         fti = context.getTypeInfo()
00220         try:
00221             # XXX: This isn't quite right since it assumes the action starts with ${object_url}
00222             action = fti.getActionInfo(actionId)['url'].split('/')[-1]
00223         except ValueError:
00224             # If the action doesn't exist, stop
00225             return None
00226 
00227         # Try resolving method aliases because we need a real template_id here
00228         action = fti.queryMethodID(action, default = action, context = context)
00229 
00230         # Strip off leading /
00231         if action and action[0] == '/':
00232             action = action[1:]
00233         return action

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 193 of file context.py.

00193 
00194     def actions(self):
00195         tool = getToolByName(self.context, "portal_actions")
00196         return tool.listFilteredActionsFor(aq_inner(self.context),
00197                                            ignore_providers=BLACKLISTED_PROVIDERS,
00198                                            ignore_categories=BLACKLISTED_CATEGORIES)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 48 of file context.py.

00048 
00049     def canonical_object(self):
00050         if self.is_default_page():
00051             return self.parent()
00052         else:
00053             return self.context
            

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file context.py.

00055 
00056     def canonical_object_url(self):
00057         return self.canonical_object().absolute_url()
            

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 41 of file context.py.

00041 
00042     def current_base_url(self):
00043         return self.request.get('ACTUAL_URL',
00044                  self.request.get('VIRTUAL_URL',
00045                    self.request.get('URL', 
00046                      self.context.absolute_url())))
                             

Here is the caller graph for this function:

Definition at line 33 of file context.py.

00033 
00034     def current_page_url(self):
00035         url = self.current_base_url()
00036         query = self.request.get('QUERY_STRING', None)
00037         if query:
00038             url += '?' + query
00039         return url
        

Here is the call graph for this function:

Definition at line 135 of file context.py.

00135 
00136     def folder(self):
00137         if self.is_structural_folder() and not self.is_default_page():
00138             return aq_inner(self.context)
00139         else:
00140             return self.parent()
    

Here is the call graph for this function:

Definition at line 160 of file context.py.

00160 
00161     def is_default_page(self):
00162         context = aq_inner(self.context)
00163         container = aq_parent(context)
00164         if not container:
00165             return False
00166         view = getMultiAdapter((container, self.request), name='default_page')
00167         return view.isDefaultPage(context)
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 176 of file context.py.

00176 
00177     def is_editable(self):
00178         tool = getToolByName(self.context, "portal_membership")
00179         return bool(tool.checkPermission('Modify portal content', aq_inner(self.context)))
    

Here is the call graph for this function:

Definition at line 142 of file context.py.

00142 
00143     def is_folderish(self):
00144         return bool(getattr(aq_base(aq_inner(self.context)), 'isPrincipiaFolderish', False))
            

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 181 of file context.py.

00181 
00182     def is_locked(self):
00183         # plone_lock_info is registered on marker interface ITTWLockable, since
00184         # not everything may want to parttake in its lock-stealing ways.
00185         lock_info = queryMultiAdapter((self.context, self.request), name='plone_lock_info')
00186         if lock_info is not None:
00187             return lock_info.is_locked_for_current_user()
00188         else:
00189             context = aq_inner(self.context)
00190             lockable = getattr(context.aq_explicit, 'wl_isLocked', None) is not None
00191             return lockable and context.wl_isLocked()

Here is the call graph for this function:

Definition at line 169 of file context.py.

00169 
00170     def is_portal_root(self):
00171         context = aq_inner(self.context)
00172         portal = getUtility(ISiteRoot)
00173         return aq_base(context) is aq_base(portal) or \
00174                 (self.is_default_page() and aq_base(self.parent()) is aq_base(portal))
    

Here is the call graph for this function:

Definition at line 146 of file context.py.

00146 
00147     def is_structural_folder(self):
00148         folderish = self.is_folderish()
00149         context = aq_inner(self.context)
00150         if not folderish:
00151             return False
00152         elif INonStructuralFolder.providedBy(context):
00153             return False
00154         elif z2INonStructuralFolder.isImplementedBy(context):
00155             # BBB: for z2 interface compat
00156             return False
00157         else:
00158             return folderish
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 95 of file context.py.

00095 
00096     def is_view_template(self):
00097         current_url = self.current_base_url()
00098         canonical_url = self.canonical_object_url()
00099         object_url = self.object_url()
00100         
00101         if current_url.endswith('/'):
00102             current_url = current_url[:-1]
00103         
00104         if current_url == canonical_url or current_url == object_url:
00105             return True
00106         elif current_url == object_url + '/view':
00107             return True
00108         
00109         template_id = self.view_template_id()
00110         if current_url == "%s/%s" % (object_url, template_id):
00111             return True
00112         elif current_url == "%s/@@%s" % (object_url, template_id):
00113             return True
00114         
00115         return False

Here is the call graph for this function:

Definition at line 200 of file context.py.

00200 
00201     def keyed_actions(self):
00202         actions = self.actions()
00203         keyed_actions = {}
00204         for category in actions.keys():
00205             keyed_actions[category] = {}
00206             for action in actions[category]:
00207                 id = action.get('id', None)
00208                 if id is not None:
00209                     keyed_actions[category][id] = action.copy()
00210         return keyed_actions
       

Here is the call graph for this function:

Definition at line 121 of file context.py.

00121 
00122     def object_title(self):
00123         context = aq_inner(self.context)
00124         return utils.pretty_title_or_id(context, context)
        

Here is the call graph for this function:

Definition at line 117 of file context.py.

00117 
00118     def object_url(self):
00119         return aq_inner(self.context).absolute_url()
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 131 of file context.py.

00131 
00132     def parent(self):
00133         return aq_parent(aq_inner(self.context))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 212 of file context.py.

00212 
00213     def portlet_assignable(self):
00214         return ILocalPortletAssignable.providedBy(self.context)
        

Here is the call graph for this function:

Definition at line 77 of file context.py.

00077 
00078     def view_template_id(self):
00079         context = aq_inner(self.context)
00080         browserDefault = IBrowserDefault(context, None)
00081         
00082         if browserDefault is not None:
00083             try:
00084                 return browserDefault.getLayout()
00085             except AttributeError:
00086                 # Might happen if FTI didn't migrate yet.
00087                 pass
00088 
00089         action = self._lookupTypeActionTemplate('object/view')
00090         if not action:
00091             action = self._lookupTypeActionTemplate('folder/folderlisting')
00092 
00093         return action

Here is the call graph for this function:

Here is the caller graph for this function:

URL to use for viewing

Files and Images get downloaded when they are directly
called, instead of with /view appended.  We want to avoid that.

Definition at line 59 of file context.py.

00059 
00060     def view_url(self):
00061         """URL to use for viewing
00062 
00063         Files and Images get downloaded when they are directly
00064         called, instead of with /view appended.  We want to avoid that.
00065         """
00066         view_url = self.object_url()
00067         portal_properties = getToolByName(self.context, 'portal_properties', None)
00068         if portal_properties is not None:
00069             site_properties = getattr(portal_properties, 'site_properties', None)
00070             portal_type = getattr(aq_base(self.context), 'portal_type', None)
00071             if site_properties is not None and portal_type is not None:
00072                 use_view_action = site_properties.getProperty('typesUseViewActionInListings', ())
00073                 if portal_type in use_view_action:
00074                     view_url = view_url + '/view'
00075         return view_url

Here is the call graph for this function:

Definition at line 126 of file context.py.

00126 
00127     def workflow_state(self):
00128         tool = getToolByName(self.context, "portal_workflow")
00129         return tool.getInfoFor(aq_inner(self.context), 'review_state', None)
    

Here is the call graph for this function:


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