コード例 #1
0
ファイル: touched.py プロジェクト: 4teamwork/opengever.core
    def ensure_log_initialized(self, user_id):
        ann = unprotected_write(IAnnotations(self.portal))
        if RECENTLY_TOUCHED_KEY not in ann:
            ann[RECENTLY_TOUCHED_KEY] = unprotected_write(OOBTree())

        if user_id not in ann[RECENTLY_TOUCHED_KEY]:
            ann[RECENTLY_TOUCHED_KEY][user_id] = unprotected_write(PersistentList())
コード例 #2
0
    def ensure_log_initialized(self, user_id):
        ann = unprotected_write(IAnnotations(self.portal))
        if RECENTLY_TOUCHED_KEY not in ann:
            ann[RECENTLY_TOUCHED_KEY] = unprotected_write(OOBTree())

        if user_id not in ann[RECENTLY_TOUCHED_KEY]:
            ann[RECENTLY_TOUCHED_KEY][user_id] = unprotected_write(
                PersistentList())
コード例 #3
0
    def _retrieve_version(self, context, version_id):
        try:
            # CMFEditions causes writes to the parent when retrieving versions
            unprotected_write(aq_parent(context))
            return Versioner(context).retrieve(version_id)

        except ArchivistRetrieveError:
            # Version does not exists.
            raise NotFound
コード例 #4
0
ファイル: overlay.py プロジェクト: lukasgraf/opengever.core
    def _retrieve_version(self, context, version_id):
        try:
            # CMFEditions causes writes to the parent when retrieving versions
            unprotected_write(aq_parent(context))
            return Versioner(context).retrieve(version_id)

        except ArchivistRetrieveError:
            # Version does not exists.
            raise NotFound
コード例 #5
0
    def annotations(self):
        annotations = unprotected_write(IAnnotations(self.context))
        if ANNOTATION_KEY not in annotations:
            annotations[ANNOTATION_KEY] = OOBTree()

        unprotected_write(annotations[ANNOTATION_KEY])
        if self.username not in annotations[ANNOTATION_KEY]:
            annotations[ANNOTATION_KEY][self.username] = PersistentList()

        return unprotected_write(annotations[ANNOTATION_KEY][self.username])
コード例 #6
0
    def annotations(self):
        annotations = unprotected_write(IAnnotations(self.context))
        if ANNOTATION_KEY not in annotations:
            annotations[ANNOTATION_KEY] = OOBTree()

        unprotected_write(annotations[ANNOTATION_KEY])
        if self.username not in annotations[ANNOTATION_KEY]:
            annotations[ANNOTATION_KEY][self.username] = PersistentList()

        return unprotected_write(annotations[ANNOTATION_KEY][self.username])
コード例 #7
0
ファイル: overlay.py プロジェクト: 4teamwork/opengever.core
    def _retrieve_version(self, context, version_id):
        prtool = api.portal.get_tool("portal_repository")

        try:
            # CMFEditions causes writes to the parent when retrieving versions
            unprotected_write(aq_parent(context))
            return prtool.retrieve(context, version_id).object

        except ArchivistRetrieveError:
            # Version does not exists.
            raise NotFound
コード例 #8
0
    def _retrieve_version(self, context, version_id):
        prtool = api.portal.get_tool('portal_repository')

        try:
            # CMFEditions causes writes to the parent when retrieving versions
            unprotected_write(aq_parent(context))
            return prtool.retrieve(context, version_id).object

        except ArchivistRetrieveError:
            # Version does not exists.
            raise NotFound
コード例 #9
0
    def _increment_number(self, portal, key):
        ann = unprotected_write(IAnnotations(portal))
        if SEQUENCE_NUMBER_ANNOTATION_KEY not in ann:
            ann[SEQUENCE_NUMBER_ANNOTATION_KEY] = unprotected_write(
                PersistentDict())

        mapping = unprotected_write(ann.get(SEQUENCE_NUMBER_ANNOTATION_KEY))
        if key not in mapping:
            mapping[key] = 0

        mapping[key] += 1
        return mapping[key]
