當前位置: 首頁>>代碼示例>>Python>>正文


Python walker.CustomQueryWalker類代碼示例

本文整理匯總了Python中Products.contentmigration.walker.CustomQueryWalker的典型用法代碼示例。如果您正苦於以下問題:Python CustomQueryWalker類的具體用法?Python CustomQueryWalker怎麽用?Python CustomQueryWalker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CustomQueryWalker類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: migrate

def migrate(context):
    # switch linkintegrity temp off
    ptool = queryUtility(IPropertiesTool)
    site_props = getattr(ptool, 'site_properties', None)
    linkintegrity = site_props.getProperty(
        'enable_link_integrity_checks',
        False
    )
    site_props.manage_changeProperties(enable_link_integrity_checks=False)

    # do migration
    portal = getToolByName(context, 'portal_url').getPortalObject()
    walker = CustomQueryWalker(
        portal, PloneArticleMigrator,
        query=dict(object_provides=IPloneArticle.__identifier__),
        callBefore=callBefore)
    savepoint(optimistic=True)
    walker.go()

    # switch linkintegrity back
    site_props.manage_changeProperties(
        enable_link_integrity_checks=linkintegrity
    )

    return walker.getOutput()
開發者ID:collective,項目名稱:collective.folderishtypes,代碼行數:25,代碼來源:migrate_plonearticle.py

示例2: migrate_fileTestCgwb_to_blob

 def migrate_fileTestCgwb_to_blob(self):
     upgrades.log('Migrating FileTestCgwb to blob')
     walker = CustomQueryWalker(
         self.context,
         FileTestCgwbMigrator,
         full_transaction=True)
     walker.go()
     upgrades.commit(self.context)
開發者ID:makinacorpus,項目名稱:cgwb-test,代碼行數:8,代碼來源:migrate.py

示例3: migrate_fileVirtualcollections_to_blob

 def migrate_fileVirtualcollections_to_blob(self):
     upgrades.log('Migrating FileVirtualcollections to blob')
     walker = CustomQueryWalker(
         self.context,
         FileVirtualcollectionsMigrator,
         full_transaction=True)
     walker.go()
     upgrades.commit(self.context)
開發者ID:RBINS,項目名稱:virtualcollections,代碼行數:8,代碼來源:migrate.py

示例4: to_blob_f

 def to_blob_f(self):
     """To avoir conflicts during the plonemigration loop, run the blob migration now"""
     portal = getToolByName(self.context, 'portal_url').getPortalObject()
     migrator = FMigrator
     walker = CustomQueryWalker(portal, migrator, full_transaction=True)
     upgrades.log('Migrating files to blob')
     walker.go()
     upgrades.commit(self.context)
開發者ID:AntoineVe,項目名稱:ibwt.plonesite,代碼行數:8,代碼來源:migrate.py

示例5: migrate_filePhenologyPlone_to_blob

 def migrate_filePhenologyPlone_to_blob(self):
     upgrades.log('Migrating FilePhenologyPlone to blob')
     walker = CustomQueryWalker(
         self.context,
         FilePhenologyPloneMigrator,
         full_transaction=True)
     walker.go()
     upgrades.commit(self.context)
開發者ID:makinacorpus,項目名稱:phenology.plone,代碼行數:8,代碼來源:migrate.py

示例6: upgrade_step_1

