def get_portlet_blacklist_xml(context, prefix): return_value = False doc = PrettyDocument() node = doc.createElement('portlets') key = '/'.join(context.getPhysicalPath()) if key.startswith(prefix): key = key[len(prefix):] key = key or '/' for manager_name, manager in getUtilitiesFor(IPortletManager): assignable = queryMultiAdapter((context, manager), ILocalPortletAssignmentManager) if assignable is None: continue for category in (USER_CATEGORY, GROUP_CATEGORY, CONTENT_TYPE_CATEGORY, CONTEXT_CATEGORY): # noqa child = doc.createElement('blacklist') child.setAttribute('manager', manager_name) child.setAttribute('category', category) child.setAttribute('location', key) status = assignable.getBlacklistStatus(category) if status: child.setAttribute('status', u'block') return_value = True elif not status: child.setAttribute('status', u'show') return_value = True else: child.setAttribute('status', u'acquire') node.appendChild(child) doc.appendChild(node) xml = doc.toprettyxml(' ') doc.unlink() if return_value: yield xml
def get_portlet_assignment_xml(context, prefix): doc = PrettyDocument() node = doc.createElement('portlets') for manager_name, manager in getUtilitiesFor(IPortletManager): mapping = queryMultiAdapter((context, manager), IPortletAssignmentMapping) if mapping is None: continue mapping = mapping.__of__(context) key = '/'.join(context.getPhysicalPath()) if key.startswith(prefix): key = key[len(prefix):] key = key or '/' extract_mapping(doc, node, manager_name, CONTEXT_CATEGORY, key, mapping) doc.appendChild(node) xml = patch_portlets_xml(doc.toprettyxml(' '), prefix) doc.unlink() return xml