Lynn Rees avatar Lynn Rees committed 1ae3a95

- snapshot

Comments (0)

Files changed (18)

graphalchemy/backends/apps.py

             node = 'graphalchemy.backends.neo4jem.NodeWrite'
 
 
-appconf = Appconf.build()
+appconf = Appconf.create()

graphalchemy/backends/neo4jem.py

         full text search using index
 
         @param index: name of index
-        @param queries: queries build with query builder
+        @param queries: queries create with query builder
         @param model: element model (default: None)
         '''
         return self.one_or_all(self.index(index).query(queries), model)
 
     def traverser(self, this, tester=None, links=None, unique=None):
         '''
-        build a traverse function
+        create a traverse function
 
         @param this: graph object
         @param tester: filter for traversed elements (default: None)
 
     def traverser(self, this, tester=None, links=None, unique=None):
         '''
-        build a traverse function
+        create a traverse function
 
         @param this: graph object
         @param tester: filter for traversed elements (default: None)
 
     '''neo4j link writer'''
 
-    def build(self, link, start, end, callback=None, **kw):
+    def create(self, link, start, end, callback=None, **kw):
         '''
-        build a new graph link
+        create a new graph link
 
         @param link: link name
         @param start: start node for link
         kind = 'fulltext' if fts else None
         self._db.relationships.indexes.create(index, type=kind)
 
-    def delete_element(self, this, indices=None):
+    def delete(self, this, indices=None):
         '''
         delete graph element
 
 
     def traverser(self, this, tester=None, links=None, unique=None):
         '''
-        build a traverse function
+        create a traverse function
 
         @param this: graph object
         @param tester: filter for traversed elements (default: None)
 
     '''neo4j node writer'''
 
-    def build(self, data, link=None, other=None, callback=None, **kw):
-        '''
-        build a new graph node
-
-        @param link: link name
-        @param start: start node for link
-        @param end: end node for link
-        @param callback: callback function (default: None)
-        @param kw: keywords (default: None)
-        '''
-        # create node
-        node = self._db.node(**data)
-        # link back to reference
-        if link is not None and other is not None:
-            node.rels.create(link, other.source, **kw)
-        if callback is not None:
-            node = callback(node)
-        return node
-
     def clone(self, this, model_link, callback=None, **kw):
         '''
         clone node
             fork = callback(fork)
         return fork
 
+    def create(self, data, link=None, other=None, callback=None, **kw):
+        '''
+        create a new graph node
+
+        @param link: link name
+        @param start: start node for link
+        @param end: end node for link
+        @param callback: callback function (default: None)
+        @param kw: keywords (default: None)
+        '''
+        # create node
+        node = self._db.node(**data)
+        # link back to reference
+        if link is not None and other is not None:
+            node.rels.create(link, other.source, **kw)
+        if callback is not None:
+            node = callback(node)
+        return node
+
     def create_index(self, index, fts=False):
         '''
         create node index
         kind = 'fulltext' if fts else None
         return self._db.nodes.indexes.create(index, type=kind)
 
