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


Python globalrequest.getRequest函数代码示例

本文整理汇总了Python中zope.globalrequest.getRequest函数的典型用法代码示例。如果您正苦于以下问题:Python getRequest函数的具体用法?Python getRequest怎么用?Python getRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _recursive_rename

    def _recursive_rename(self, obj):
        """Recursively rename object and its children.

        Children are renamed/moved postorder, i.e. children are renamed before
        their parents. This is important to avoid race-conditions with the
        move optimization from ftw.copymovepatches:

        - When moving multiple items plone dispatches the move event to
          children in an event handler. This event handler is registered
          earlier than the handler from `ftw.copymovepatches`. Thus it is
          called before the parent item is "moved" in the catalog by
          `ftw.copymovepatches`.
        - The optimization in `ftw.copymovepatches` trips up if one of the
          children somehow cause their parent to be reindexed while it is
          moved as the catalog then treats it as a new entry.

        """
        # We update the docproperties only when renaming a document
        # not when renaming the containing dossiers
        if IBaseDocument.providedBy(obj):
            getRequest().set(DISABLE_DOCPROPERTY_UPDATE_FLAG, False)
        else:
            getRequest().set(DISABLE_DOCPROPERTY_UPDATE_FLAG, True)

        for child in obj.getFolderContents():
            self._recursive_rename(child.getObject())
        return api.content.rename(obj, new_id=self.get_new_id(obj))
开发者ID:4teamwork,项目名称:opengever.core,代码行数:27,代码来源:paste.py

示例2: ticket_title_generator

def ticket_title_generator(obj):
    """Generate a title for the ticket, also using event information.
    """

    event = obj
    ret = {
        'title': obj.title, 'eventtitle': '', 'eventstart': '', 'eventend': ''
    }

    if ITicketOccurrence.providedBy(event):
        event = aq_parent(aq_parent(event))
        # Traverse to the Occurrence object
        if IATEvent.providedBy(event):
            # get the request out of thin air to be able to publishTraverse to
            # the transient Occurrence object.
            traverser = OccTravAT(event, getRequest())
        elif IDXEvent.providedBy(event):
            # TODO
            traverser = OccTravDX(event, getRequest())
        else:
            raise NotImplementedError(
                u"There is no event occurrence traverser implementation for "
                u"this kind of object."
            )
        try:
            event = traverser.publishTraverse(getRequest(), obj.id)
        except KeyError:
            # Maybe the ticket occurrence isn't valid anymore because the
            # event occurence doesn't exist anymore.
            # Just ignore that case.
            return ret

    elif ITicket.providedBy(event):
        event = aq_parent(event)

    if IEvent.providedBy(event) or IOccurrence.providedBy(event):
        acc = IEventAccessor(event)
        lstart = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        lend = ulocalized_time(
            DT(acc.start),
            long_format=True,
            context=event
        )
        # XXX: no unicode, store as utf-8 encoded string instead
        ret = dict(
            title=u'%s - %s (%s - %s)' % (
                safe_unicode(acc.title),
                safe_unicode(obj.title),
                lstart,
                lend,
            ),
            eventtitle=acc.title,
            eventstart=acc.start,
            eventend=acc.end,
        )
    return ret
开发者ID:bluedynamics,项目名称:bda.plone.ticketshop,代码行数:60,代码来源:common.py

示例3: wrapper

    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)

        except (WrongAgendaItemState, CannotExecuteTransition):
            return JSONResponse(getRequest()).error(
                _(u'invalid_agenda_item_state',
                  default=u'The agenda item is in an invalid state for '
                           'this action.'),
                status=403).dump()

        except Forbidden:
            return JSONResponse(getRequest()).error(
                _(u'editing_not_allowed',
                  default=u'Editing is not allowed.'),
                status=403).dump()

        except MissingMeetingDossierPermissions:
            return JSONResponse(getRequest()).error(
                _('error_no_permission_to_add_document',
                  default=u'Insufficient privileges to add a '
                          u'document to the meeting dossier.'),
                status=403).dump()

        except MissingAdHocTemplate:
            return JSONResponse(getRequest()).error(
                _('missing_ad_hoc_template',
                  default=u"No ad-hoc agenda-item template has been "
                          u"configured."),
                status=501).dump()

        except SablonProcessingFailed:
            return JSONResponse(getRequest()).error(
                _('Error while processing Sablon template'),
                status=500).dump()
