本文整理匯總了Python中plone.app.drafts.interfaces.ICurrentDraftManagement.mark方法的典型用法代碼示例。如果您正苦於以下問題:Python ICurrentDraftManagement.mark方法的具體用法?Python ICurrentDraftManagement.mark怎麽用?Python ICurrentDraftManagement.mark使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plone.app.drafts.interfaces.ICurrentDraftManagement
的用法示例。
在下文中一共展示了ICurrentDraftManagement.mark方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import mark [as 別名]
def __init__(self, form, request, context):
fti = queryUtility(IDexterityFTI, name=form.portal_type)
if IDraftable.__identifier__ in fti.behaviors:
draft = getCurrentDraft(request, create=False)
target = getattr(draft, '_draftAddFormTarget',
createContent(form.portal_type))
if draft is None:
IMutableUUID(target).set('++add++%s' % form.portal_type)
beginDrafting(target.__of__(context), None)
draft = getCurrentDraft(request, create=True)
draft._draftAddFormTarget = target
# Disable Plone 5 implicit CSRF when no form action
if HAS_PLONE_PROTECT:
if not ([key for key in request.form
if key.startswith('form.buttons.')]):
alsoProvides(request, IDisableCSRFProtection)
else:
current = ICurrentDraftManagement(request)
current.mark()
context = DraftProxy(draft, target.__of__(context))
alsoProvides(request, IAddFormDrafting)
super(DefaultAddFormFieldWidgets, self).__init__(form, request, context) # noqa
示例2: beginDrafting
# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import mark [as 別名]
def beginDrafting(context, event):
"""When we enter the edit screen, set up the target key and draft cookie
path. If there is exactly one draft for the given user id and target key,
consider that to be the current draft. Also mark the request with
IDrafting if applicable.
"""
storage = queryUtility(IDraftStorage)
if storage is None or not storage.enabled:
return
request = getattr(context, 'REQUEST', None)
if request is None:
return
current = ICurrentDraftManagement(request)
# Update target key regardless - we could have a stale cookie
current.targetKey = getObjectKey(context)
if current.draftName is None:
drafts = storage.getDrafts(current.userId, current.targetKey)
if len(drafts) == 1:
current.draftName = tuple(drafts.keys())[0]
# Save the path now so that we can use it again later, even on URLs
# (e.g. in AJAX dialogues) that are below this path.
current.path = current.defaultPath
current.mark()
current.save()
示例3: test_mark
# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import mark [as 別名]
def test_mark(self):
request = self.request
current = ICurrentDraftManagement(request)
current.mark()
self.failIf(IDrafting.providedBy(request))
current.targetKey = u"123"
current.mark()
self.failUnless(IDrafting.providedBy(request))
示例4: update
# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import mark [as 別名]
def update(self):
# Set up draft information if required
currentDraft = ICurrentDraftManagement(self.request)
currentDraft.mark()
# Override to check the tile add/edit permission
if not IDeferSecurityCheck.providedBy(self.request):
if not checkPermission(self.tileType.add_permission, self.context):
raise Unauthorized(
"You are not allowed to add this kind of tile")
super(TileForm, self).update()
示例5: __call__
# 需要導入模塊: from plone.app.drafts.interfaces import ICurrentDraftManagement [as 別名]
# 或者: from plone.app.drafts.interfaces.ICurrentDraftManagement import mark [as 別名]
def __call__(self):
# Set up draft information if required
currentDraft = ICurrentDraftManagement(self.request)
currentDraft.mark()
self.request['disable_border'] = True
confirm = self.request.form.get('confirm', False)
self.tileTypeName = self.request.form.get('type', None)
self.tileId = self.request.form.get('id', None)
self.deleted = False
if confirm and self.tileTypeName and self.tileId:
tileType = getUtility(ITileType, name=self.tileTypeName)
if not checkPermission(tileType.add_permission, self.context):
raise Unauthorized("You are not allowed to modify this " + \
"tile type")
tile = self.context.restrictedTraverse(
'@@%s/%s' % (self.tileTypeName, self.tileId,))
dm = ITileDataManager(tile)
dm.delete()
notify(ObjectRemovedEvent(tile, self.context, self.tileId))
self.deleted = True
elif 'form.button.Ok' in self.request.form:
self.request.response.redirect(
self.context.absolute_url() + '/view')
return ''
return self.index()