当前位置: 首页>>代码示例>>Python>>正文


Python ObjectManager.manage_delObjects方法代码示例

本文整理汇总了Python中OFS.ObjectManager.ObjectManager.manage_delObjects方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectManager.manage_delObjects方法的具体用法?Python ObjectManager.manage_delObjects怎么用?Python ObjectManager.manage_delObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OFS.ObjectManager.ObjectManager的用法示例。


在下文中一共展示了ObjectManager.manage_delObjects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_portal_for_z210

# 需要导入模块: from OFS.ObjectManager import ObjectManager [as 别名]
# 或者: from OFS.ObjectManager.ObjectManager import manage_delObjects [as 别名]
def update_portal_for_z210(portal):
    """The way that the component registry and other things changed when going
    from Zope 2.9 to 2.10.  This function will migrate all aspects that it
    can migrate.
    """

    portal = aq_base(portal)
    if 'utilities' in portal.objectIds():
        for id, u in portal.utilities.objectItems():
            pieces = id.split('-')
            ifacename = pieces[0]
            name = u''
            if len(pieces) > 1:
                name = pieces[1]
            iface = None
            for checkiface in interface.providedBy(u).flattened():
                if checkiface.getName() == ifacename:
                    iface = checkiface
                    break
            if iface is not None:
                update_utility(portal, id, u, iface, name)

        if len(portal.utilities.objectIds()) == 0:
            # using ObjectManager since it doesn't do as intensive
            # security checks as PloneSite.manage_delObjects
            ObjectManager.manage_delObjects(portal, ['utilities'])
开发者ID:collective,项目名称:p4a.common,代码行数:28,代码来源:migutils.py

示例2: importDesignFromZip

# 需要导入模块: from OFS.ObjectManager import ObjectManager [as 别名]
# 或者: from OFS.ObjectManager.ObjectManager import manage_delObjects [as 别名]
    def importDesignFromZip(self, zip_file, replace=False):
        """Import the design from a zip file
        """
        logger.info("Start design import")
        self.setStatus(_("Importing design"))
        self.getIndex().no_refresh = True
        txn = transaction.get()
        count = 0
        total = 0
        if replace:
            logger.info("Replace mode: removing current design")
            designelements = (
                [o.id for o in self.getForms()] +
                [o.id for o in self.getViews()] +
                [o.id for o in self.getAgents()])
            ObjectManager.manage_delObjects(self, designelements)
            ObjectManager.manage_delObjects(
                self.resources,
                list(self.resources.objectIds()))
            logger.info("Current design removed")
        total_elements = None
        file_names = zip_file.namelist()
        for file_name in file_names:
            json_string = zip_file.open(file_name).read()
            if not json_string:
                # E.g. if the zipfile contains entries for directories
                continue
            design = json.loads(json_string, object_pairs_hook=OrderedDict)["design"]
            elements = design.items()
            if not total_elements:
                total_elements = len(elements)
            for (name, element) in elements:
                if name == 'dbsettings':
                    logger.info("Import db settings")
                    self.importDbSettingsFromJSON(element)
                elif name == 'resources':
                    for (res_id, res) in design['resources'].items():
                        logger.info("Import resource" + res_id)
                        self.importResourceFromJSON(
                            self.resources, res_id, res)
                else:
                    logger.info("Import " + name)
                    self.importElementFromJSON(self, name, element)
                count = count + 1
                total = total + 1
                if count == 10:
                    self.setStatus(_("Importing design (%d%%)") % int(
                        100 * total / total_elements))
                    logger.info(
                        "(%d elements committed, still running...)" % total)
                    txn.savepoint(optimistic=True)
                    count = 0

        logger.info("(%d elements imported)" % total)
        self.setStatus(_("Ready"))
        txn.commit()
        self.getIndex().no_refresh = False
开发者ID:plomino,项目名称:Plomino,代码行数:59,代码来源:design.py

示例3: deleteDocuments

# 需要导入模块: from OFS.ObjectManager import ObjectManager [as 别名]
# 或者: from OFS.ObjectManager.ObjectManager import manage_delObjects [as 别名]
    def deleteDocuments(self, ids=None, massive=True):
        """ Batch delete documents from database.
        If ``massive`` is True, the ``onDelete`` formula and index
        updating are not performed (use ``refreshDB`` to update).
        """
        if ids is None:
            ids = [doc.id for doc in self.getAllDocuments()]

        if massive:
            ObjectManager.manage_delObjects(self.documents, ids)
        else:
            for id in ids:
                self.deleteDocument(self.getDocument(id))