开发者ID:4teamwork,项目名称:opengever.core,代码行数:35,代码来源:agendaitem.py

示例4: test_isolate_globalrequest

    def test_isolate_globalrequest(self):
        setRequest(self.layer['request'])

        with isolate_globalrequest():
            self.assertIsNone(None, getRequest())
            setRequest('bar')

        self.assertEquals(self.layer['request'], getRequest())
开发者ID:4teamwork,项目名称:ftw.testbrowser,代码行数:8,代码来源:test_driver_utils.py

示例5: interactive_users

def interactive_users(context):
    yield ('responsible',
           translate(_(u'interactive_user_responsible',
                       default=u'Responsible'),
                     context=getRequest()))
    yield ('current_user',
           translate(_(u'interactive_user_current_user',
                       default=u'Current user'),
                     context=getRequest()))
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:9,代码来源:vocabularies.py

示例6: accept_task_with_successor

def accept_task_with_successor(dossier, predecessor_oguid, response_text):
    predecessor = Task.query.by_oguid(predecessor_oguid)

    # Set the "X-CREATING-SUCCESSOR" flag for preventing the event handler
    # from creating additional responses per added document.
    getRequest().set('X-CREATING-SUCCESSOR', True)

    # Transport the original task (predecessor) to this dossier. The new
    # response and task change is not yet done and will be done later. This
    # is necessary for beeing as transaction aware as possible.
    transporter = Transporter()
    successor = transporter.transport_from(
        dossier, predecessor.admin_unit_id, predecessor.physical_path)
    successor_tc = ISuccessorTaskController(successor)

    # copy documents and map the intids
    doc_transporter = getUtility(ITaskDocumentsTransporter)

    comment = _(u'version_message_accept_task',
               default=u'Document copied from task (task accepted)')
    intids_mapping = doc_transporter.copy_documents_from_remote_task(
        predecessor, successor, comment=comment)

    # copy the responses
    response_transporter = IResponseTransporter(successor)
    response_transporter.get_responses(predecessor.admin_unit_id,
                                       predecessor.physical_path,
                                       intids_mapping=intids_mapping)

    # Move current responsible from predecessor task to successor
    center = notification_center()
    center.add_task_responsible(successor, successor.responsible)

    # First "accept" the successor task..
    accept_task_with_response(successor, response_text)

    transaction.savepoint()
    response_text = response_text or ''
    request_data = {'text': response_text.encode('utf-8'),
                    'successor_oguid': successor_tc.get_oguid()}

    response = dispatch_request(predecessor.admin_unit_id,
                                '@@accept_task_workflow_transition',
                                path=predecessor.physical_path,
                                data=request_data)

    response_body = response.read()
    if response_body.strip() != 'OK':
        raise TaskRemoteRequestError(
            'Adding the response and changing the workflow state on the '
            'predecessor task failed.')

    # Connect the predecessor and the successor task. This needs to be done
    # that late for preventing a deadlock because of the locked tasks table.
    successor_tc.set_predecessor(predecessor_oguid)

    return successor
开发者ID:4teamwork,项目名称:opengever.core,代码行数:57,代码来源:utils.py

示例7: removeFromYouTube

def removeFromYouTube(video):
    if not youtube:
        return api.portal.show_message(
            'Whoops, trying to use YouTube but not configure correctly?',
            request=getRequest())
    api.portal.show_message(
        'Removing video from YouTube. Be patient.',
        request=getRequest())
    _run(video, youtube.removeFromYouTube)
开发者ID:collective,项目名称:wildcard.media,代码行数:9,代码来源:async.py

