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


Python IDossierMarker.providedBy方法代码示例

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


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

示例1: containing_subdossier

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
def containing_subdossier(obj):
    """Returns the title of the subdossier the object is contained in,
    unless it's contained directly in the root of a dossier, in which
    case an empty string is returned.
    """
    context = aq_inner(obj)
    # Only compute for types that actually can be contained in a dossier
    if not context.portal_type in ['opengever.document.document',
                                   'opengever.task.task',
                                   'ftw.mail.mail']:
        return ''

    parent = context
    parent_dossier = None
    parent_dossier_found = False
    while not parent_dossier_found:
        parent = aq_parent(parent)
        if ISiteRoot.providedBy(parent):
            # Shouldn't happen, just to be safe
            break
        if IDossierMarker.providedBy(parent):
            parent_dossier_found = True
            parent_dossier = parent

    if IDossierMarker.providedBy(aq_parent(parent_dossier)):
        # parent dossier is a subdossier
        return parent_dossier.Title()
    return ''
开发者ID:hellfish2,项目名称:opengever.core,代码行数:30,代码来源:indexers.py

示例2: containing_subdossier

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
def containing_subdossier(obj):
    """Returns the title of the subdossier the object is contained in,
    unless it's contained directly in the root of a dossier, in which
    case an empty string is returned.
    """
    if obj.portal_type not in TYPES_WITH_CONTAINING_SUBDOSSIER_INDEX:
        return ''

    context = aq_inner(obj)

    parent = context
    parent_dossier = None
    parent_dossier_found = False
    while not parent_dossier_found:
        parent = aq_parent(parent)
        if ISiteRoot.providedBy(parent):
            # Shouldn't happen, just to be safe
            break
        if IDossierMarker.providedBy(parent):
            parent_dossier_found = True
            parent_dossier = parent

    if IDossierMarker.providedBy(aq_parent(parent_dossier)):
        # parent dossier is a subdossier
        return parent_dossier.Title()
    return ''
开发者ID:4teamwork,项目名称:opengever.core,代码行数:28,代码来源:indexers.py

示例3: test_one_of_the_parents_of_content_needs_to_be_a_dossier

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def test_one_of_the_parents_of_content_needs_to_be_a_dossier(self):
        self.login(self.regular_user)
        self.assertTrue(IDossierMarker.providedBy(aq_parent(self.document)))
        self.assertTrue(can_access_archival_file_form(self.regular_user, self.document))

        self.assertFalse(IDossierMarker.providedBy(aq_parent(self.taskdocument)))
        self.assertTrue(can_access_archival_file_form(self.regular_user, self.taskdocument))

        self.login(self.administrator)
        self.assertFalse(can_access_archival_file_form(self.administrator, self.inbox_document))
开发者ID:4teamwork,项目名称:opengever.core,代码行数:12,代码来源:test_archival_file_form.py

示例4: object_moved_or_added

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
def object_moved_or_added(context, event):
    if isinstance(event, ObjectAddedEvent):
        # Don't consider moving or removing an object a "touch". Mass-moves
        # would immediately fill up the touched log, and removals should not
        # be tracked anyway.
        if should_track_touches(context):
            notify(ObjectTouchedEvent(context))

    if IObjectRemovedEvent.providedBy(event):
        return

    # Update object security after moving or copying.
    # Specifically, this is needed for the case where an object is moved out
    # of a location where a Placeful Workflow Policy applies to a location
    # where it doesn't.
    #
    #  Plone then no longer provides the placeful workflow for that object,
    # but doesn't automatically update the object's security.
    #
    # We use ftw.upgrade's update_security_for() here to correctly
    # recalculate security, but do the reindexing ourselves because otherwise
    # Plone will do it recursively (unnecessarily so).
    changed = update_security_for(context, reindex_security=False)
    if changed:
        reindex_object_security_without_children(context)

    # There are several indices that need updating when a dossier is moved.
    # first make sure obj was actually moved and not created
    if not event.oldParent or not event.newParent:
        return

    # When an object is moved, its containing_dossier needs reindexing.
    to_reindex = ['containing_dossier']
    # containing_subdossier is really only used for documents,
    # while is_subdossier is only meaningful for dossiers.
    if IDossierMarker.providedBy(context):
        was_subdossier = IDossierMarker.providedBy(event.oldParent)
        is_subdossier = IDossierMarker.providedBy(event.newParent)
        if was_subdossier != is_subdossier:
            to_reindex.append('is_subdossier')

    if context.portal_type in TYPES_WITH_CONTAINING_SUBDOSSIER_INDEX:
        to_reindex.append('containing_subdossier')

    context.reindexObject(idxs=to_reindex)

    # synchronize with model if necessary
    if ITask.providedBy(context):
        sync_task(context, event)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:51,代码来源:handlers.py

