Esempio n. 1
0
    def storage(self):
        obj = self.config.get_annotated_object()
        ann = IAnnotations(obj)

        key = self.config.get_annotations_key()
        if key not in ann.keys():
            ann[key] = PersistentDict()

        return ann[key]
Esempio n. 2
0
    def storage(self):
        obj = self.config.get_annotated_object()
        ann = IAnnotations(obj)

        key = self.config.get_annotations_key()
        if key not in ann.keys():
            ann[key] = PersistentDict()

        return ann[key]
    def is_convertible(self):
        """
          Check if the context is convertible (hopefully).
        """
        # collective.documentviewer add an entry to the annotations
        annotations = IAnnotations(self.context)
        if 'collective.documentviewer' not in annotations.keys():
            Settings(self.context)

        settings = GlobalSettings(api.portal.get())
        return allowedDocumentType(self.context,
                                   settings.auto_layout_file_types)
    def test_add_expects_response_objects(self):
        self.login(self.workspace_member)

        annotations = IAnnotations(self.todo)
        self.assertNotIn(ResponseContainer.ANNOTATION_KEY, annotations.keys())

        container = IResponseContainer(self.todo)
        with self.assertRaises(ValueError):
            container.add(object())

        storage = annotations[ResponseContainer.ANNOTATION_KEY]
        self.assertEqual([], list(storage.keys()))
    def test_stores_response_in_the_annotations(self):
        self.login(self.workspace_member)

        annotations = IAnnotations(self.todo)
        self.assertNotIn(ResponseContainer.ANNOTATION_KEY, annotations.keys())

        response = Response()
        container = IResponseContainer(self.todo)
        container.add(response)

        storage = annotations[ResponseContainer.ANNOTATION_KEY]
        self.assertEqual([response], list(storage.values()))
Esempio n. 6
0
    def logout(self):
        """
        Delete any cached localrole information from the request.
        """
        super(TestGroupspaceBehavior, self).logout()
        annotations = IAnnotations(self.request)
        keys_to_remove = []
        for key in annotations.keys():
            if (isinstance(key, basestring)
                    and key.startswith('borg.localrole')):
                keys_to_remove.append(key)

        for key in keys_to_remove:
            annotations.pop(key)
Esempio n. 7
0
    def logout(self):
        """
        Delete any cached localrole information from the request.
        """
        super(TestCasePermissioningTodos, self).logout()
        annotations = IAnnotations(self.request)
        keys_to_remove = []
        for key in annotations.keys():
            if (isinstance(key, basestring)
                    and key.startswith('borg.localrole')):
                keys_to_remove.append(key)
            if (isinstance(key, tuple) and key[0] == 'workspaces'):
                keys_to_remove.append(key)

        for key in keys_to_remove:
            annotations.pop(key)
Esempio n. 8
0
    def _storage(self, create_if_missing=False):
        ann = IAnnotations(self.context)
        if self.ANNOTATION_KEY not in ann.keys() and create_if_missing:
            ann[self.ANNOTATION_KEY] = LOBTree()

        return ann.get(self.ANNOTATION_KEY, None)