本文整理汇总了Python中zope.proxy.removeAllProxies函数的典型用法代码示例。如果您正苦于以下问题:Python removeAllProxies函数的具体用法?Python removeAllProxies怎么用?Python removeAllProxies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeAllProxies函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: commentRemoved
def commentRemoved(comment, ev):
comment = removeAllProxies(comment)
catalog = removeAllProxies(getCatalog())
try:
catalog.unindex_doc(getUtility(IIntIds).getId(comment))
except KeyError:
pass
示例2: testTraverseNameView
def testTraverseNameView(self):
pub = self.klass(self.db)
class I(Interface):
pass
class C(object):
implements(I)
ob = C()
class V(object):
def __init__(self, context, request):
pass
implements(ISOAPPresentation)
# Register the simple traverser so we can traverse without @@
from z3c.soap.interfaces import ISOAPPublisher, ISOAPRequest
from zope.app.publication.traversers import SimpleComponentTraverser
ztapi.provideView(Interface, ISOAPRequest, ISOAPPublisher, "", SimpleComponentTraverser)
r = self._createRequest("/@@spam", pub)
ztapi.provideView(I, ISOAPRequest, Interface, "spam", V)
ob2 = pub.traverseName(r, ob, "@@spam")
self.assertEqual(removeAllProxies(ob2).__class__, V)
ob2 = pub.traverseName(r, ob, "spam")
self.assertEqual(removeAllProxies(ob2).__class__, V)
示例3: testTraverseNameView
def testTraverseNameView(self):
pub = self.klass(self.db)
class I(Interface):
pass
class C(object):
implements(I)
ob = C()
class V(object):
def __init__(self, context, request):
pass
implements(IXMLRPCView)
# Register the simple traverser so we can traverse without @@
component.provideAdapter(SimpleComponentTraverser,
(Interface, IXMLRPCRequest),
IXMLRPCPublisher)
r = self._createRequest('/@@spam', pub)
component.provideAdapter(V, (I, IXMLRPCRequest), Interface,
name='spam')
ob2 = pub.traverseName(r, ob, '@@spam')
self.assertEqual(removeAllProxies(ob2).__class__, V)
ob2 = pub.traverseName(r, ob, 'spam')
self.assertEqual(removeAllProxies(ob2).__class__, V)
示例4: retract
def retract(self, principal=None):
if principal is None:
principal = getPrincipal()
if not self.isRetractable(principal):
raise DraftException('Cannot retract content.')
container = queryMultiAdapter((principal, self), IDraftContainer)
if container is None:
raise DraftException('Cannot find draft container.')
content = self.context
origName = content.__name__
oldContainer = content.__parent__
newName = INameChooser(container).chooseName(u'', content)
container[newName] = removeAllProxies(content)
del removeAllProxies(oldContainer)[origName]
draft = container[newName]
event.notify(ObjectRetractedEvent(content, draft))
return draft
示例5: generateMessageId
def generateMessageId(self, post, salt=None):
ids = getUtility(IIntIds)
post = ids.getId(removeAllProxies(post))
if salt:
if not isinstance(salt, basestring):
salt = str(ids.getId(removeAllProxies(salt)))
return '<%s.%[email protected]>'%(post, salt)
else:
return '<%[email protected]>'%post
示例6: getMailInDestination
def getMailInDestination(context):
annotation = IAnnotations(removeAllProxies(context))
destination = annotation.get(KEY)
if destination is None:
destination = MailInAwareDestination(removeAllProxies(context))
annotation[KEY] = destination
return destination
示例7: __call__
def __call__(self):
context = self.context
removeAllProxies(context)._v_currentRevision = -1
rendered = super(WorkingRevision, self).__call__()
removeAllProxies(context)._v_currentRevision = None
return rendered
示例8: getContent
def getContent(self):
content = self.wizard.getContent()
data = removeAllProxies(content.getFieldData())
for schema in (removeAllProxies(content).__schema__, IField):
for name in getFieldNames(schema):
field = schema[name].bind(content)
data[name] = field.get(content)
return data
示例9: __call__
def __call__(self):
revid = int(self.context.__name__)
content = self.context.__parent__.__parent__
if checkPermission('zojax.ModifyContent', content):
removeAllProxies(content).setRevision(revid)
IStatusMessage(self.request).add(
_('Revision has been activated.'))
self.redirect('../')
示例10: install
def install(self):
ws = self.space.get(self.name)
if not IMessagesWorkspace.providedBy(ws):
ws = MessagesWorkspace(self.space.principalId)
event.notify(ObjectCreatedEvent(ws))
removeAllProxies(self.space)[self.name] = ws
ws.__name__ = self.name
ws.__parent__ = removeAllProxies(self.space)
return ws
示例11: __init__
def __init__(self, record, default=None):
values = []
ids = getUtility(IIntIds)
context = removeAllProxies(record.object)
while context is not None:
values.append(ids.queryId(context))
context = removeAllProxies(
getattr(context, '__parent__', None))
self.value = values
示例12: search
def search(self, object=None, contexts=(),
sort_on='date', sort_order='reverse',
noSecurityChecks=False, **kw):
ids = getUtility(IIntIds)
query = dict(kw)
# records for object
if type(object) is not type({}) and object is not None:
oid = ids.queryId(removeAllProxies(object))
if oid is None:
return ResultSet(IFBTree(), getUtility(IActivity))
query['object'] = {'any_of': (oid,)}
# context
if not contexts:
contexts = (getSite(),)
c = []
for context in contexts:
id = ids.queryId(removeAllProxies(context))
if id is not None:
c.append(id)
query['contexts'] = {'any_of': c}
# security
if not noSecurityChecks:
request = getRequest()
if request is not None:
users = listAllowedRoles(request.principal, getSite())
if 'zope.Anonymous' not in users:
users.append('zope.Anonymous')
query['allowedUsers'] = {'any_of': users}
# apply searh terms
results = self.apply(query)
if results is None:
results = IFBTree()
# sort result by index
if sort_on and sort_on in self:
sortable = ISortable(self[sort_on], None)
if sortable is not None:
results = sortable.sort(results)
if sort_order == 'reverse':
return ReverseResultSet(results, getUtility(IActivity))
else:
return ResultSet(results, getUtility(IActivity))
示例13: completeTask
def completeTask(self):
results = getUtility(ICatalog).searchResults(
type={'any_of': ('project.task',),},
projectTaskState = {'any_of': (1,)},
projectTaskMilestone = {'any_of': (getUtility(IIntIds).getId(self),)},
searchContext = self.__parent__.__parent__)
for task in results:
removeAllProxies(task).completeTask()
event.notify(ObjectModifiedEvent(task))
self.state = 2
event.notify(StateChangedEvent(self, 2))
示例14: search
def search(self, content=None,
contexts=(), sort_on='date', sort_order='reverse', types=(), approved=()):
ids = getUtility(IIntIds)
indexes = list(self.values())
query = {}
# comments for content
if content:
query['content'] = {'any_of':(ids.getId(removeAllProxies(content)),)}
# context
if contexts:
c = []
for context in contexts:
id = ids.queryId(removeAllProxies(context))
if id is not None:
c.append(id)
query['contexts'] = {'any_of': c}
# content type
if types:
query['type'] = {'any_of': types}
# security
users = listAllowedRoles(getRequest().principal, getSite())
if 'zope.Anonymous' not in users:
users.append('zope.Anonymous')
query['access'] = {'any_of': users}
# comments approved
if approved:
query['approved'] = {'any_of': approved}
# apply searh terms
results = self.apply(query)
if results is None:
results = IFBTree()
# sort result by index
if sort_on and sort_on in self:
sortable = ISortable(self[sort_on], None)
if sortable is not None:
results = sortable.sort(results)
if sort_order == 'reverse':
return ReverseResultSet(results, ids)
else:
return ResultSet(results, ids)
示例15: publishTraverse
def publishTraverse(self, request, name):
view = queryMultiAdapter((self.context, request), name=name)
if view is not None:
return view
tasks = self.context.__parent__.__parent__.get('tasks')
if tasks is not None:
task = tasks.get(name)
if task is not None:
id = getUtility(IIntIds).getId(removeAllProxies(self.context))
if task.milestone == id:
return LocationProxy(
removeAllProxies(task), self.context, name)
raise NotFound(self.context, name, request)