Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
plone.app.portlets.portletcontext.ContentContext Class Reference
Inheritance diagram for plone.app.portlets.portletcontext.ContentContext:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def uid
def getParent
def globalPortletCategories

Public Attributes

 context

Private Member Functions

def _getUserId
def _getGroupIds
def _getContentType

Detailed Description

A portlet context for regular content items.

Note - we register this for Interface so that it can also work for
tools and other non-content items. This may hijack the context in non-CMF
contexts, but that is doubtfully going to be an issue.

Definition at line 16 of file portletcontext.py.


Constructor & Destructor Documentation

Reimplemented in plone.app.portlets.portletcontext.PortalRootContext.

Definition at line 26 of file portletcontext.py.

00026 
00027     def __init__(self, context):
00028         self.context = context

Here is the caller graph for this function:


Member Function Documentation

Definition at line 92 of file portletcontext.py.

00092 
00093     def _getContentType(self):
00094         typeInfo = getattr(aq_base(self.context), 'getTypeInfo', None)
00095         if typeInfo is not None:
00096             fti = typeInfo()
00097             if fti is not None:
00098                 return fti.getId()
00099         portal_type = getattr(aq_base(self.context), 'portal_type', None)
00100         if portal_type is not None:
00101             return portal_type
00102         return None

Here is the caller graph for this function:

Definition at line 72 of file portletcontext.py.

00072 
00073     def _getGroupIds(self):
00074         membership = getToolByName(self.context, 'portal_membership', None)
00075         if membership is None or membership.isAnonymousUser():
00076             return ()
00077 
00078         member = membership.getAuthenticatedMember()
00079         if not member:
00080             return ()
00081 
00082         groups = member.getGroups()
00083 
00084         # Ensure we get the list of ids - getGroups() suffers some acquision
00085         # ambiguity - the Plone member-data version returns ids.
00086 
00087         for group in groups:
00088             if type(group) not in StringTypes:
00089                 return ()
00090 
00091         return sorted(groups)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 49 of file portletcontext.py.

00049 
00050     def _getUserId(self):
00051         membership = getToolByName(self.context, 'portal_membership', None)
00052         if membership is None:
00053             return None
00054         
00055         member = membership.getAuthenticatedMember()
00056         if not member:
00057             return None
00058 
00059         memberId = member.getId()
00060         if memberId is None:
00061             # Basic users such as the special Anonymous users have no
00062             # id, but we can use their username instead.
00063             try:
00064                 memberId = member.getUserName()
00065             except AttributeError:
00066                 pass
00067 
00068         if not memberId:
00069             return None
00070 
00071         return memberId

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in plone.app.portlets.portletcontext.PortalRootContext.

Definition at line 33 of file portletcontext.py.

00033 
00034     def getParent(self):
00035         return aq_parent(aq_inner(self.context))

Definition at line 36 of file portletcontext.py.

00036 
00037     def globalPortletCategories(self, placeless=False):
00038         cats = []
00039         if not placeless:
00040             pt = self._getContentType()
00041             if pt is not None:
00042                 cats.append((CONTENT_TYPE_CATEGORY, pt,))
00043         u = self._getUserId()
00044         if u is not None:
00045             cats.append((USER_CATEGORY, u,))
00046         for g in self._getGroupIds():
00047             cats.append((GROUP_CATEGORY, g,))
00048         return cats

Here is the call graph for this function:

Definition at line 30 of file portletcontext.py.

00030 
00031     def uid(self):
00032         return '/'.join(self.context.getPhysicalPath())


Member Data Documentation

Reimplemented in plone.app.portlets.portletcontext.PortalRootContext.

Definition at line 27 of file portletcontext.py.


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