示例8: render_tree

    def render_tree(self):
        context_path = '/'.join(self.context.getPhysicalPath())
        query_filter = {
            'object_provides': (
                IRepositoryFolder.__identifier__,
                IDossierMarker.__identifier__,
                ),
            'blocked_local_roles': True,
            }

        dossier_container_brains = api.content.find(
            context=self.context, **query_filter)

        if dossier_container_brains:
            title = escape_html(translate(
                _(
                    u'label_blocked_local_roles',
                    default=u'Protected Objects',
                    ),
                context=getRequest(),
                ))

            title_element = u''.join((u'<h1>', title, u'</h1>', ))

            tree = Treeify(
                dossier_container_brains,
                context_path, node_updater,
                )

            # XXX - Preserving the reference number tree order.
            # Sorting here was easier than figuring out the treeifying.
            iterable_children = sorted(
                tree(self.context).get('children', ()),
                key=lambda child: child.get('title', ''),
                )

            rendered_tree = self._build_html_tree(iterable_children)

            garnished_tree = ''.join((
                title_element,
                rendered_tree,
                ))

            return garnished_tree

        title = escape_html(translate(
            _(
                u'label_no_blocked_local_roles',
                default=u'No protected objects were found within this scope.',
                ),
            context=getRequest(),
            ))

        title_element = u''.join((u'<h1>', title, u'</h1>', ))

        return title_element
开发者ID:4teamwork,项目名称:opengever.core,代码行数:56,代码来源:admin_list.py

示例9: interactive_users

def interactive_users():
    return {
        'responsible': translate(_(u'interactive_user_responsible',
                                   default=u'Responsible'),
                                 context=getRequest()),

        'current_user': translate(_(u'interactive_user_current_user',
                                    default=u'Current user'),
                                  context=getRequest())
    }
开发者ID:4teamwork,项目名称:opengever.core,代码行数:10,代码来源:sources.py

示例10: uploadToYouTube

def uploadToYouTube(video):
    if not youtube:
        return api.portal.show_message(
            'Whoops, trying to use YouTube but not configure correctly?',
            request=getRequest())
    api.portal.show_message(
        'Uploading video to YouTube. Check YouTube for status. '
        'Be patient while YouTube processes.',
        request=getRequest())
    _run(video, youtube.uploadToYouTube)
开发者ID:collective,项目名称:wildcard.media,代码行数:10,代码来源:async.py

示例11: queue_conversion

    def queue_conversion(self):
        self.set_state(STATE_CONVERTING)
        IBumblebeeServiceV3(getRequest()).queue_conversion(
            self.document, PROCESSING_QUEUE,
            self.get_callback_url(), target_format='pdf/a')

        annotations = IAnnotations(getRequest())
        if ARCHIVAL_FILE_CONVERSION_QUEUE_KEY not in annotations:
            annotations[ARCHIVAL_FILE_CONVERSION_QUEUE_KEY] = []
        annotations[ARCHIVAL_FILE_CONVERSION_QUEUE_KEY].append(self.document_intid)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:10,代码来源:archival_file.py

示例12: resourceDirectorySubDirectoriesSource

def resourceDirectorySubDirectoriesSource(context):
    # Our context is portal root, because z3c.form would not work otherwise
    try:
        context = getRequest()['PUBLISHED'].form_instance.directory
    except AttributeError:
        # For InlineValidationView
        context = getRequest()['PUBLISHED'].context.form_instance.directory
    files = context.listDirectory()
    directories = [path for path in files
                   if context.isDirectory(path)]
    return SimpleVocabulary(map(SimpleTerm, map(str, directories)))
开发者ID:collective,项目名称:collective.themesitesetup,代码行数:11,代码来源:browser.py

示例13: handleApply

 def handleApply(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     changes = self.applyChanges(data)
     if changes:
         api.portal.show_message(self.successMessage, getRequest())
     else:
         api.portal.show_message(self.noChangesMessage, getRequest())
     return self.request.RESPONSE.redirect(self.main_url)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:11,代码来源:forms.py

示例14: create

        def create(*args, **kwargs):
            request = getRequest()
            if request is not None:
                alsoProvides(request, IDuringContentCreation)

            result = original_create(*args, **kwargs)

            request = getRequest()
            if request is not None:
                noLongerProvides(request, IDuringContentCreation)

            return result
开发者ID:4teamwork,项目名称:opengever.core,代码行数:12,代码来源:default_values.py

示例15: _fixup

    def _fixup(self):
        # due to compatibility reasons this method fixes data structure
        # for old Taxonomy instances.
        # XXX: remove this in version 2.0 to prevent write on read
        if self.order is None:
            safeWrite(self, getRequest())
            self.order = PersistentDict()
            self.count = PersistentDict()

        if self.version is None:
            safeWrite(self, getRequest())
            self.version = PersistentDict()
开发者ID:collective,项目名称:collective.taxonomy,代码行数:12,代码来源:utility.py


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