コード例 #10
0
    def _increment_number(self, portal, key):
        ann = unprotected_write(IAnnotations(portal))
        if SEQUENCE_NUMBER_ANNOTATION_KEY not in ann:
            ann[SEQUENCE_NUMBER_ANNOTATION_KEY] = unprotected_write(
                PersistentDict())

        mapping = unprotected_write(ann.get(SEQUENCE_NUMBER_ANNOTATION_KEY))
        if key not in mapping:
            mapping[key] = 0

        mapping[key] += 1
        return mapping[key]
コード例 #11
0
ファイル: touched.py プロジェクト: 4teamwork/opengever.core
    def rotate(self, user_id):
        """Rotate recently touched log.

        We basically truncate it to the RECENTLY_TOUCHED_LIMIT.

        However, because the display limit only applies to recently touched
        items (not checked out docs), we need to take care to calculate the
        correct cutoff by "ignoring" checked out docs (adding them to the
        cutoff limit).
        """
        num_checked_out = len(self.catalog(checked_out=user_id))
        limit = get_registry_record('limit', IRecentlyTouchedSettings)
        cutoff = limit + num_checked_out
        truncated = unprotected_write(self.get_recently_touched_log(user_id)[:cutoff])
        unprotected_write(IAnnotations(self.portal)[RECENTLY_TOUCHED_KEY])[user_id] = truncated
コード例 #12
0
 def get_number(self, obj):
     ann = unprotected_write(IAnnotations(obj))
     if SEQUENCE_NUMBER_ANNOTATION_KEY not in ann.keys():
         generator = getAdapter(obj, ISequenceNumberGenerator)
         value = generator.generate()
         ann[SEQUENCE_NUMBER_ANNOTATION_KEY] = value
     return ann.get(SEQUENCE_NUMBER_ANNOTATION_KEY)
コード例 #13
0
 def set_sync_stamp(self, stamp, context=None):
     """Update sync stamp with the given value.
     """
     context = self.get_context(context)
     self.annotations = unprotected_write(IAnnotations(context))
     self.annotations['sync_stamp'] = stamp
     logger.info("Stored sync_stamp %s in annotations" % stamp)
コード例 #14
0
    def set_sync_stamp(self, stamp, context=None):
        """update the stamp with the given value"""

        context = self.get_context(context)
        self.annotations = unprotected_write(IAnnotations(context))
        self.annotations['sync_stamp'] = stamp
        logger.info("Stored sync_stamp %s in annotations" % stamp)
コード例 #15
0
    def get_reference_mapping(self, obj=None):
        type_key = self.get_type_key(obj)
        annotations = unprotected_write(IAnnotations(self.context))

        if not type_key in annotations:
            annotations[type_key] = PersistentDict()
        return annotations[type_key]
コード例 #16
0
 def _get_history_for_writing(self):
     """Return the history for writing and make sure a default is also
     initialized if it is the first time the history is accessed.
     """
     return unprotected_write(
         IAnnotations(self.context).setdefault(self.annotation_key,
                                               OOBTree()))
コード例 #17
0
ファイル: adapters.py プロジェクト: lukasgraf/opengever.core
 def __init__(self, context):
     self.context = context
     annotations = unprotected_write(IAnnotations(self.context))
     self.__mapping = annotations.get(self.ANNO_KEY, None)
     if self.__mapping is None:
         self.__mapping = PersistentList()
         annotations[self.ANNO_KEY] = self.__mapping
コード例 #18
0
ファイル: adapters.py プロジェクト: 4teamwork/opengever.core
 def __init__(self, context):
     self.context = context
     annotations = unprotected_write(IAnnotations(self.context))
     self.__mapping = annotations.get(self.ANNO_KEY, None)
     if self.__mapping is None:
         self.__mapping = PersistentList()
         annotations[self.ANNO_KEY] = self.__mapping
