本文整理汇总了Python中OFS.ObjectManager.ObjectManager类的典型用法代码示例。如果您正苦于以下问题:Python ObjectManager类的具体用法?Python ObjectManager怎么用?Python ObjectManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update_portal_for_z210
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,代码行数:26,代码来源:migutils.py
示例2: importDesignFromZip
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,代码行数:57,代码来源:design.py
示例3: __init__
def __init__(self, *args, **kwargs):
ObjectManager.__init__(self, *args)
self.user = None
self.job_name = None
self.job_type = None
self.job_description = None
self.status = states.PENDING
self.date_schedule = None
self.date_started = None
self.date_done = None
self.result = None
self.update(kwargs)
开发者ID:damilare,项目名称:zenoss-prodbin,代码行数:12,代码来源:manager.py
示例4: deleteDocuments
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,代码行数:13,代码来源:database.py
示例5: _processExtFile
def _processExtFile(self, mid, ctype):
""" Apply media converters to self subobject with given id (mid) which
is stored outside Data.fs, with original content-type ctype.
"""
from OFS.ObjectManager import ObjectManager
media = ObjectManager._getOb(self, mid)
launch_job(media2flv, self.aq_parent, ofs_path(media))
开发者ID:eaudeweb,项目名称:Naaya-legacy,代码行数:7,代码来源:mediafile_item.py
示例6: addIndex
def addIndex(self, name, type,extra=None):
# Convert the type by finding an appropriate product which supports
# this interface by that name. Bleah
products = ObjectManager.all_meta_types(self, interfaces=(
PluggableIndexInterface,))
p = None
for prod in products:
if prod['name'] == type:
p = prod
break
if p is None:
raise ValueError, "Index of type %s not found" % type
base = p['instance']
if base is None:
raise ValueError, "Index type %s does not support addIndex" % type
# This code is somewhat lame but every index type has its own
# function signature *sigh* and there is no common way to pass
# additional parameters to the constructor. The suggested way
# for new index types is to use an "extra" record.
if 'extra' in base.__init__.func_code.co_varnames:
index = base(name, extra=extra, caller=aq_base(self))
else:
index = base(name, aq_base(self))
self._catalog.addIndex(name,index)
开发者ID:OS2World,项目名称:APP-SERVER-Zope,代码行数:33,代码来源:ZCatalog.py
示例7: _delObject
def _delObject(self, id, dp=1, suppress_events=False):
"""When deleted clear __primary_parent__."""
obj = self._getOb(id, None)
if obj is None:
# Added this check because we are seeing stack traces in the UI.
# We aren't 100% sure what is causing the object to disappear from
# the ObjectManager. It could be that a different user had already
# deleted it or that a single user had two brower tabs open. Ian saw
# a case were the references on an object were wrong (getPrimaryId
# pointed to the wrong location) but I'm not sure that is what is
# causing this problem. -EAD
log.warning(
"Tried to delete object id '%s' but didn't find it on %s",
id, self.getPrimaryId())
return
ObjectManager._delObject(self, id, dp, suppress_events)
obj.__primary_parent__ = None
开发者ID:bbc,项目名称:zenoss-prodbin,代码行数:17,代码来源:PrimaryPathObjectManager.py
示例8: deleteDocuments
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,代码行数:17,代码来源:PlominoDatabase.py
示例9: __init__
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Globals import InitializeClass
from OFS.ObjectManager import ObjectManager
from ZODB.POSException import ConflictError
logger = logging.getLogger('CMFCore.Skinnable')
# superGetAttr is assigned to whatever ObjectManager.__getattr__
# used to do.
try:
superGetAttr = ObjectManager.__getattr__
except AttributeError:
try:
superGetAttr = ObjectManager.inheritedAttribute('__getattr__')
except AttributeError:
superGetAttr = None
_MARKER = object() # Create a new marker object.
SKINDATA = {} # mapping thread-id -> (skinobj, skinname, ignore, resolve)
class SkinDataCleanup:
"""Cleanup at the end of the request."""
def __init__(self, tid):
self.tid = tid
def __del__(self):
tid = self.tid
# Be extra careful in __del__
开发者ID:dtgit,项目名称:dtedu,代码行数:31,代码来源:Skinnable.py
示例10: manage_beforeDelete
def manage_beforeDelete(self, item, container):
ObjectManager.manage_beforeDelete(self, item, container)
Reference.manage_beforeDelete(self, item, container)
开发者ID:urska19,项目名称:Plone-test,代码行数:3,代码来源:ReferenceEngine.py
示例11: manage_afterAdd
def manage_afterAdd(self, item, container):
Reference.manage_afterAdd(self, item, container)
ObjectManager.manage_afterAdd(self, item, container)
开发者ID:urska19,项目名称:Plone-test,代码行数:3,代码来源:ReferenceEngine.py
示例12: importDesignFromJSON
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,代码行数:81,代码来源:design.py
示例13: manage_afterAdd
def manage_afterAdd(self,item,container):
ObjectManager.manage_afterAdd(self,item,container)
BasicUserFolder.manage_afterAdd(self,item,container)
开发者ID:clearwired,项目名称:Blend-CMS,代码行数:3,代码来源:SimpleUserFolder.py
示例14: manage_beforeDelete
def manage_beforeDelete(self,item,container):
BasicUserFolder.manage_beforeDelete(self,item,container)
ObjectManager.manage_beforeDelete(self,item,container)
开发者ID:clearwired,项目名称:Blend-CMS,代码行数:3,代码来源:SimpleUserFolder.py
示例15: _setObject
def _setObject(self, id, obj, roles=None, user=None, set_owner=1):
"""Track __primary_parent__ when we are set into an object"""
obj.__primary_parent__ = aq_base(self)
return ObjectManager._setObject(self, id, obj, roles, user, set_owner)
开发者ID:bbc,项目名称:zenoss-prodbin,代码行数:4,代码来源:PrimaryPathObjectManager.py
注:本文中的OFS.ObjectManager.ObjectManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论