Back to index

plone3  3.1.7
Functions | Variables
plone.app.portlets.utils Namespace Reference

Functions

def assignment_mapping_from_key
def assignment_from_key
def convert_legacy_portlets

Variables

tuple DONT_MIGRATE = object()
dictionary portletsMapping

Function Documentation

def plone.app.portlets.utils.assignment_from_key (   context,
  manager_name,
  category,
  key,
  name 
)
Given the name of a portlet manager, the name of a category, a
key in that category and the name of a particular assignment, return
the IPortletAssignment. Raise a KeyError if it cannot be found.

Definition at line 52 of file utils.py.

00052 
00053 def assignment_from_key(context, manager_name, category, key, name):
00054     """Given the name of a portlet manager, the name of a category, a
00055     key in that category and the name of a particular assignment, return
00056     the IPortletAssignment. Raise a KeyError if it cannot be found.
00057     """
00058     return assignment_mapping_from_key(context, manager_name, category, key)[name]

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.portlets.utils.assignment_mapping_from_key (   context,
  manager_name,
  category,
  key,
  create = False 
)
Given the name of a portlet manager, the name of a category, and a
key in that category, return the IPortletAssignmentMapping. 
Raise a KeyError if it cannot be found.

Definition at line 26 of file utils.py.

00026 
00027 def assignment_mapping_from_key(context, manager_name, category, key, create=False):
00028     """Given the name of a portlet manager, the name of a category, and a
00029     key in that category, return the IPortletAssignmentMapping. 
00030     Raise a KeyError if it cannot be found.
00031     """
00032     
00033     manager = getUtility(IPortletManager, manager_name)
00034     
00035     if category == CONTEXT_CATEGORY:
00036         path = key
00037         portal = getToolByName(context, 'portal_url').getPortalObject()
00038         portal_path = '/'.join(portal.getPhysicalPath())
00039         path = path[len(portal_path)+1:]
00040         obj = portal.restrictedTraverse(path, None)
00041         if obj is None:
00042             raise KeyError, "Cannot find object at path %s" % path
00043         return getMultiAdapter((obj, manager), IPortletAssignmentMapping)
00044     else:
00045         mapping = manager[category]
00046         if key not in mapping and create:
00047             if category == USER_CATEGORY:
00048                 mapping[key] = UserPortletAssignmentMapping()
00049             else:
00050                 mapping[key] = PortletAssignmentMapping()
00051         return mapping[key]

Here is the call graph for this function:

Here is the caller graph for this function:

Convert legacy portlets (left_slots, right_slots) in the given
context to new-style portlets.

Definition at line 72 of file utils.py.

00072 
00073 def convert_legacy_portlets(context):
00074     """Convert legacy portlets (left_slots, right_slots) in the given
00075     context to new-style portlets.
00076     """
00077         
00078     # Convert left_slots and right_slots to portlets
00079     
00080     left = getUtility(IPortletManager, name='plone.leftcolumn')
00081     right = getUtility(IPortletManager, name='plone.rightcolumn')
00082     
00083     leftAssignable = getMultiAdapter((context, left), IPortletAssignmentMapping).__of__(context)
00084     rightAssignable = getMultiAdapter((context, right), IPortletAssignmentMapping).__of__(context)
00085     
00086     IPortletPermissionChecker(leftAssignable)()
00087     IPortletPermissionChecker(rightAssignable)()
00088     
00089     leftChooser = INameChooser(leftAssignable)
00090     rightChooser = INameChooser(rightAssignable)
00091     
00092     left_slots = getattr(aq_base(context), 'left_slots', [])
00093     right_slots = getattr(aq_base(context), 'right_slots', [])
00094             
00095     for item in left_slots:
00096         path = item.split('/')
00097         if len(path) == 4:
00098             newPortlet = portletsMapping.get(path[1], None)
00099             if newPortlet is None and path[0] in ('context', 'here',) and path[2] == 'macros':
00100                 newPortlet = classic.Assignment(path[1], path[3])
00101             if newPortlet is not None and newPortlet is not DONT_MIGRATE:
00102                 leftAssignable[leftChooser.chooseName(None, newPortlet)] = newPortlet
00103                 
00104     for item in right_slots:
00105         path = item.split('/')
00106         if len(path) == 4:
00107             newPortlet = portletsMapping.get(path[1], None)
00108             if newPortlet is None and path[0] in ('context', 'here',) and path[2] == 'macros':
00109                 newPortlet = classic.Assignment(path[1], path[3])
00110             if newPortlet is not None and newPortlet is not DONT_MIGRATE:
00111                 rightAssignable[rightChooser.chooseName(None, newPortlet)] = newPortlet
00112 
00113     context.left_slots = []
00114     context.right_slots = []

Here is the caller graph for this function:


Variable Documentation

Definition at line 59 of file utils.py.

Initial value:
00001 { 'portlet_login'      : login.Assignment(),
00002                     'portlet_news'       : news.Assignment(count=5),
00003                     'portlet_events'     : events.Assignment(count=5),
00004                     'portlet_navigation' : navigation.Assignment(),
00005                     'portlet_calendar'   : calendar.Assignment(),
00006                     'portlet_review'     : review.Assignment(),
00007                     'portlet_recent'     : recent.Assignment(count=5),
00008                     'portlet_related'    : DONT_MIGRATE,
00009                     'portlet_languages'  : DONT_MIGRATE,
00010                   }

Definition at line 61 of file utils.py.