示例5: isSubdossierIndexer

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
def isSubdossierIndexer(obj):
    # TODO: should be replaced with the is_subdossier method
    # from og.dossier.base.py
    parent = aq_parent(aq_inner(obj))
    if IDossierMarker.providedBy(parent):
        return True
    return False
开发者ID:hellfish2,项目名称:opengever.core,代码行数:9,代码来源:indexers.py

示例6: move_repository_reference_mappings

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def move_repository_reference_mappings(self, obj):
        intids = getUtility(IIntIds)
        annotations = IAnnotations(obj)

        if annotations and annotations.get(CHILD_REF_KEY):
            repository_mapping = PersistentDict(
                {CHILD_REF_KEY: {},
                 PREFIX_REF_KEY: {}})
            dossier_mapping = PersistentDict(
                {CHILD_REF_KEY: {},
                 PREFIX_REF_KEY: {}})

            for number, intid in annotations.get(CHILD_REF_KEY).items():
                try:
                    child = intids.getObject(intid)
                except KeyError:
                    # the object with this intid does not longer exist.
                    continue

                if IDossierMarker.providedBy(child):
                    dossier_mapping[CHILD_REF_KEY][number] = intid
                    dossier_mapping[PREFIX_REF_KEY][intid] = number
                else:
                    repository_mapping[CHILD_REF_KEY][number] = intid
                    repository_mapping[PREFIX_REF_KEY][intid] = number

            # save mapping
            annotations[REPOSITORY_FOLDER_KEY] = repository_mapping
            annotations[DOSSIER_KEY] = dossier_mapping

            # drop old mapings
            annotations.pop(CHILD_REF_KEY)
            annotations.pop(PREFIX_REF_KEY)
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:35,代码来源:to2601.py

示例7: _construct_object

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def _construct_object(self, container, item):
        portal_type = item['_type']
        fti = self._get_fti(portal_type)
        title_args = self._get_title_args(fti, item)

        with NoDossierReferenceNumbersIssued():
            # Create the object without automatically issuing a
            # reference number - we might want to set it explicitly
            obj = createContentInContainer(
                container, portal_type, **title_args)

            if IDossierMarker.providedBy(obj):
                prefix_adapter = IReferenceNumberPrefix(container)
                if not prefix_adapter.get_number(obj):
                    # Set the local reference number part for the
                    # dossier if provided in item, otherwise have
                    # the adapter issue the next one
                    local_refnum = item.get('reference_number')
                    if local_refnum is not None:
                        prefix_adapter.set_number(obj, local_refnum)
                    else:
                        prefix_adapter.set_number(obj)

        self._set_guid(obj, item)
        return obj
开发者ID:4teamwork,项目名称:opengever.core,代码行数:27,代码来源:constructor.py

示例8: is_locked

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def is_locked(self, recursive=True):
        """Determine whether a dossier currently is resolve locked.

        By default also considers a subdossier locked if any of its parent
        dossiers have a lock on them.

        If recursive=False is given, only the current dossier is checked for
        a lock (cheaper, this is used to display the state in the byline).

        If a lock exists (somewhere) but is older than RESOLVE_LOCK_LIFETIME,
        it is considered expired and treated as if it wouldn't exist.
        """
        item = self.context

        while IDossierMarker.providedBy(item):

            lockinfo = self.get_lockinfo(item)
            if lockinfo is not None and not self.is_expired(lockinfo):
                self.log("%s is resolve locked via lock on %r" % (self.context, item))
                return True

            if not recursive:
                return False

            item = aq_parent(item)

        return False
开发者ID:4teamwork,项目名称:opengever.core,代码行数:29,代码来源:resolve_lock.py

示例9: replace_interactive_user

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def replace_interactive_user(self, principal):
        """Replaces interactive users in the principal.
        """

        if principal == 'responsible':
            # find the dossier
            dossier = self.context
            while not IDossierMarker.providedBy(dossier):
                if IPloneSiteRoot.providedBy(dossier):
                    raise ValueError('Could not find dossier')
                dossier = aq_parent(aq_inner(dossier))
            # get the responsible of the dossier
            wrapped_dossier = IDossier(dossier)
            return wrapped_dossier.responsible

        elif principal == 'current_user':
            # get the current user
            mtool = getToolByName(self.context, 'portal_membership')
            member = mtool.getAuthenticatedMember()
            if not member:
                raise Unauthorized()
            return member.getId()

        else:
            return principal
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:27,代码来源:form.py

