def extractMapping(manager_name, category, key, mapping): for name, assignment in mapping.items(): type_ = None for schema in providedBy(assignment).flattened(): type_ = portletSchemata.get(schema, None) if type_ is not None: break if type_ is not None: child = self._doc.createElement('assignment') child.setAttribute('manager', manager_name) child.setAttribute('category', category) child.setAttribute('key', key) child.setAttribute('type', type_) child.setAttribute('name', name) assignment = assignment.__of__(mapping) settings = IPortletAssignmentSettings(assignment) visible = settings.get('visible', True) child.setAttribute('visible', repr(visible)) handler = IPortletAssignmentExportImportHandler(assignment) handler.export_assignment(schema, self._doc, child) fragment.appendChild(child)
def extractMapping(manager_name, category, key, mapping): for name, assignment in mapping.items(): type_ = None for schema in providedBy(assignment).flattened(): type_ = portletSchemata.get(schema, None) if type_ is not None: break if type_ is not None: child = self._doc.createElement('assignment') child.setAttribute('manager', manager_name) child.setAttribute('category', category) child.setAttribute('key', key) child.setAttribute('type', type_) child.setAttribute('name', name) assignment = assignment.__of__(mapping) settings = IPortletAssignmentSettings(assignment) visible = settings.get('visible', True) child.setAttribute('visible', repr(visible)) handler = IPortletAssignmentExportImportHandler(assignment) handler.export_assignment(schema, self._doc, child) fragment.appendChild(child)
def exportAssignments(self, obj): assignments = [] for manager_name, manager in self.portlet_managers: mapping = queryMultiAdapter((obj, manager), IPortletAssignmentMapping) if mapping is None: continue mapping = mapping.__of__(obj) for name, assignment in mapping.items(): type_ = None for schema in providedBy(assignment).flattened(): type_ = self.portlet_schemata.get(schema, None) if type_ is not None: break if type_ is not None: child = self.doc.createElement('assignment') child.setAttribute('manager', manager_name) child.setAttribute('category', CONTEXT_CATEGORY) child.setAttribute('key', '/'.join(obj.getPhysicalPath())) child.setAttribute('type', type_) child.setAttribute('name', name) assignment = assignment.__of__(mapping) # use existing adapter for exporting a portlet assignment handler = IPortletAssignmentExportImportHandler(assignment) handler.export_assignment(schema, self.doc, child) assignments.append(child) return assignments
def exportAssignments(self, obj): assignments = [] for manager_name, manager in self.portlet_managers: mapping = queryMultiAdapter((obj, manager), IPortletAssignmentMapping) if mapping is None: continue mapping = mapping.__of__(obj) for name, assignment in mapping.items(): type_ = None for schema in providedBy(assignment).flattened(): type_ = self.portlet_schemata.get(schema, None) if type_ is not None: break if type_ is not None: child = self.doc.createElement('assignment') child.setAttribute('manager', manager_name) child.setAttribute('category', CONTEXT_CATEGORY) child.setAttribute('key', '/'.join(obj.getPhysicalPath())) child.setAttribute('type', type_) child.setAttribute('name', name) assignment = assignment.__of__(mapping) # use existing adapter for exporting a portlet assignment handler = IPortletAssignmentExportImportHandler(assignment) handler.export_assignment(schema, self.doc, child) assignments.append(child) return assignments
def extract_mapping(manager_name, category, key, mapping): portlets_schemata = dict([ (iface, name) for name, iface in getUtilitiesFor(IPortletTypeInterface) ]) for name, assignment in mapping.items(): type_ = None schema = None for schema in providedBy(assignment).flattened(): type_ = portlets_schemata.get(schema, None) if type_ is not None: break if type_ is not None: child = PrettyDocument().createElement('assignment') child.setAttribute('manager', manager_name) child.setAttribute('category', category) child.setAttribute('key', key) child.setAttribute('type', type_) child.setAttribute('name', name) assignment = assignment.__of__(mapping) settings = IPortletAssignmentSettings(assignment) visible = settings.get('visible', True) child.setAttribute('visible', repr(visible)) handler = IPortletAssignmentExportImportHandler(assignment) handler.export_assignment(schema, PrettyDocument(), child) yield child