-    def delete_element(self, this, indices=None):
+    def delete(self, this, indices=None):
         '''
         delete graph element
 

graphalchemy/managers/apps.py

             node = 'graphalchemy.managers.readers.Nodes'
 
 
-appconf = Appconf.build()
+appconf = Appconf.create()

graphalchemy/managers/core.py

+# -*- coding: utf-8 -*-
+'''graph managers'''
+
+from graphalchemy.core import octopus, app, factory
+from graphalchemy.managers.readers import (
+    Nodes as NodesRead, Links as LinksRead)
+from graphalchemy.managers.writers import (
+    Nodes as NodesWrite, Links as LinksWrite)
+
+__all__ = ('Links', 'Nodes')
+# settings
+conf = octopus.G
+backends = conf.backends
+db = conf.key.db
+
+
+class Links(LinksRead, LinksWrite):
+
+    # graph source
+    _db = app(conf.key.backend, conf.userspace)
+    _model = app(conf.manager.generic.element.link, conf.managers)
+    # direct link reader
+    r = factory(conf.read.link, backends, db)
+    # direct link writer
+    w = factory(conf.write.link, backends, db)
+
+
+class Nodes(NodesRead, NodesWrite):
+
+    _model = app(conf.manager.element.node, conf.managers)
+
+    # direct node reader
+    r = factory(conf.read.node, backends, db)
+    # direct node writer
+    w = factory(conf.write.node, backends, db)
+

graphalchemy/managers/elements.py

 # -*- coding: utf-8 -*-
-# pylint: disable-msg=w0201
 '''manager element models'''
 
-from graphalchemy.core import octopus, defer, app
+from graphalchemy.core import octopus, app
 from graphalchemy.mixins.elements import LinkMixin, NodeMixin, ElementMixin
 
 __all__ = ('Link', 'Node')
-
 # settings
 conf = octopus.G
 
         '''node class'''
         return Node
 
-    @defer
-    def create(self, kw):
-        '''make link'''
-        self.source = self.l.make(self.link, self.start, self.end, kw=kw)
-        self._refresh()
-
-    @defer
-    def modify(self, **kw):
-        '''update link'''
-        self.l.modify(self, kw)
-        self._refresh()
-
 
 class Node(NodeMixin, Element):
 
 
     # manager node collection
     _nodes = app(conf.manager.collector.node, conf.managers)
-
-    @defer
-    def create(self, kw):
-        '''make node'''
-        self.source = self.n.make(kw)
-        self._refresh()
-
-    @defer
-    def modify(self, kw):
-        '''update node'''
-        self.n.modify(self, kw)
-        self._refresh()

graphalchemy/managers/readers.py

 
 from appspace import AppLookupError
 
-from graphalchemy.core import octopus, app
-from graphalchemy.mixins.readers import ReaderMixin, LinksMixin, NodesMixin
+from graphalchemy.mixins.readers import ReaderMixin
 
 __all__ = ('Links', 'Nodes')
 
-# settings
-conf = octopus.G
-
 
 class Reader(ReaderMixin):
 
             yield model(element)
 
 
-class Links(Reader, LinksMixin):
+class Links(Reader):
 
     '''graph link reader'''
 
-    _model = app(conf.generic.element.link, conf.generics)
+    def kind(self, element):
+        '''
+        kind of link
+
+        @param element: graph element
+        '''
+        return self.r.kind(element)
 
     def walk(self, this, direction=None, label=None, keys=None):
         '''
             yield model(element)
 
 
-class Nodes(Reader, NodesMixin):
+class Nodes(Reader):
 
     '''graph manager node reader'''
 
-    _model = app(conf.generic.element.node, conf.generics)
-
     def root(self):
         '''reference root for graph'''
         try:

graphalchemy/managers/writers.py

 # -*- coding: utf-8 -*-
 '''graph writer managers'''
 
+from graphalchemy.core import defer
 from graphalchemy.mixins.writers import Writer
-from graphalchemy.core import octopus, app, factory
 
-__all__ = ('Links', 'Nodes')
-# settings
-conf = octopus.G
-backends = conf.backends
-db = conf.key.db
 
-
-class Links(Writer):
+class WriterMixin(Writer):
 
     '''graph link writer manager'''
 
-    _model = app(conf.manager.element.link, conf.managers)
-    # direct link reader
-    r = factory(conf.read.link, backends, db)
-    # direct link writer
-    w = factory(conf.write.link, backends, db)
+    @defer
+    def update(self, this, **data):
+        '''
+        update a graph element's properties
 
-    def _build(self, link, start, end, kw=None):
+        @param this: graph object
+        @param **data: data
         '''
-        build a new graph link
+        self.w.update(this, data)
+        this._refresh()
+        return this
 
-        @param data: data
+    @defer
+    def delete(self, this, indices=None):
         '''
-        if kw is None:
-            kw = {}
-        kw.update(_created=self.now(), _uuid=self.Q.uuid())
-        return self.w.build(link, start, end, **kw)
+        delete graph element
 
+        @param this: graph object
+        @param indicies: graph indices (default: None)
+        '''
+        self.w.delete(this, indices)
 
