Changeset 1584 in products
- Timestamp:
- Jan 25, 2010 3:52:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/portlets.py
r1576 r1584 12 12 13 13 from plone.portlets.interfaces import ILocalPortletAssignable, IPortletManager,\ 14 IPortletAssignmentMapping, IPortletAssignment, ILocalPortletAssignmentManager 15 from plone.portlets.constants import USER_CATEGORY, GROUP_CATEGORY, \ 16 CONTENT_TYPE_CATEGORY, CONTEXT_CATEGORY 14 IPortletAssignmentMapping, IPortletAssignment 15 from plone.portlets.constants import CONTEXT_CATEGORY 17 16 from plone.app.portlets.interfaces import IPortletTypeInterface 18 17 from plone.app.portlets.exportimport.interfaces import IPortletAssignmentExportImportHandler … … 59 58 for elem in self.exportAssignments(obj): 60 59 root.appendChild(elem) 61 for elem in self.exportBlacklists(obj):62 root.appendChild(elem)60 #for elem in self.exportBlacklists(obj) 61 #root.appendChild(elem) 63 62 if root.hasChildNodes(): 64 63 self.doc.appendChild(root) … … 78 77 for manager_name, manager in self.portlet_managers: 79 78 mapping = queryMultiAdapter((obj, manager), IPortletAssignmentMapping) 79 if mapping is None: 80 continue 81 80 82 mapping = mapping.__of__(obj) 81 83 … … 104 106 return assignments 105 107 106 def exportBlacklists(self, obj):107 assignments = []108 for manager_name, manager in self.portlet_managers:109 assignable = queryMultiAdapter((obj, manager), ILocalPortletAssignmentManager)110 if assignable is None:111 continue112 for category in (USER_CATEGORY, GROUP_CATEGORY, CONTENT_TYPE_CATEGORY, CONTEXT_CATEGORY,):113 child = self.doc.createElement('blacklist')114 child.setAttribute('manager', manager_name)115 child.setAttribute('category', category)116 117 status = assignable.getBlacklistStatus(category)118 if status == True:119 child.setAttribute('status', u'block')120 elif status == False:121 child.setAttribute('status', u'show')122 else:123 child.setAttribute('status', u'acquire')124 125 assignments.append(child)126 127 return assignments128 129 130 108 class PortletsImporterSection(object): 131 109 classProvides(ISectionBlueprint) … … 138 116 self.pathkey = defaultMatcher(options, 'path-key', name, 'path') 139 117 self.fileskey = defaultMatcher(options, 'files-key', name, 'files') 140 self.purge = options.get('purge', 'false').strip().lower() == 'true' and True or False141 118 142 119 def __iter__(self): … … 155 132 if obj is None: # path doesn't exist 156 133 yield item; continue 157 158 # Purge assignments if 'purge' option set to true159 if self.purge:160 for name, portletManager in getUtilitiesFor(IPortletManager):161 assignable = queryMultiAdapter((obj, portletManager), IPortletAssignmentMapping)162 if assignable is not None:163 for key in list(assignable.keys()):164 del assignable[key]165 134 166 135 if ILocalPortletAssignable.providedBy(obj): … … 172 141 if elem.nodeName == 'assignment': 173 142 self.importAssignment(obj, elem) 174 elif elem.nodeName == 'blacklist':175 self.importBlacklist(obj, elem)143 #elif elem.nodeName == 'blacklist': 144 #self.importBlacklist(obj, elem) 176 145 177 146 yield item … … 186 155 manager = getUtility(IPortletManager, manager_name) 187 156 mapping = getMultiAdapter((obj, manager), IPortletAssignmentMapping) 157 if mapping is None: 158 return 188 159 189 160 # 2. Either find or create the assignment … … 212 183 assignment_handler = IPortletAssignmentExportImportHandler(assignment) 213 184 assignment_handler.import_assignment(portlet_interface, node) 214 215 def importBlacklist(self, obj, node):216 """ Import a blacklist from a node217 """218 manager = node.getAttribute('manager')219 category = node.getAttribute('category')220 status = node.getAttribute('status')221 222 manager = getUtility(IPortletManager, name=manager)223 224 assignable = queryMultiAdapter((obj, manager), ILocalPortletAssignmentManager)225 226 if status.lower() == 'block':227 assignable.setBlacklistStatus(category, True)228 elif status.lower() == 'show':229 assignable.setBlacklistStatus(category, False)230 elif status.lower() == 'acquire':231 assignable.setBlacklistStatus(category, None)232 233 185 234 186 logger = logging.getLogger('quintagroup.transmogrifier.portletsimporter')
Note: See TracChangeset
for help on using the changeset viewer.