Пример #1
0
    def __setitem__(self, key, assignment):
        # add the assignment mapping to the object graph, if it's not there yet
        if getattr(self, '_v_context', None) is not None:
            annotations = IAnnotations(self._v_context)
            assignments = annotations.get(CONTEXT_ASSIGNMENT_KEY, None)
            if assignments is None:
                assignments = annotations[CONTEXT_ASSIGNMENT_KEY] = OOBTree()
            mapping = assignments.get(self.__manager__, None)
            if mapping is None:
                assignments[self.__manager__] = aq_base(self)
            del self._v_context

        BaseMapping.__setitem__(self, key, aq_base(assignment))
Пример #2
0
    def __setitem__(self, key, assignment):
        # add the assignment mapping to the object graph, if it's not there yet
        if getattr(self, '_v_context', None) is not None:
            annotations = IAnnotations(self._v_context)
            assignments = annotations.get(CONTEXT_ASSIGNMENT_KEY, None)
            if assignments is None:
                assignments = annotations[CONTEXT_ASSIGNMENT_KEY] = OOBTree()
            mapping = assignments.get(self.__manager__, None)
            if mapping is None:
                assignments[self.__manager__] = aq_base(self)
            del self._v_context

        BaseMapping.__setitem__(self, key, aq_base(assignment))
Пример #3
0
def localPortletAssignmentMappingAdapter(context, manager):
    """When adapting (context, manager), get an IPortletAssignmentMapping
    by finding one in the object's annotations. The container will be created
    if necessary.
    """
    if IAnnotations.providedBy(context):
        annotations = context
    else:
        annotations = queryAdapter(context, IAnnotations)
    local = annotations.get(CONTEXT_ASSIGNMENT_KEY, None)
    if local is None:
        local = annotations[CONTEXT_ASSIGNMENT_KEY] = OOBTree()
    portlets = local.get(manager.__name__, None)
    if portlets is None:
        portlets = local[manager.__name__] = PortletAssignmentMapping(
            manager=manager.__name__, category=CONTEXT_CATEGORY)
    return portlets
Пример #4
0
 def __getitem__(self, key):
     return BaseMapping.__getitem__(self, key).__of__(self)
Пример #5
0
 def __setitem__(self, key, assignment):
     BaseMapping.__setitem__(self, key, aq_base(assignment))
Пример #6
0
 def __getitem__(self, key):
     return BaseMapping.__getitem__(self, key).__of__(self)