本文整理汇总了Python中Products.contentmigration.walker.CustomQueryWalker.getOutput方法的典型用法代码示例。如果您正苦于以下问题:Python CustomQueryWalker.getOutput方法的具体用法?Python CustomQueryWalker.getOutput怎么用?Python CustomQueryWalker.getOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.contentmigration.walker.CustomQueryWalker
的用法示例。
在下文中一共展示了CustomQueryWalker.getOutput方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrateFlowplayerToRedTurtleVideo
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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()
示例2: migrate
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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()
示例3: upgrade_step_1
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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()
示例4: migrate
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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()
示例5: migrate
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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"
示例6: __call__
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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
示例7: migrateContents
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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
示例8: migrateCustomAT
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
def migrateCustomAT(fields_mapping, src_type, dst_type, dry_run=False):
"""
Try to get types infos from archetype_tool, then set a migrator an pass it
given values. There is a dry_run mode that allows to check the success of
a migration without committing.
"""
portal = getSite()
# if the type still exists get the src_meta_type from the portal_type
portal_types = getToolByName(portal, 'portal_types')
fti = portal_types.get(src_type, None)
# Check if the fti was removed or replaced by a DX-implementation
if fti is None or IDexterityFTI.providedBy(fti):
# Get the needed info from an instance of the type
catalog = portal.portal_catalog
brains = catalog(portal_type=src_type, sort_limit=1)
if not brains:
# no item? assume stuff
is_folderish = False
src_meta_type = src_type
else:
src_obj = brains[0].getObject()
if IDexterityContent.providedBy(src_obj):
logger.error(
'%s should not be dexterity object!',
src_obj.absolute_url())
is_folderish = getattr(src_obj, 'isPrincipiaFolderish', False)
src_meta_type = src_obj.meta_type
else:
# Get info from at-fti
src_meta_type = fti.content_meta_type
archetype_tool = getToolByName(portal, 'archetype_tool', None)
for info in archetype_tool.listRegisteredTypes():
# lookup registered type in archetype_tool with meta_type
# because several portal_types can use same meta_type
if info.get('meta_type') == src_meta_type:
klass = info.get('klass', None)
is_folderish = klass.isPrincipiaFolderish
migrator = makeCustomATMigrator(context=portal,
src_type=src_type,
dst_type=dst_type,
fields_mapping=fields_mapping,
is_folderish=is_folderish,
dry_run=dry_run)
if migrator:
migrator.src_meta_type = src_meta_type
migrator.dst_meta_type = ''
walker_settings = {'portal': portal,
'migrator': migrator,
'src_portal_type': src_type,
'dst_portal_type': dst_type,
'src_meta_type': src_meta_type,
'dst_meta_type': '',
'use_savepoint': True}
if dry_run:
walker_settings['limit'] = 1
walker = CustomQueryWalker(**walker_settings)
walker.go()
walker_infos = {'errors': walker.errors,
'msg': walker.getOutput().splitlines(),
'counter': walker.counter}
for error in walker.errors:
logger.error(error.get('message'))
if dry_run:
transaction.abort()
return walker_infos
示例9: migrateSimpleAttachment
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
def migrateSimpleAttachment(portal, migrator):
walker = CustomQueryWalker(portal, migrator, full_transaction=True)
savepoint(optimistic=True)
walker.go()
return walker.getOutput()
示例10: migrateSmartLinkToLink
# 需要导入模块: from Products.contentmigration.walker import CustomQueryWalker [as 别名]
# 或者: from Products.contentmigration.walker.CustomQueryWalker import getOutput [as 别名]
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()