def upgrade_step_1(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    walker = CustomQueryWalker(
        portal, PAEATMigrator,
        query=dict(object_provides=IATEvent.__identifier__),
        callBefore=callBefore)
    savepoint(optimistic=True)
    walker.go()
    return walker.getOutput()
開發者ID:senner,項目名稱:plone.app.event,代碼行數:9,代碼來源:event.py

示例7: execute

 def execute(self, query, actions, callBefore=None, **kwargs):
     TestMigrator.fieldActions = actions
     walker = CustomQueryWalker(self.portal, TestMigrator,
                                 query = query,
                                 callBefore = callBefore,
                                 **kwargs)
     # Need this to avoid copy errors....
     transaction.savepoint(optimistic=True)
     walker.go(**kwargs)
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:9,代碼來源:cmtc.py

示例8: migrate

def migrate(context, portal_type=None, meta_type=None, walker=None):
    """ migrate instances using the given walker """
    if walker is None:
        migrator = makeMigrator(context, portal_type, meta_type)
        walker = CustomQueryWalker(context, migrator, full_transaction=True)
    else:
        walker = walker(context)
    savepoint(optimistic=True)
    walker.go()
    return walker.getOutput()
開發者ID:tomgross,項目名稱:plone.app.blob,代碼行數:10,代碼來源:migrations.py

示例9: __call__

 def __call__(self):
     res = 'State before:\n' + self.stats() + '\n'
     portal = self.context
     for migrator in [ATBlobFileToAWSFileMigrator, ATBlobImageToAWSImageMigrator]:
         max_size = self.request.get('max_size')
         def callBefore(obj, **kwargs):
             return obj.get_size() < int(max_size) if max_size else True
         walker = CustomQueryWalker(portal, migrator, callBefore=callBefore, use_savepoint=True)
         if self.request.get('limit'):
             walker.limit = int(self.request.get('limit'))
         transaction.savepoint(optimistic=True)
         walker.go()
         res += walker.getOutput()
     res += 'State after:\n' + self.stats() + '\n'
     portal.plone_log(res)
     return res
開發者ID:quintagroup,項目名稱:collective.contentfiles2aws,代碼行數:16,代碼來源:content_migration.py

示例10: migrate

def migrate(self):
    out = StringIO()
    print >> out, "Starting ratings migration"

    portal_url = getToolByName(self, 'portal_url')
    portal = portal_url.getPortalObject()

    # Migrate release count variable
    walker = CustomQueryWalker(portal, RatingsMigrator,
                               query = {'portal_type': 'PSCProject'})
    transaction.savepoint(optimistic=True)
    print >> out, "Switching from contentratings to twothumbs.."
    walker.go(out=out)
    print >> out, walker.getOutput()

    print >> out, "Migration finished"
開發者ID:Conectivo,項目名稱:Products.PloneSoftwareCenter,代碼行數:16,代碼來源:migrateratings.py

示例11: migrateContents

def migrateContents(context, src_type, dst_type, src_metatype, dst_metatype, query={}):
    from Products.contentmigration.walker import CustomQueryWalker
    #BBB: i can't find a better way to know if a given portal_type is folderish or not
    is_folderish = False
    temp_obj = context.restrictedTraverse('portal_factory/%s/tmp_id' % src_type)
    if temp_obj:
        plone_view = temp_obj.restrictedTraverse('@@plone')
        if plone_view.isStructuralFolder():
            is_folderish = True
    portal_types = context.portal_types
    src_infos = portal_types.getTypeInfo(src_type)
    dst_infos = portal_types.getTypeInfo(dst_type)
    if is_folderish:
        migrator = makeFolderMigrator(context,
                                     src_type,
                                     dst_type,
                                     src_metatype,
                                     dst_metatype)
    else:
        migrator = makeContentMigrator(context,
                                      src_type,
                                      dst_type,
                                      src_metatype,
                                      dst_metatype)
    if migrator:
        if not src_metatype:
            src_metatype = src_infos.content_meta_type
        if not dst_metatype:
            dst_metatype = dst_infos.content_meta_type
        migrator.src_meta_type = src_metatype
        migrator.dst_meta_type = dst_metatype
        walker = CustomQueryWalker(context, migrator,
                                  src_portal_type=src_type,
                                  dst_portal_type=dst_type,
                                  src_meta_type=src_metatype,
                                  dst_meta_type=dst_metatype,
                                  query=query,
                                  use_savepoint=True)
        walker.go()
        walk_infos = {'error': walker.errors,
                      'msg': walker.getOutput().splitlines(),
                      'counter': walker.counter}
        return walk_infos
開發者ID:RedTurtle,項目名稱:rt.atmigrator,代碼行數:43,代碼來源:migrator.py

示例12: migrateFlowplayerToRedTurtleVideo

def migrateFlowplayerToRedTurtleVideo(context):
    from Products.contentmigration.walker import CustomQueryWalker
    migrator = makeMigrator(context, 'ATFile')
    walker = CustomQueryWalker(context, migrator, use_savepoint=True,
                               query={'object_provides': IVideo.__identifier__})
    walker.go()
    output = walker.getOutput()
    migrator = makeMigrator(context, 'ATBlob')
    walker = CustomQueryWalker(context, migrator, use_savepoint=True,
                               query={'object_provides': IVideo.__identifier__})
    walker.go()
    output += walker.getOutput()
    return output.splitlines()
開發者ID:RedTurtle,項目名稱:redturtle.video,代碼行數:13,代碼來源:migrator.py

示例13: from_1_1_to_1_2

def from_1_1_to_1_2(self, out):
    """
    Migrate from 1.1 to 1.2: We now use a field `instructors' instead
    of `instructor', and it contains a list instead of a string.
    """
    if not haveContentMigrations:
        print >> out, "WARNING: Install contentmigrations to be able to migrate from 1.1 to 1.2"
        return

    class InstructorsMigrator(InlineFieldActionMigrator):
        src_portal_type = src_meta_type = (ECL_META,)

        fieldActions = ({ 'fieldName':    'instructor',
                          'newFieldName': 'instructors',
                          'transform':    instructor_to_instructors,
                          },
                        )

    # Migrate instructor field
    portal = getToolByName(self, 'portal_url').getPortalObject()
    walker = CustomQueryWalker(portal, InstructorsMigrator, query={})
    transaction.savepoint(optimistic=True)
    print >> out, "Migrating from instructor to instructors"
    walker.go()
開發者ID:dtgit,項目名稱:dtedu,代碼行數:24,代碼來源:Migrations.py

示例14: migrateSmartLinkToLink

def migrateSmartLinkToLink(context):
    from Products.contentmigration.walker import CustomQueryWalker
    migrator = makeMigrator(context, 'Link', 'ATLink')
    walker = CustomQueryWalker(context, migrator, callBefore=isSmartLink, use_savepoint=True)
    walker.go()
    return walker.getOutput().splitlines()
開發者ID:RedTurtle,項目名稱:redturtle.smartlink,代碼行數:6,代碼來源:migrator.py

示例15: v1beta7_v1beta8

def v1beta7_v1beta8(self, out):
    """Migrate from beta 7 to beta 8
    """

    if not haveContentMigrations:
        print >> out, "WARNING: Install contentmigrations to be able to migrate from v1 beta 7 to beta 8"
        return

    class ReleaseStateMigrator(BaseInlineMigrator):
        src_portal_type = src_meta_type = 'PSCRelease'

        stateMap = {'final' : 'final',
                    'rc'    : 'release-candidate',
                    'beta'  : 'beta',
                    'alpha' : 'alpha',
                    'in progress' : 'pre-release',
                    'in-progress' : 'pre-release'}

        def migrate_releaseState(self):
            maturity = getattr(aq_base(self.obj), 'maturity', None)
            wftool = getToolByName(self.obj, 'portal_workflow')
            wfdef = getattr(aq_base(wftool), 'psc_release_workflow', None)
            if maturity is not None and wfdef is not None:
                maturity = str(maturity)
                state = self.stateMap.get(maturity.lower(), 'pre-release')
                wfstate = {'action'       : None,
                           'actor'        : None,
                           'comments'     : 'Updated by migration; maturity was ' + maturity,
                           'review_state' : state,
                           'time'         : DateTime()}
                wftool.setStatusOf('psc_release_workflow', self.obj, wfstate)
                wfdef.updateRoleMappingsFor(self.obj)
                self.obj.reindexObject()

    class ReleaseCountMigrator(BaseInlineMigrator):
        src_portal_type = src_meta_type = 'PSCProject'

        def migrate_releaseCount(self):
            releaseCount = getattr(aq_base(self.obj), 'releaseCount', None)
            catalog = getToolByName(self.obj, 'portal_catalog')
            releases = catalog.searchResults(portal_type = 'PSCRelease',
                                             review_state = ('alpha', 'beta', 'release-candidate', 'final',),
                                             path = '/'.join(self.obj.getPhysicalPath()))
            if releaseCount is None:
                self.obj.manage_addProperty('releaseCount', len(releases), 'int')
            else:
                self.obj.manage_changeProperties(releaseCount = len(releases))
            self.obj.reindexObject()

    portal = getToolByName(self, 'portal_url').getPortalObject()

    # Migrate release state
    walker = CustomQueryWalker(portal, ReleaseStateMigrator, query = {})
    transaction.savepoint(optimistic=True)
    print >> out, "Migrating from field-based maturity to workflow-based maturity"
    walker.go()

    # Migrate release count variable
    walker = CustomQueryWalker(portal, ReleaseCountMigrator, query = {})
    transaction.savepoint(optimistic=True)
    print >> out, "Adding release count property"
    walker.go()
開發者ID:Conectivo,項目名稱:Products.PloneSoftwareCenter,代碼行數:62,代碼來源:Migrations.py


注:本文中的Products.contentmigration.walker.CustomQueryWalker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。