开发者ID:deepak41,项目名称:Plomino,代码行数:15,代码来源:database.py

示例4: deleteDocuments

# 需要导入模块: from OFS.ObjectManager import ObjectManager [as 别名]
# 或者: from OFS.ObjectManager.ObjectManager import manage_delObjects [as 别名]
    def deleteDocuments(self, ids=None, massive=True):
        """ Batch delete documents from database.
        If ``massive`` is True, the ``onDelete`` formula and index
        updating are not performed (use ``refreshDB`` to update).
        """
        if ids is None:
            ids = [doc.id for doc in self.getAllDocuments()]

        if massive:
            ObjectManager.manage_delObjects(self.documents, ids)
        else:
            for id in ids:
                try:
                    self.deleteDocument(self.getDocument(id))
                except Exception, e:
                    # TODO: if insufficient access rights or absolutely anything else. Fix the bare except.
                    warnings.warn("Error during deletion: %s" % e)
开发者ID:Vinsurya,项目名称:Plone,代码行数:19,代码来源:PlominoDatabase.py

示例5: importDesignFromJSON

# 需要导入模块: from OFS.ObjectManager import ObjectManager [as 别名]
# 或者: from OFS.ObjectManager.ObjectManager import manage_delObjects [as 别名]
    def importDesignFromJSON(self, jsonstring=None, REQUEST=None,
            from_folder=None, replace=False):
        """
        """
        logger.info("Start design import")
        self.setStatus(_("Importing design"))
        self.getIndex().no_refresh = True
        txn = transaction.get()
        json_strings = []
        count = 0
        total = 0
        if from_folder:
            if not os.path.isdir(from_folder):
                raise PlominoDesignException('%s does not exist' % from_folder)
            json_files = (glob.glob(os.path.join(from_folder, '*.json')) +
                glob.glob(os.path.join(from_folder, 'resources/*.json')))
            total_elements = len(json_files)
            for p in json_files:
                fileobj = codecs.open(p, 'r', 'utf-8')
                json_strings.append(fileobj.read())
        else:
            if REQUEST:
                filename = REQUEST.get('filename')
                f = REQUEST.get(filename)
                cte = f.headers.get('content-transfer-encoding')
                if cte == 'base64':
                    filecontent = base64.decodestring(f.read())
                else:
                    filecontent = f.read()
                json_strings.append(asUnicode(filecontent))
            else:
                json_strings.append(asUnicode(jsonstring))
            total_elements = None

        if replace:
            logger.info("Replace mode: removing current design")
            designelements = [o.id for o in
                    self.getForms() +
                    self.getViews() +
                    self.getAgents()]
            ObjectManager.manage_delObjects(self, designelements)
            ObjectManager.manage_delObjects(
                self.resources,
                # Un-lazify BTree
                list(self.resources.objectIds()))
            logger.info("Current design removed")

        for jsonstring in json_strings:
            design = json.loads(jsonstring.encode('utf-8'), object_pairs_hook=OrderedDict)["design"]
            elements = design.items()

            if not total_elements:
                total_elements = len(elements)

            for (name, element) in design.items():
                if name == 'dbsettings':
                    logger.info("Import db settings")
                    self.importDbSettingsFromJSON(element)
                elif name == 'resources':
                    for (res_id, res) in design['resources'].items():
                        logger.info("Import resource" + res_id)
                        self.importResourceFromJSON(
                            self.resources, res_id, res)
                else:
                    logger.info("Import " + name)
                    self.importElementFromJSON(self, name, element)
                count = count + 1
                total = total + 1
                if count == 10:
                    self.setStatus(
                        _("Importing design (%d%%)") % int(
                            100 * total / total_elements))
                    logger.info(
                        "(%d elements committed, still running...)" % total)
                    txn.savepoint(optimistic=True)
                    count = 0

        logger.info("(%d elements imported)" % total)
        self.setStatus(_("Ready"))
        txn.commit()
        self.getIndex().no_refresh = False
开发者ID:plomino,项目名称:Plomino,代码行数:83,代码来源:design.py


注:本文中的OFS.ObjectManager.ObjectManager.manage_delObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。