-class Nodes(Writer):
+
+class Links(WriterMixin):
+
+    '''graph link writer manager'''
+
+    @defer
+    def create(self, link, start, end, **data):
+        '''
+        create a new graph link
+
+        @param link: link name
+        @param start: start node for link
+        @param end: end node for link
+        @param **data: data
+        '''
+        data.update(_created=self.now(), _uuid=self.Q.uuid())
+        thing = self.w.create(link, start, end, data)
+        thing._refresh()
+        return thing
+
+
+class Nodes(WriterMixin):
 
     '''graph node writer manager'''
 
-    _query = app(conf.model.node.reader, conf.appspace)
-    _builder = app(conf.model.node.writer, conf.appspace)
-    _model = app(conf.manager.element.node, conf.managers)
-    # direct node reader
-    r = factory(conf.read.node, backends, db)
-    # direct node writer
-    w = factory(conf.write.node, backends, db)
+    @defer
+    def create(self, **data):
+        '''
+        create a new graph node
 
-    def _build(self, data):
-        '''
-        build a new graph node
-
-        @param data: data
+        @param **data: data
         '''
         data.update(_created=self.now(), _uuid=self.Q.uuid())
-        return self.w.build(data)
-
-    def query(self, model):
-        return self._query(model)
-
-    def create(self, **kw):
-        '''create a new graph element'''
-        instance = self.model(**kw)
-        self.session.add(instance)
-        return instance
+        thing = self.w.create(data)
+        thing._refresh()
+        return thing

graphalchemy/mixins/collections.py

         return self._this.n.walked(
             self._this, self.direction, keys=self.keys, end=self.link_end,
         )
-
-    def create(self, **kw):
-        '''create a node'''
-        new_node = self._model(**kw)
-        new_node.save()
-        return new_node

graphalchemy/mixins/elements.py

 # -*- coding: utf-8 -*-
 '''graph element mixins'''
 
-from stuf.utils import both, getcls, lazy, clsname, either
+from stuf.utils import both, getcls, lazy, clsname
 
-from graphalchemy.core import octopus, defer, app
+from graphalchemy.core import octopus
 
 __all__ = ('LinksMixin', 'NodesMixin')
 
 
     '''graph element'''
 
-    # graph connector
-    _g = app(conf.manager.graph, conf.appspace)
-
     def __init__(self, element=None, **kw):
         '''
         init
         '''graph element id'''
         return self._p.id(self.source)
 
-    @either
-    def l(self):
-        '''link wrapper'''
-        return self.session.links.wrap(self._link())
-
-    # prime link
-    _p = l
-
     @both
     def links(self):
         '''sequence of all links'''
         return self._links(self, getcls(self))
 
-    @links.expression
-    def links(self):
-        '''sequence of all links connected to this node'''
-        return self.l
-
     def _source(self, this):
         '''
         synchronized data structure
         # reset links collector
         self.links.reset()
 
-    @defer
     def index_by(self, index=None, *indexed):
         '''
         index properties on a graph element
         '''
         self._p.index_many(index, self, indexed)
 
-    @defer
     def index_under(self, index, key, value):
         '''
         index one property of a graph element
     @property
     def kind(self):
         '''kind of link'''
-        return self.l.kind(self.source)
+        return self.session.links.kind(self.source)
 
     @lazy
     def start(self):
         )
 
     @lazy
-    def n(self):
-        '''node wrapper'''
-        return self.session.nodes.wrap(self)
-
-    # prime element
-    _p = n
-
-    @lazy
     def nodes(self):
         '''connector to all nodes linked to this node'''
         return self._nodes(self, getcls(self))
         '''serialize this node and outgoing related nodes'''
         return self.copy(id=self.id)
 
-    @defer
     def link(self, link, node, **kw):
         '''
         link this node to another node
         @param node: the other node
         @param **kw: link properties
         '''
-        self.l.make(link, self, node, kw)
+        self.session.links.create(link, self, node, kw)

graphalchemy/mixins/readers.py

 # -*- coding: utf-8 -*-
 '''graph reader mixins'''
 
-from graphalchemy.core import octopus, app, factory
-
 __all__ = ('Reader Mixin', 'LinksMixin', 'Nodes')
 
-# settings
-conf = octopus.G
-
 
 class ReaderMixin(object):
 
     '''graph reader base'''
 
-    # graph source
-    _db = app(conf.key.backend, conf.userspace)
-
     def id(self, element):
         '''
         graph element identifier
         @param element: element with properties
         '''
         return self.r.properties(element)