示例10: is_allowed

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def is_allowed(self):
        """Perform the necessary checks to determine whether pasting is
        allowed / possible on the current context.
        """
        # Check whether pasting is allowed at all for the container type
        if self.context.portal_type in self.disabled_types:
            return False

        # XXX implement me in a more object oriented manner, i.e. by
        # implementing `is_pasting_allowed` for all our content types.
        if IDossierMarker.providedBy(self.context):
            if not self.context.is_open():
                return False

        objs = Clipboard(self.request).get_objs()
        if not objs:
            # Clipboard empty
            return False

        # Check whether there's an object in the clipboard whose type
        # is not allowed to be added to the container
        for obj in objs:
            if obj.portal_type not in self.allowed_content_types:
                return False

        return self.validate_private_folder_pasting(objs)
开发者ID:lukasgraf,项目名称:opengever.core,代码行数:28,代码来源:pasting_allowed.py

示例11: raise_invalid

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def raise_invalid(self):
        if IDossierMarker.providedBy(self.context):
            mail_address = IEmailAddress(
                self.request).get_email_for_object(self.context)
        else:
            parent = aq_parent(aq_inner(self.context))
            mail_address = IEmailAddress(
                self.request).get_email_for_object(parent)

        # Remove widget value in order to disable that the widget renders
        # radio-buttons (nochange/remove/replace) once a file has been
        # uploaded.
        # This is a special case since we are an additional validator
        # for the file field that may block an otherwise valid file upload.
        # The widget does not expect this to happen though.
        if getattr(self.view.parentForm, '_nullify_file_on_error', False):
            self.widget.value = None

        raise Invalid(_(
            u'error_mail_upload',
            default=(u"It's not possible to add E-mails here, please "
            "send it to ${mailaddress} or drag it to the dossier "
            "(Dragn'n'Drop)."),
            mapping={'mailaddress': mail_address}
            ))
开发者ID:lukasgraf,项目名称:opengever.core,代码行数:27,代码来源:document.py

示例12: allowedContentTypes

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
    def allowedContentTypes(self, *args, **kwargs):
        types = super(
            DossierContainer, self).allowedContentTypes(*args, **kwargs)
        # calculate depth
        depth = 0
        obj = self
        while IDossierMarker.providedBy(obj):
            depth += 1
            obj = aq_parent(aq_inner(obj))
            if IPloneSiteRoot.providedBy(obj):
                break

        # the adapter decides
        def filter_type(fti):
            # first we try the more specific one ...
            decider = queryMultiAdapter((self.REQUEST, self, fti),
                                    IConstrainTypeDecider,
                                    name=fti.portal_type)
            if not decider:
                # .. then we try the more general one
                decider = queryMultiAdapter((self.REQUEST, self, fti),
                                        IConstrainTypeDecider)
            if decider:
                return decider.addable(depth)
            # if we don't have an adapter, we just allow it
            return True
        # filter
        return filter(filter_type, types)
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:30,代码来源:base.py

示例13: _add_descendants

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
 def _add_descendants(self):
     objs = self.obj.objectValues()
     for obj in objs:
         if IDossierMarker.providedBy(obj):
             self.dossiers[obj.UID()] = Dossier(obj)
         elif IDocumentSchema.providedBy(obj):
             self.documents[obj.UID()] = Document(obj)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:9,代码来源:dossier.py

示例14: check_dossier_nesting

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
def check_dossier_nesting(portal, options):
    """Find all Dossiers that are nested 3 levels or more (sub-sub-dossiers).
    """
    catalog = getToolByName(portal, 'portal_catalog')
    dossiers = catalog(object_provides=IDossierMarker.__identifier__)

    for brain in dossiers:
        obj = brain.getObject()
        subdossiers = [c for c in obj.getChildNodes()
                       if IDossierMarker.providedBy(c)]

        for subdossier in subdossiers:
            if subdossier.get_subdossiers() != []:
                badly_nested_dossiers = [c for c in subdossier.getChildNodes()
                                         if IDossierMarker.providedBy(c)]
                print badly_nested_dossiers
开发者ID:4teamwork,项目名称:opengever.maintenance,代码行数:18,代码来源:check_dossier_nesting.py

示例15: _add_descendants

# 需要导入模块: from opengever.dossier.behaviors.dossier import IDossierMarker [as 别名]
# 或者: from opengever.dossier.behaviors.dossier.IDossierMarker import providedBy [as 别名]
 def _add_descendants(self):
     objs = self.obj.objectValues()
     for obj in objs:
         if IDossierMarker.providedBy(obj):
             self.dossiers.append(Dossier(obj, self.path))
         elif IBaseDocument.providedBy(obj) and obj.get_file():
             self.documents.append(Document(obj, self.path))
开发者ID:4teamwork,项目名称:opengever.core,代码行数:9,代码来源:model.py


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