本文整理汇总了Python中plone.app.iterate.interfaces.ICheckinCheckoutPolicy类的典型用法代码示例。如果您正苦于以下问题:Python ICheckinCheckoutPolicy类的具体用法?Python ICheckinCheckoutPolicy怎么用?Python ICheckinCheckoutPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICheckinCheckoutPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_folderContents
def test_folderContents(self):
"""When an folder is checked out, and item is added, and then
the folder is checked back in, the added item is in the new
version of the folder. UIDs of contained content are also
preserved."""
container = self.portal.docs
folder = container[container.invokeFactory(
type_name='Folder', id='foo-folder')]
existing_doc = folder[folder.invokeFactory(
type_name='Document', id='existing-folder-item')]
existing_doc_uid = existing_doc.UID()
self.repo.save(folder)
wc = ICheckinCheckoutPolicy(folder).checkout(container)
new_doc = wc[wc.invokeFactory(type_name='Document',
id='new-folder-item',
text='new folder item text')]
new_doc_uid = new_doc.UID()
new_folder = ICheckinCheckoutPolicy(wc).checkin("updated")
catalog = getToolByName(self.portal, 'portal_catalog')
self.assertTrue('existing-folder-item' in new_folder)
self.assertEqual(
new_folder['existing-folder-item'].UID(), existing_doc_uid)
self.assertTrue('new-folder-item' in new_folder)
self.assertEqual(new_folder['new-folder-item'].UID(), new_doc_uid)
brains = catalog(path='/'.join(
new_folder['new-folder-item'].getPhysicalPath()))
self.assertTrue(brains)
self.assertTrue('new folder item text' in
new_folder['new-folder-item'].getText())
示例2: test_baselineNoCopyReferences
def test_baselineNoCopyReferences(self):
# ensure that custom state is maintained with the no copy adapter
# setup the named ref adapter
from zope import component
from Products.Archetypes.interfaces import IBaseObject
from plone.app.iterate import relation, interfaces
from plone.app.iterate.tests.utils import CustomReference
component.provideAdapter(
adapts=(IBaseObject,),
provides=interfaces.ICheckinCheckoutReference,
factory=relation.NoCopyReferenceAdapter,
name="zebra")
doc = self.portal.docs.doc1
ref = doc.addReference(
self.portal.docs, "zebra", referenceClass=CustomReference)
ref.custom_state = "hello world"
wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)
self.assertEqual(len(wc.getReferences("zebra")), 0)
doc = ICheckinCheckoutPolicy(wc).checkin("updated")
self.assertEqual(len(doc.getReferences("zebra")), 1)
ref = doc.getReferenceImpl("zebra")[0]
self.assert_(hasattr(ref, "custom_state"))
self.assertEqual(ref.custom_state, "hello world")
示例3: _checkout
def _checkout(self):
# NOTE: this code is copied from plone.app.iterate.browser.checkout
context = aq_inner(self.context)
containers = list(self._containers())
location = containers[0]["name"]
# We want to redirect to a specific template, else we might
# end up downloading a file
control = getMultiAdapter((context, self.request), name=u"iterate_control")
if not control.checkout_allowed():
raise CheckoutException(u"Not allowed")
locator = None
try:
locator = [c["locator"] for c in containers if c["name"] == location][0]
except IndexError:
IStatusMessage(self.request).addStatusMessage(_("Cannot find checkout location"), type="stop")
view_url = context.restrictedTraverse("@@plone_context_state").view_url()
self.request.response.redirect(view_url)
return
policy = ICheckinCheckoutPolicy(context)
wc = policy.checkout(locator())
# we do this for metadata update side affects which will update lock info
context.reindexObject("review_state")
IStatusMessage(self.request).addStatusMessage(_("Check-out created"), type="info")
# view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
return wc
示例4: checkin_allowed
def checkin_allowed(self):
"""Check if a checkin is allowed
"""
context = aq_inner(self.context)
checkPermission = getSecurityManager().checkPermission
if not interfaces.IIterateAware.providedBy(context):
return False
archiver = interfaces.IObjectArchiver(context)
if not archiver.isVersionable():
return False
if not IWorkingCopy.providedBy(context):
return False
policy = ICheckinCheckoutPolicy(context, None)
if policy is None:
return False
original = policy.getBaseline()
if original is None:
return False
can_modify = checkPermission(
Products.CMFCore.permissions.ModifyPortalContent,
original,
)
if not can_modify:
return False
return True
示例5: get_baseline_state
def get_baseline_state(self):
policy = ICheckinCheckoutPolicy(self.context)
baseline = policy.getBaseline()
if baseline is None:
baseline = self.context
return get_state(baseline)
示例6: __call__
def __call__(self):
context = aq_inner(self.context)
if 'form.button.Checkin' in self.request.form:
control = getMultiAdapter(
(context, self.request), name=u'iterate_control')
if not control.checkin_allowed():
raise CheckinException(u'Not a checkout')
message = self.request.form.get('checkin_message', '')
policy = ICheckinCheckoutPolicy(context)
baseline = policy.checkin(message)
IStatusMessage(self.request).addStatusMessage(
_('Checked in'), type='info')
view_url = baseline.restrictedTraverse(
'@@plone_context_state').view_url()
self.request.response.redirect(view_url)
elif 'form.button.Cancel'in self.request.form:
view_url = context.restrictedTraverse(
'@@plone_context_state').view_url()
self.request.response.redirect(view_url)
else:
return self.index()
示例7: handle_edit
def handle_edit(self):
policy = ICheckinCheckoutPolicy(self.context)
obj = policy.getWorkingCopy()
#baseline = policy.getBaseline()
if obj is None:
obj = self.context
state = get_state(obj)
if state in ['private', 'sent']:
url = '{0}/edit'.format(obj.absolute_url())
return self.request.response.redirect(url)
elif state == 'published':
# create copy, go to it
wc = self._checkout()
url = '{0}/edit'.format(wc.absolute_url())
return self.request.response.redirect(url)
elif state == 'pending':
# retract object, go to it
transition(obj, to_state='sent')
url = '{0}/edit'.format(obj.absolute_url())
return self.request.response.redirect(url)
raise ValueError ('unknown state')
示例8: _checkout
def _checkout(self):
# NOTE: this code is copied from plone.app.iterate.browser.checkout
context = aq_inner(self.context)
# containers = list(self._containers())
location = self.context.aq_parent #containers[0]['name']
# We want to redirect to a specific template, else we might
# end up downloading a file
control = getMultiAdapter((context, self.request),
name=u"iterate_control")
if not control.checkout_allowed():
raise CheckoutException(u"Not allowed")
policy = ICheckinCheckoutPolicy(context)
wc = policy.checkout(location)
transition(wc, to_state='sent')
# we do this for metadata update side affects which will update lock info
context.reindexObject('review_state')
IStatusMessage(self.request).addStatusMessage(_("Check-out created"),
type='info')
#view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
return wc
示例9: __call__
def __call__(self):
context = aq_inner(self.context)
# We want to redirect to a specific template, else we might
# end up downloading a file
if self.request.form.has_key('form.button.Checkout'):
control = getMultiAdapter((context, self.request), name=u"iterate_control")
if not control.checkout_allowed():
raise CheckoutException(u"Not allowed")
location = self.request.form.get('checkout_location', None)
locator = None
try:
locator = [c['locator'] for c in self.containers() if c['name'] == location][0]
except IndexError:
IStatusMessage(self.request).addStatusMessage(_("Cannot find checkout location"), type='stop')
view_url = context.restrictedTraverse("@@plone_context_state").view_url()
self.request.response.redirect(view_url)
return
policy = ICheckinCheckoutPolicy(context)
wc = policy.checkout(locator())
# we do this for metadata update side affects which will update lock info
context.reindexObject('review_state')
IStatusMessage(self.request).addStatusMessage(_("Check-out created"), type='info')
view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
self.request.response.redirect(view_url)
elif self.request.form.has_key('form.button.Cancel'):
view_url = context.restrictedTraverse("@@plone_context_state").view_url()
self.request.response.redirect(view_url)
else:
return self.index()
示例10: test_wcNewForwardReferencesCopied
def test_wcNewForwardReferencesCopied( self ):
# ensure that new wc references are copied back to the baseline on checkin
doc = self.portal.docs.doc1
doc.addReference( self.portal.docs )
self.assertEqual( len(doc.getReferences("zebra")), 0)
wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
wc.addReference( self.portal.docs.doc2, "zebra")
doc = ICheckinCheckoutPolicy( wc ).checkin( "updated" )
self.assertEqual( len(doc.getReferences("zebra")), 1 )
示例11: cancel_allowed
def cancel_allowed(self):
"""Check to see if the user can cancel the checkout on the
given working copy
"""
policy = ICheckinCheckoutPolicy(self.context, None)
if policy is None:
return False
original = policy.getBaseline()
return original is not None
示例12: get_working_copy
def get_working_copy(self):
context = self.context
policy = ICheckinCheckoutPolicy(context, None)
if policy is None:
return False
wc = policy.getWorkingCopy()
return wc
示例13: __call__
def __call__(self):
policy = ICheckinCheckoutPolicy(self.context)
if IBaseline.providedBy(self.context):
self.baseline = self.context
self.working_copy = policy.getWorkingCopy()
elif IWorkingCopy.providedBy(self.context):
self.working_copy = self.context
self.baseline = policy.getBaseline()
else:
raise AttributeError('Invalid Context')
return self.index()
示例14: test_cancel_checkout
def test_cancel_checkout(self):
self.setRoles(('Contributor',))
p1 = self.places['1']
self.failUnless('foo' in p1, p1.keys())
wc = ICheckinCheckoutPolicy(p1).checkout(self.places)
self.failUnlessEqual(len(wc.keys()), 0, wc.keys())
p1 = ICheckinCheckoutPolicy(wc).cancelCheckout()
self.failUnless('foo' in p1, p1.keys())
# A child's history acquires its parent's history
history = self.repo.getHistory(p1['foo'])
self.failUnlessEqual(len(history), 1)
示例15: checkInIfNeeded
def checkInIfNeeded(document, event):
context = aq_inner(document)
workflowTool = getToolByName(context, "portal_workflow")
status = workflowTool.getStatusOf("1MX_wiki_workflow", document)
if IWorkingCopy.providedBy(context) and status["review_state"] == "internally_published":
policy = ICheckinCheckoutPolicy(context)
baseline = policy.checkin("")
IStatusMessage(context.REQUEST).addStatusMessage(
_("Checked in"), type='info')
view_url = baseline.unrestrictedTraverse("@@plone_context_state").view_url()
transaction.commit()
raise Redirect(view_url)