source: products/quintagroup.pfg.captcha/branches/migration/quintagroup/pfg/captcha/setuphandlers.py @ 2711

Last change on this file since 2711 was 2711, checked in by mylan, 14 years ago

#222: Added basic structure of migration Product to Package

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1import logging
2from zope.component import queryMultiAdapter
3
4from quintagroup.canonicalpath.interfaces  import ICanonicalLink
5from quintagroup.canonicalpath.adapters import PROPERTY_LINK
6
7logger = logging.getLogger('quintagroup.pfg.captcha')
8
9def isNeedMigration(plone_tools):
10    ptypes = plone_tools.types()
11    cftype = getattr(ptypes, 'CaptchaField', None)
12    return cftype and getattr(cftype, 'product', "") == "qPloneCaptchaField"
13
14def migrateToPackage(context):
15    """ Replace old qPloneCaptchaField with new quintagroup.pfg.captcha ob.
16    """
17    if context.readDataFile('_uninstall.txt') is None:
18        return
19    site = context.getSite()
20    plone_tools = queryMultiAdapter((site, setuptool.REQUEST), name="plone_tools")
21
22    if isNeedMigration(plone_tools):
23        pass
24        ## Find old objects:
25        #for cf in catalog.search({'portal_type':'CaptchaField'}):
26        #   get parent obj, del old CaptchaField and create new one
27        # Then remove old portal type "CaptchaField"
28        # for path in plone_tools.catalog().search()
29        # recriateCaptchaFields(plone_tools)
30        # removeOldPortalType(plone_tools)
Note: See TracBrowser for help on using the repository browser.