-
-    def close(self):
-        '''close database'''
-        self.r.close()
-
-
-class LinksMixin(object):
-
-    '''graph link reader mixin'''
-
-    # graph reader
-    r = factory(conf.read.link, conf.backends, conf.key.db)
-
-    def kind(self, element):
-        '''
-        kind of link
-
-        @param element: graph element
-        '''
-        return self.r.kind(element)
-
-
-class NodesMixin(object):
-
-    '''graph node reader mixin'''
-
-    # graph reader
-    r = factory(conf.read.node, conf.backends, conf.key.db)

graphalchemy/mixins/writers.py

 
 import nanotime
 
-from graphalchemy.core import octopus, defer, app
+from graphalchemy.core import octopus, defer
 
 __all__ = ('Links', 'Nodes')
 
 
     '''graph writer base'''
 
-    # graph source
-    _db = app(conf.key.backend, conf.userspace)
-
     @defer
-    def delete(self, this, indices=None):
-        '''
-        delete graph element
-
-        @param this: graph object
-        @param indicies: graph indices (default: None)
-        '''
-        self.w.delete_element(this, indices)
-
     def index(self, index, fts=False):
         '''
         create link index
         '''
         self.w.create_index(index, fts)
 
+    @defer
     def index_many(self, index, this, indexed):
         '''
         index properties on a graph element
         '''
         self.w.index_many(self.r.index(index), this, indexed)
 
+    @defer
     def index_one(self, index, key, value, this):
         '''
         index one property of a graph element
         '''
         self.w.index_one(self.r.index(index), key, value, this)
 
-    def modify(self, this, data):
-        '''
-        update a graph element's properties
-
-        @param this: graph object
-        @param data: data
-        '''
-        self.w.update(this, data)
-
     @staticmethod
     def now():
         '''current time in microseconds'''

graphalchemy/models/apps.py

             node = 'graphalchemy.models.readers.Nodes'
 
 
-appconf = Appconf.build()
+appconf = Appconf.create()

graphalchemy/models/core.py

