Ejemplo n.º 1
0
    def tearDown(self):
        from woost import app
        from woost.models import staticpublication
        from woost.models.trigger import set_triggers_enabled

        app.installation_id = self.__prev_installation_id
        set_triggers_enabled(self.__prev_triggers_enabled)

        TempStorageMixin.tearDown(self)
Ejemplo n.º 2
0
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail import schema
        from cocktail.persistence import PersistentObject

        class A(PersistentObject):

            full_text_indexed = True

            text = schema.String()

            child = schema.Reference(bidirectional=True, text_search=True)

            irrelevant_child = schema.Reference(bidirectional=True)

        class B(PersistentObject):

            full_text_indexed = True

            text = schema.String()

            parent = schema.Reference(bidirectional=True)

            children = schema.Collection(bidirectional=True, text_search=True)

        class C(PersistentObject):

            full_text_indexed = True

            text = schema.String()

            parent = schema.Reference(bidirectional=True)

        class Z(PersistentObject):

            text = schema.String()

            parent = schema.Reference(bidirectional=True)

        A.child.type = B
        B.parent.type = A
        B.children.items = schema.Reference(type=C)
        C.parent.type = B
        A.irrelevant_child.type = Z
        Z.parent.type = A

        self.A = A
        self.B = B
        self.C = C
        self.Z = Z
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail import schema
        from cocktail.persistence import PersistentObject

        class TestObject(PersistentObject):

            test_collection = schema.Collection(items=schema.String(),
                                                indexed=True)

        self.TestObject = TestObject
Ejemplo n.º 4
0
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail.schema import String
        from cocktail.persistence import PersistentObject

        class TestObject(PersistentObject):

            full_text_indexed = True

            test_field = String(translated=True, full_text_indexed=True)

        self.test_type = TestObject
Ejemplo n.º 5
0
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail.schema import String, Reference, Collection
        from cocktail.persistence import PersistentObject

        class TestObject(PersistentObject):
            test_field = String(unique=True, indexed=True)
            test_ref = Reference()
            test_collection = Collection()
            test_translated_field = String(indexed=True, translated=True)

        self.test_type = TestObject
Ejemplo n.º 6
0
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail.schema import String
        from cocktail.persistence import PersistentObject

        class Foo(PersistentObject):
            spam = String(unique=True, indexed=True)

        class Bar(Foo):
            pass

        self.Foo = Foo
        self.Bar = Bar
Ejemplo n.º 7
0
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail.schema import String, Reference, Collection
        from cocktail.persistence import PersistentObject

        class TestObject(PersistentObject):
            test_field = String(
                unique = True,
                indexed = True
            )
            parent = Reference(bidirectional = True)
            children = Collection(bidirectional = True)

        TestObject.parent.type = TestObject
        TestObject.children.items = Reference(type = TestObject)
        self.test_type = TestObject
Ejemplo n.º 8
0
    def setUp(self):
        TempStorageMixin.setUp(self)

        from cocktail.schema import Reference, Collection
        from cocktail.persistence import PersistentObject, datastore

        datastore.root.clear()

        class Document(PersistentObject):
            parent = Reference(
                bidirectional = True,
                related_key = "children"
            )
            children = Collection(
                bidirectional = True,
                related_key = "parent"
            )

            extension = Reference(
                bidirectional = True,
                related_key = "extended"
            )
            extended = Reference(
                bidirectional = True,
                related_key = "extension"
            )

            improvement = Reference()
            related_documents = Collection()

        Document.extension.type = Document
        Document.extended.type = Document
        Document.parent.type = Document
        Document.children.items = Reference(type = Document)
        Document.improvement.type = Document
        Document.related_documents.items = Reference(type = Document)

        self.Document = Document
    def setUp(self):

        TempStorageMixin.setUp(self)

        from cocktail import schema
        from cocktail.persistence import PersistentObject

        class Document(PersistentObject):

            instance_count = 0

            def __init__(self, *args, **kwargs):
                PersistentObject.__init__(self, *args, **kwargs)
                self.__class__.instance_count += 1
                self.number = self.instance_count

            def __repr__(self):
                return "Document %d" % self.number

        class Tag(PersistentObject):

            instance_count = 0

            documents = schema.Collection(
                items=schema.Reference(type=Document),
                related_end=schema.Collection("tags", indexed=True),
                indexed=True)

            def __init__(self, *args, **kwargs):
                PersistentObject.__init__(self, *args, **kwargs)
                self.__class__.instance_count += 1
                self.number = self.instance_count

            def __repr__(self):
                return "Tag %d" % self.number

        self.Document = Document
        self.Tag = Tag
Ejemplo n.º 10
0
    def setUp(self):

        from woost import app
        from woost.models import Configuration, User, Role
        from woost.models.trigger import get_triggers_enabled, set_triggers_enabled
        from woost.controllers.installer import Installer

        self.__prev_installation_id = app.installation_id
        self.__prev_triggers_enabled = get_triggers_enabled()
        app.installation_id = "TEST"
        set_triggers_enabled(False)

        TempStorageMixin.setUp(self)

        app.root = os.path.join(self._temp_dir, "test_project")
        installer = Installer()
        installer.create_project({"project_path": app.root})

        # Configuration
        self.config = Configuration(qname = "woost.configuration")
        self.config.insert()

        # Roles and users
        self.anonymous_role = Role(qname = "woost.anonymous")
        self.anonymous_role.insert()

        self.anonymous_user = User(qname = "woost.anonymous_user")
        self.anonymous_user.roles.append(self.anonymous_role)
        self.anonymous_user.insert()

        self.everybody_role = Role(qname = "woost.everybody")
        self.everybody_role.insert()

        self.authenticated_role = Role(qname = "woost.authenticated")
        self.authenticated_role.insert()
       
        set_triggers_enabled(True)
Ejemplo n.º 11
0
 def setUp(self):
     TempStorageMixin.setUp(self)