コード例 #19
0
 def get_number(self, obj):
     ann = unprotected_write(IAnnotations(obj))
     if SEQUENCE_NUMBER_ANNOTATION_KEY not in ann.keys():
         generator = getAdapter(obj, ISequenceNumberGenerator)
         value = generator.generate()
         ann[SEQUENCE_NUMBER_ANNOTATION_KEY] = value
     return ann.get(SEQUENCE_NUMBER_ANNOTATION_KEY)
コード例 #20
0
    def search_results(self, query):
        # `query` , as generated by `VersionsTab.get_base_query()`,  is
        # actually the object we're displaying the version history for
        obj = query

        # CMFEditions causes writes to the parent when retrieving versions
        unprotected_write(aq_parent(obj))

        shadow_history = Versioner(obj).get_history_metadata()
        manager = getMultiAdapter((obj, self.request), ICheckinCheckoutManager)

        if not shadow_history:
            return NoVersionHistoryMetadataProxy(obj)

        return LazyHistoryMetadataProxy(
            shadow_history, obj.absolute_url(),
            obj, is_revert_allowed=manager.is_revert_allowed())
コード例 #21
0
    def rotate(self, user_id):
        """Rotate recently touched log.

        We basically truncate it to the RECENTLY_TOUCHED_LIMIT.

        However, because the display limit only applies to recently touched
        items (not checked out docs), we need to take care to calculate the
        correct cutoff by "ignoring" checked out docs (adding them to the
        cutoff limit).
        """
        num_checked_out = len(self.catalog(checked_out=user_id))
        limit = get_registry_record('limit', IRecentlyTouchedSettings)
        cutoff = limit + num_checked_out
        truncated = unprotected_write(
            self.get_recently_touched_log(user_id)[:cutoff])
        unprotected_write(IAnnotations(
            self.portal)[RECENTLY_TOUCHED_KEY])[user_id] = truncated
コード例 #22
0
    def search_results(self, query):
        # `query` , as generated by `VersionsTab.get_base_query()`,  is
        # actually the object we're displaying the version history for
        obj = query

        # CMFEditions causes writes to the parent when retrieving versions
        unprotected_write(aq_parent(obj))

        repo_tool = api.portal.get_tool('portal_repository')
        shadow_history = repo_tool.getHistoryMetadata(obj)
        manager = getMultiAdapter((obj, self.request), ICheckinCheckoutManager)

        return LazyHistoryMetadataProxy(
            shadow_history,
            obj.absolute_url(),
            obj,
            is_revert_allowed=manager.is_revert_allowed())
コード例 #23
0
    def purge_mappings(self):
        """Purge all child/prefix-mappings for context.

        This is potentially dangerous and should only be used carefully!
        """

        annotations = unprotected_write(IAnnotations(self.context))
        annotations.pop(REPOSITORY_FOLDER_KEY, None)
        annotations.pop(DOSSIER_KEY, None)
コード例 #24
0
ファイル: touched.py プロジェクト: 4teamwork/opengever.core
 def get_recently_touched_log(self, user_id):
     return unprotected_write(IAnnotations(self.portal)[RECENTLY_TOUCHED_KEY][user_id])
コード例 #25
0
 def _get_history_for_writing(self):
     """Return the history for writing and make sure a default is also
     initialized if it is the first time the history is accessed.
     """
     return unprotected_write(IAnnotations(self.context).setdefault(
         self.annotation_key, OOBTree()))
コード例 #26
0
 def remove_number(self, obj):
     ann = unprotected_write(IAnnotations(obj))
     if SEQUENCE_NUMBER_ANNOTATION_KEY in ann.keys():
         del ann[SEQUENCE_NUMBER_ANNOTATION_KEY]
コード例 #27
0
 def get_recently_touched_log(self, user_id):
     return unprotected_write(
         IAnnotations(self.portal)[RECENTLY_TOUCHED_KEY][user_id])
コード例 #28
0
 def remove_number(self, obj):
     ann = unprotected_write(IAnnotations(obj))
     if SEQUENCE_NUMBER_ANNOTATION_KEY in ann.keys():
         del ann[SEQUENCE_NUMBER_ANNOTATION_KEY]