+# -*- coding: utf-8 -*-
+'''graph model manager'''
+
+from itertools import count
+from functools import partial
+
+from markupsafe import escape
+
+from graphalchemy.errors import ReversionError
+from graphalchemy.mixins.writers import Writer
+from graphalchemy.core import octopus, app, factory, defer
+
+__all__ = ['Nodes']
+# settings
+conf = octopus.G
+backends = conf.backends
+db = conf.key.db
+
+
+class Nodes(Writer, octopus.workflow.worker):
+
+    '''graph node writer'''
+
+    # graph source
+    _db = app(conf.key.backend, conf.userspace)
+    # model finder
+    _finder = app(conf.model.finder.node, conf.appspace)
+    # model query
+    _query = app(conf.model.node.reader, conf.appspace)
+    # model user
+    _using = app(conf.model.node.writer, conf.appspace)
+    # direct node reader
+    r = factory(conf.read.node, backends, db)
+    # direct node writer
+    w = factory(conf.write.node, backends, db)
+
+    def _autoslug(self, properties):
+        '''
+        auto slug an element
+
+        @param properties: graph element properties
+        '''
+        C = self.model.C
+        slug_from = C.slug_from
+        if not slug_from:
+            return
+        slug = tmpslug = self.Q.slugify(properties[slug_from])
+        slug_field = C.slug_field
+        # loop until unique slug is located
+        filter_by = self.r.filter_by
+        index = C.index
+        for cnt in count(1):
+            prev = filter_by(index, slug_field, tmpslug)
+            if not prev:
+                break
+            tmpslug = '{slug}-{count}'.format(slug=slug, count=cnt)
+        # add slug
+        properties[slug_field] = tmpslug
+
+    @defer
+    def _create(self, data):
+        '''
+        create a new graph node
+
+        @param data: data
+        '''
+        model = self.model
+        C = model.C
+        data.update(_created=self.now(), _model=C.name, _uuid=self.Q.uuid())
+        # number of versions to maintain
+        if C.versioned:
+            data['_versions'] = 0
+        self._preprocess(data)
+        thing = self.w.create(
+            data,
+            C.reference_link,
+            model.nodes.reference(),
+            partial(self._postprocess, model=model),
+        )
+        thing._refresh()
+
+    def _prepare(self, this):
+        # snapshot if flag set
+        if this.C.versioned:
+            self._snapshot(this)
+        super(Nodes, self)._prepare(this)
+
+    @defer
+    def _update(self, this, data):
+        '''
+        update a graph element's properties
+
+        @param this: graph object
+        @param data: data
+        '''
+        self._preprocess(data)
+        self.w.update(this, data, partial(self._postprocess, model=self.model))
+        this._refresh()
+
+    def _preprocess(self, this):
+        '''
+        pre-process graph element
+
+        @param this: graph object
+        '''
+        esc = escape
+        for k in self.model.C.escaped:
+            this[k] = esc(this[k])
+        this['_modified'] = self.now()
+        # slug field
+        self._autoslug(this)
+
+    def _postprocess(self, this):
+        '''
+        postprocess graph node
+
+        @param this: graph object
+        '''
+        this = self.model(this)
+        C = self.model.C
+        index = C.index
+        # index created date
+        index_one = self.index_one
+        if index:
+            index_one(index, 'created', self.now(), this)
+        # index any listed properties
+        indexed = C.indexed
+        if indexed:
+            self.index_many(index, this, indexed)
+        # add a slug if present
+        slug_from = C.slug_from
+        if slug_from:
+            index_one(index, slug_from, getattr(this, slug_from), this)
+        # index properties that support full text search
+        fts_indexed = C.fts_indexed
+        if fts_indexed:
+            self.index_many(C.fts_index, this, fts_indexed)
+        return this
+
+#    @defer
+#    def _versioning(self, diff, thing):
+#        '''snapshot node'''
+#        diff.update(_hash=thing.hash_diff(), _version=thing._version())
+#        # create new snapshot
+#        version = self._snapshot(thing, diff)
+#        thing._refresh()
+#        return version
+
+    @defer
+    def _revert(self, thing, version):
+        '''
+        change to another snapshot of this node
+
+        @param snapshot: id of previous snapshot of this node
+        '''
+        if thing.C.versioned:
+            self._snapshot(thing)
+            self.n.revert(self, version)
+            self._snapshot(thing)
+        raise ReversionError('could not revert snapshot {0}'.format(version))
+
+    def _snapshot(self, thing):
+        '''track changes for this node'''
+        diff = thing.diff()
+        # if there is a change to nodes properties...
+        return self._versioning(diff, thing) if diff else {}
+
+    def query(self, model):
+        '''
+        query using a graph model
+
+        @param model: graph model
+        '''
+        return self._query(model)
+
+    def using(self, model):
+        '''
+        use graph model
+
+        @param model: graph model
+        '''
+        return self._using(model)

graphalchemy/models/elements.py

 
 from stuf.utils import lazy_class, selfname
 
-from graphalchemy.errors import ReversionError
-from graphalchemy.core import octopus, app, defer
+
+from graphalchemy.core import octopus, app
 from graphalchemy.mixins.elements import NodeMixin, ElementMixin
 
 __all__ = ['Node']
     '''node model'''
 
     # links collection
-    _links = app(conf.generic.collector.link, conf.generics)
+    _links = app(conf.generic.collector.link, conf.managers)
     # node collection
     _nodes = app(conf.model.collector.node, conf.models)
 
     @lazy_class
     def C(self):
         '''local settings'''
-        existing = self.traits.localize()
         metas = dict()
         # model name
         metas['name'] = selfname(self)
-        class_names = self.traits.names
+        class_names = self.names
         # slug field
         try:
             metas['slug_from'] = class_names(slug_from=True)[0]
         metas['fts_indexed'] = set(k for k in class_names(full_text=True))
         # properties to HTML escape
         metas['escaped'] = set(k for k in class_names(escaped=True))
+        existing = self.M.localize(self)
         existing.update(metas)
         return existing
 
-    @classmethod
-    def _link(cls):
-        return cls.Q.app(cls.S.generic.element.link, cls.S.generics)
-
-    @defer
-    def _versioning(self, diff):
-        '''snapshot node'''
-        diff.update(_hash=self.traits.hash_diff(), _version=self._version())
-        # create new snapshot
-        version = self.n.snapshot(self, diff)
-        self._refresh()
-        return version
-
     def _version(self):
         '''increment current snapshot number of node'''
         self.update({'_versions': self._current['_versions'] + 1})
         return self._current['_versions']
 
