Changeset 1850 in products for quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/setuphandlers.py
- Timestamp:
- Mar 4, 2010 9:02:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/setuphandlers.py
r1832 r1850 1 1 import logging 2 2 from Products.CMFCore.utils import getToolByName 3 from Products.CMFCore.Expression import Expression4 3 5 4 logger = logging.getLogger('quintagroup.seoptimizer') 6 FIX_PTYPES_DOMAIN = ['Document', 'File', 'News Item']7 5 8 6 def removeSkin(site, layer): … … 34 32 logger.log(logging.INFO, "Unregistered \"%s\" configlet." % conf_id) 35 33 36 def changeDomain(site):37 """ Fixes old versions bug: Change of content type's domain to 'plone'.38 """39 types_tool = getToolByName(site, 'portal_types')40 for ptype in [ptypes for ptypes in types_tool.objectValues() if ptypes.id in FIX_PTYPES_DOMAIN]:41 if ptype.i18n_domain == 'quintagroup.seoptimizer':42 ptype.i18n_domain = 'plone'43 logger.log(logging.INFO, "I18n Domain of the type \'%s\' changed to \'plone\'." % ptype.id)44 45 def changeMetatagsOrderList(site):46 """ Change format metatags order list from "metaname accessor" to "metaname".47 """48 types_tool = getToolByName(site, 'portal_types')49 pprops_tool = getToolByName(site, 'portal_properties')50 seoprops_tool = getToolByName(pprops_tool, 'seo_properties')51 mto = seoprops_tool.getProperty('metatags_order', [])52 mto_new = [line.split(' ')[0].strip() for line in mto]53 if not list(mto) == mto_new:54 logger.log(logging.INFO, "Changed format metatags order list in configlet from \"metaname accessor\" to \"metaname\".")55 seoprops_tool.manage_changeProperties(metatags_order=mto_new)56 57 def migrationActions(site):58 """ Migration actions from portal_types action to portal_actions.59 """60 types_tool = getToolByName(site, 'portal_types')61 pprops_tool = getToolByName(site, 'portal_properties')62 seoprops_tool = getToolByName(pprops_tool, 'seo_properties')63 ctws = list(seoprops_tool.getProperty('content_types_with_seoproperties', []))64 65 for ptype in types_tool.objectValues():66 idxs = [idx_act[0] for idx_act in enumerate(ptype.listActions()) if idx_act[1].id == 'seo_properties']67 if idxs:68 if ptype.id not in ctws:69 ctws.append(ptype.id)70 ptype.deleteActions(idxs)71 logger.log(logging.INFO, "Moved \"SEO Properties\" action from %s type in portal actions." % ptype.id)72 seoprops_tool.manage_changeProperties(content_types_with_seoproperties=ctws)73 74 34 def importVarious(context): 75 35 """ Do customized installation. … … 77 37 if context.readDataFile('seo_install.txt') is None: 78 38 return 79 80 def reinstall(context):81 """ Do customized reinstallation.82 """83 if context.readDataFile('seo_reinstall.txt') is None:84 return85 site = context.getSite()86 migrationActions(site)87 changeDomain(site)88 changeMetatagsOrderList(site)89 39 90 40 def uninstall(context):
Note: See TracChangeset
for help on using the changeset viewer.