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


Python ICheckinCheckoutPolicy.checkout方法代码示例

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


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

示例1: test_control_cancel_on_original_does_not_delete_original

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    def test_control_cancel_on_original_does_not_delete_original(self):
        # checkout document
        doc = self.portal.docs.doc1
        policy = ICheckinCheckoutPolicy(self.portal.docs.doc1, None)
        policy.checkout(self.portal.workarea)

        # get cancel browser view
        from plone.app.iterate.browser.cancel import Cancel
        cancel = Cancel(doc, self.layer['request'])
        self.layer['request'].form['form.button.Cancel'] = True

        # check if cancel on original raises the correct exception
        from plone.app.iterate.interfaces import CheckoutException
        with self.assertRaises(CheckoutException):
            cancel()
开发者ID:plone,项目名称:plone.app.iterate,代码行数:17,代码来源:test_iterate.py

示例2: _checkout

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    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
开发者ID:abstract-open-solutions,项目名称:eea.climateadapt.plone,代码行数:33,代码来源:views.py

示例3: __call__

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    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()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:36,代码来源:checkout.py

示例4: _checkout

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    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
开发者ID:eea,项目名称:eea.climateadapt.plone,代码行数:27,代码来源:views.py

示例5: test_annotation_saved_on_checkin

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    def test_annotation_saved_on_checkin(self):
        # First we get and save a custom annotation to the existing object
        obj_annotations = IAnnotations(self.s1)
        self.assertEqual(obj_annotations, {})

        obj_annotations['key1'] = u'value1'
        obj_annotations = IAnnotations(self.s1)
        self.assertEqual(obj_annotations, {'key1': u'value1'})

        # Now, let's get a working copy for it.
        locators = getAdapters((self.s1,), IWCContainerLocator)
        location = u'plone.app.iterate.parent'
        locator = [c[1] for c in locators if c[0] == location][0]

        policy = ICheckinCheckoutPolicy(self.s1)

        wc = policy.checkout(locator())

        # Annotations should be the same
        new_annotations = IAnnotations(wc)
        self.assertEqual(new_annotations['key1'], u'value1')

        # Now, let's modify the existing one, and create a new one
        new_annotations['key1'] = u'value2'
        new_annotations['key2'] = u'value1'

        # Check that annotations were stored correctly and original ones were
        # not overriten
        new_annotations = IAnnotations(wc)
        self.assertEqual(new_annotations['key1'], u'value2')
        self.assertEqual(new_annotations['key2'], u'value1')

        obj_annotations = IAnnotations(self.s1)
        self.assertEqual(obj_annotations['key1'],  u'value1')
        self.assertFalse('key2' in obj_annotations)

        # Now, we do a checkin
        policy = ICheckinCheckoutPolicy(wc)
        policy.checkin(u'Commit message')

        # And finally check that the old object has the same annotations as
        # its working copy

        obj_annotations = IAnnotations(self.s1)
        self.assertTrue('key1' in obj_annotations)
        self.assertTrue('key2' in obj_annotations)
        self.assertEqual(obj_annotations['key1'], u'value2')
        self.assertEqual(obj_annotations['key2'], u'value1')
开发者ID:hatchddigital,项目名称:plone.app.iterate,代码行数:50,代码来源:test_annotations.py

示例6: checkout_object

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
    def checkout_object(self, fileobj, related, mimetype):
        """Replaces the content of uploaded file/image at the working copy
        of the related object
        """
        control = getMultiAdapter(
            (related, self.context.REQUEST), name=u"iterate_control")
        policy = ICheckinCheckoutPolicy(related)
        working_copies = related.getBRefs(WorkingCopyRelation.relationship)
        if control.checkout_allowed():
            folder = related.aq_parent
            working_copy = policy.checkout(folder)
        elif working_copies:
            working_copy = working_copies[0]
        else:
            raise Exception(u"Can't obtain working copy.")

        working_copy.update_data(fileobj, mimetype)
        working_copy.reindexObject()
        return '/'.join(related.getPhysicalPath())
开发者ID:enfold,项目名称:collective.z3cform.referenceupload,代码行数:21,代码来源:datamanager.py

示例7: do_checkout

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
 def do_checkout(self, obj):
     policy = ICheckinCheckoutPolicy(obj)
     working_copy = policy.checkout(self.folder)
     return working_copy
开发者ID:abstract-open-solutions,项目名称:plone.app.stagingbehavior,代码行数:6,代码来源:test_relations.py

示例8: serviceDescriptionUpdated

# 需要导入模块: from plone.app.iterate.interfaces import ICheckinCheckoutPolicy [as 别名]
# 或者: from plone.app.iterate.interfaces.ICheckinCheckoutPolicy import checkout [as 别名]
def serviceDescriptionUpdated(event):
    context = event.object
    updated_text = event.updated_text
    data = event.data
    old_national_text = context.getRawNationalText().decode('utf-8')
    old_text = context.getRawText().decode('utf-8')

    parent_folder = aq_parent(context)
    policy = ICheckinCheckoutPolicy(context)
    wc = policy.checkout(parent_folder)
    context.reindexObject('review_state')

    dmp = diff_match_patch()
    current_patch = dmp.patch_make(old_national_text, old_text)
    updated_text_patch = dmp.patch_make(old_national_text, updated_text)
    final_patch = current_patch + updated_text_patch
    new_text, success = dmp.patch_apply(final_patch, old_national_text)
    if False in success:
        # XXX
        # We need to handle the possibility of patching failing
        return
    wc.setNationalText(updated_text)
    wc.setText(new_text)
    if data:
        wc.setTitle(data['title'])
        wc.setDescription(data['description'])

    logger.info("Patched Service Description %s at %s" % \
        (context.Title(), context.absolute_url()))

    # Send notification
    creator = context.Creator()
    pm = getToolByName(context, 'portal_membership')
    creator = pm.getMemberById(creator)
    mail_to = None
    if creator is not None:
        mail_to = creator.getProperty('email')
    if not mail_to:
        registry = getUtility(IRegistry)
        mail_to = registry['jarn.kommuner.notifyEmail']
    if not mail_to:
        return

    request = context.REQUEST
    site_title = context.portal_properties.site_properties.title
    mail_template = getMultiAdapter((context, request),
                                    name='sd_mail')
    mail_text = mail_template(
                         sd_title=wc.Title(),
                         sd_url=wc.absolute_url(),
                         site_title=site_title,
                         charset='utf-8')

    portal_state = getMultiAdapter((context, request),
                                   name=u"plone_portal_state")
    portal = portal_state.portal()
    mail_from = portal.getProperty('email_from_address')
    mail_host = getToolByName(context, 'MailHost')

    try:
        mail_host.send(mail_text.encode('utf-8'), mto=mail_to, mfrom=mail_from,
                       subject='Service Update', charset='utf-8', msg_type=None)
    except (MailHostError, SMTPException, socket.error):
        logger.error(
            """mail error: Attempt to send mail failed.\n%s""" %
            traceback.format_exc())
开发者ID:Jarn,项目名称:jarn.kommuner,代码行数:68,代码来源:subscribers.py


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