-    def commit(self):
-        '''save this node'''
-        super(Node, self).commit()
-        # snapshot if flag set
-        if self.C.versioned:
-            self.snapshot()
-
-    @defer
-    def create(self, kw):
-        '''build node'''
-        self.source = self.n.build(kw).source
-        self._refresh()
-
-    @defer
-    def modify(self, kw):
-        '''update node'''
-        self.n.update(self, kw)
-        self._refresh()
-
-    @defer
-    def revert(self, version):
-        '''
-        change to another snapshot of this node
-
-        @param snapshot: id of previous snapshot of this node
-        '''
-        if self.C.versioned:
-            self.snapshot()
-            self.n.revert(self, version)
-            self.snapshot()
-        raise ReversionError('could not revert snapshot {0}'.format(version))
-
-    def snapshot(self):
-        '''track changes for this node'''
-        diff = self.traits.diff()
-        # if there is a change to nodes properties...
-        return self._versioning(diff) if diff else {}
-
-    @defer
     def anchor(self, anchor, **kw):
         '''link node to anchor'''
-        self.l.make(self.C.anchor_link, self, anchor, kw)
+        self.session.links.create(self.C.anchor_link, self, anchor, kw)
 
     class Meta:
         # anchor link label

graphalchemy/models/readers.py

 # -*- coding: utf-8 -*-
 '''graph model readers'''
 
-from stuf.utils import lazy
 from appspace import AppLookupError
 
-from graphalchemy.core import octopus, app
-from graphalchemy.mixins.readers import NodesMixin
+from graphalchemy.core import octopus, app, factory
+from graphalchemy.mixins.readers import ReaderMixin
 
 __all__ = ['Nodes']
 # settings
 conf = octopus.G
+backends = conf.backends
+db = conf.key.db
 
 
-class Nodes(NodesMixin, octopus.context.Thing):
+class Nodes(ReaderMixin, octopus.context.Thing):
 
     '''graph node model reader'''
 
     # model finder
     _finder = app(conf.model.finder.node, conf.appspace)
+    # direct node reader
+    r = factory(conf.read.node, backends, db)
+    # direct node writer
+    w = factory(conf.write.node, backends, db)
 
     def __init__(self, model):
         '''
         super(Nodes, self).__init__()
         self.model = model
 
-    @lazy
     def anchor(self):
         '''anchor node for a graph model'''
         try:
                 self.Q.add(anchor, anchor_link, userspace)
                 return anchor
 
-    @lazy
     def reference(self):
         '''reference node for a model'''
         try:

graphalchemy/models/writers.py

 # -*- coding: utf-8 -*-
 '''graph model writers'''
 
-from itertools import count
-from functools import partial
-
-from markupsafe import escape
-
-from graphalchemy.core import octopus, app
 from graphalchemy.mixins.writers import Writer
+from graphalchemy.core import octopus, app, factory
 
 __all__ = ['Nodes']
 # settings
 conf = octopus.G
+backends = conf.backends
+db = conf.key.db
 
 
 class Nodes(Writer, octopus.workflow.worker):
 
     '''graph node writer'''
 
+    # graph source
+    _db = app(conf.key.backend, conf.userspace)
     # model finder
     _finder = app(conf.model.finder.node, conf.appspace)
+    # direct node reader
+    r = factory(conf.read.node, backends, db)
+    # direct node writer
+    w = factory(conf.write.node, backends, db)
 
     def __init__(self, model):
         '''
         super(Nodes, self).__init__()
         self.model = model
 
-    def _autoslug(self, properties):
-        '''
-        auto slug an element
-
-        @param properties: graph element properties
-        '''
-        model = self.model
-        C = model.C
-        slug_from = C.slug_from
-        if not slug_from:
-            return
-        slug = tmpslug = self.Q.slugify(properties[slug_from])
-        slug_field = C.slug_field
-        # loop until unique slug is located
-        filter_by = self.r.filter_by
-        index = C.index
-        for cnt in count(1):
-            prev = filter_by(index, slug_field, tmpslug)
-            if not prev:
-                break
-            tmpslug = '{slug}-{count}'.format(slug=slug, count=cnt)
-        # add slug
-        properties[slug_field] = tmpslug
-
-    def _build(self, data):
-        '''
-        build a new graph node
-
-        @param data: data
-        '''
-        model = self.model
-        C = model.C
-        data.update(_created=self.now(), _model=C.name, _uuid=self.Q.uuid())
-        # number of versions to maintain
-        if C.versioned:
-            data['_versions'] = 0
-        self._preprocess(data)
-        return self.w.build(
-            data,
-            C.reference_link,
-            model.nodes.reference(),
-            partial(self._postprocess, model=model),
-        )
-
-    def _preprocess(self, this):
-        '''
-        pre-process graph element
-
-        @param this: graph object
-        '''
-        esc = escape
-        for k in self.model.C.escaped:
-            this[k] = esc(this[k])
-        this['_modified'] = self.now()
-        # slug field
-        self._autoslug(this)
-
-    def _postprocess(self, this):
-        '''
-        postprocess graph node
-
-        @param this: graph object
-        '''
-        this = self.model(this)
-        C = self.model.C
-        index = C.index
-        # index created date
-        index_one = self.index_one
-        if index:
-            index_one(index, 'created', self.now(), this)
-        # index any listed properties
-        indexed = C.indexed
-        if indexed:
-            self.index_many(index, this, indexed)
-        # add a slug if present
-        slug_from = C.slug_from
-        if slug_from:
-            index_one(index, slug_from, getattr(this, slug_from), this)
-        # index properties that support full text search
-        fts_indexed = C.fts_indexed
-        if fts_indexed:
-            self.index_many(C.fts_index, this, fts_indexed)
-        return this
-
     def anchor(self, **kw):
         '''create an anchor node'''
         model = self.model
             text=S.description.format(name=name),
         )
         data.update(kw)
-        return self.w.build(
+        return self.w.create(
             data,
             C.reference_link,
             model.nodes.reference(),
         index = C.index
         S = self.S.fork
         if index:
-            # build callback
+            # create callback
             index_one = self.index_one
             def callback(fork): #@IgnorePep8
                 # add hash
             # put in root index
             root_index = r.index(C.root_index)
             index_one(root_index, label, name, node)
-            # build any main index
+            # create any main index
             index = C.index
             if index:
                 index_one(create_index(index), label, label, node)
-            # build any full text index
+            # create any full text index
             fts_index = C.get('fts_index', False)
             if fts_index:
                 create_index(fts_index, fts=True)
             text=S.description.format(name=name),
         )
         data.update(kw)
-        return w.build(
+        return w.create(
             data, C.reference_link, finder(element=root)(root), callback,
         )
 
         C = model.C
         index = C.index
         if index:
-            # build callback if index
+            # create callback if index
             index_one = self.index_one
             def callback(snapshot): #@IgnorePep8
                 snapshot = model(snapshot)
         else:
             callback = None
         # create snapshot and link back to previous snapshot
-        return self.w.build(
+        return self.w.create(
             diff, C.version_link, this, callback, _created=created,
         )
-
-    def update(self, this, data):
-        '''
-        update a graph element's properties
-
-        @param this: graph object
-        @param data: data
-        '''
-        self._preprocess(data)
-        self.w.update(this, data, partial(self._postprocess, model=self.model))

graphalchemy/sessions.py

     '''graph session'''
 
     # link manager
-    links = extend(conf.manager.link, conf.appspace)
+    links = extend(conf.manager.link, conf.managers)
     # node monager
-    nodes = extend(conf.manager.node, conf.appspace)
+    nodes = extend(conf.manager.node, conf.managers)
     # transaction monager
     transaction = call(conf.transaction, conf.appspace)
 

graphalchemy/settings.py

 
     class manager:
         graph = 'manager.graph'
+        link = 'manager.manager.link'
+        node = 'manager.manager.node'
 
         class collection:
             link = 'manager.collection.link'
             node = 'model.finder.node'
 
         class writer:
-            link = 'manager.writer.link'
-            node = 'manager.writer.node'
+            link = 'model.writer.link'
+            node = 'model.writer.node'
 
     class backends:
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.