Commits

Lynn Rees committed 6f7eb43

- fixes

Comments (0)

Files changed (12)

graphalchemy/__init__.py

 # -*- coding: utf-8 -*-
-'''object-graph mapper'''
+'''object <-> graph mapper'''
 
 from inspect import ismodule
 

graphalchemy/core.py

 method = octopus.descriptor.method
 reextend = octopus.descriptor.reextend
 refactory = octopus.descriptor.refactory
+join = octopus.descriptor.join

graphalchemy/direct/collectors.py

 # -*- coding: utf-8 -*-
 '''direct collectors'''
 
-from graphalchemy.core import octopus, app
+from graphalchemy.core import octopus, join
 from graphalchemy.mixins.collectors import LinksMixin, NodesMixin
 
 __all__ = ('Links', 'Nodes')
 
     '''direct link collections collector'''
 
-    _collection = app(conf.direct.collection.link, conf.directs)
+    _collection = join(conf.direct.collection.link, conf.directs)
 
 
 class Nodes(NodesMixin):
 
     '''direct nodes collections collector'''
 
-    _collection = app(conf.direct.collection.node, conf.directs)
+    _collection = join(conf.direct.collection.node, conf.directs)

graphalchemy/direct/elements.py

 
 from stuf.utils import lazy
 
-from graphalchemy.core import octopus, app
+from graphalchemy.core import octopus, join
 from graphalchemy.mixins.elements import NodeMixin, ElementMixin
 
 __all__ = ('Link', 'Node')
     '''graph node object'''
 
     # direct node collection
-    _nodes = app(conf.direct.collector.node, conf.directs)
+    _nodes = join(conf.direct.collector.node, conf.directs)

graphalchemy/direct/workers.py

 # -*- coding: utf-8 -*-
 '''graph direct workers'''
 
-from graphalchemy.core import octopus, app, factory, defer
+from graphalchemy.core import octopus, app, factory, defer, join
 from graphalchemy.mixins.workers import WriterMixin, ReaderMixin
 
 __all__ = ('Links', 'Nodes')
 
     # graph source
     _db = app(conf.key.backend, conf.userspace)
-    _model = app(conf.direct.element.link, conf.directs)
+    _model = join(conf.direct.element.link, conf.directs)
     # direct link reader
     _r = factory(conf.read.link, backends, db)
     # direct link writer
 
     '''direct graph node interface'''
 
-    _model = app(conf.direct.element.node, conf.directs)
+    _model = join(conf.direct.element.node, conf.directs)
     # direct node reader
     _r = factory(conf.read.node, backends, db)
     # direct node writer

graphalchemy/mixins/elements.py

 
 from stuf.utils import both, getcls, lazy, clsname
 
-from graphalchemy.core import octopus, factory, app
+from graphalchemy.core import octopus, join
 
 __all__ = ('ElementMixin', 'NodesMixin')
 # settings
 
     '''graph element'''
 
-    # graph source
-    _db = app(conf.key.backend, conf.userspace)
-    # node reader
-    _lr = _r = factory(conf.read.link, backends, db)
-    # node writer
-    _lw = _w = factory(conf.write.link, backends, db)
     # links collection
-    _links = app(conf.direct.collector.link, conf.directs)
+    _links = join(conf.direct.collector.link, conf.directs)
 
     def __init__(self, element=None, **kw):
         '''
             clsname(self), super(ElementMixin, self).__repr__(),
         )
 
+    @property
+    def _i(self):
+        return self.session.links
+
+    _l = _i
+
     @lazy
     def id(self):
         '''graph element id'''
-        return self._r.id(self.source)
+        return self._i.id(self.source)
 
     @both
     def links(self):
 
         @param element: this element
         '''
-        return self._r.properties(element)
+        return self._i.properties(element)
 
     def _refresh(self):
         '''refresh original'''
         @param index: graph index label (default: None)
         @param *indexed: properties to index
         '''
-        self._r.index_many(index, self, indexed)
+        self._i.index_many(index, self, indexed)
 
     def index_under(self, index, key, value):
         '''
         @param key: graph element property key
         @param value: graph element property value
         '''
-        self._r.index_one(index, key, value, self)
+        self._i.index_one(index, key, value, self)
 
 
 class NodeMixin(object):
 
     '''node element'''
 
-    # node reader
-    _nr = _r = factory(conf.read.node, backends, db)
-    # node writer
-    _nw = _w = factory(conf.write.node, backends, db)
+    @property
+    def _i(self):
+        return self.session.nodes.direct
+
+    _n = _i
 
     @lazy
     def nodes(self):
         @param node: the other node
         @param **kw: link properties
         '''
-        self._lw.create(link, self, node, kw)
+        self._l.create(link, self, node, kw)

graphalchemy/models/collectors.py

 
 from stuf.utils import lazy
 
-from graphalchemy.core import octopus, app
+from graphalchemy.core import octopus, join
 from graphalchemy.mixins.collectors import NodesMixin
 
 __all__ = ('In', 'Nodes', 'Out')
     '''collection of model nodes'''
 
     # node collection
-    _collection = app(conf.model.collection.node, conf.models)
+    _collection = join(conf.model.collection.node, conf.models)
 
     @lazy
     def forks(self):
     '''direction definition'''
 
     # model finder
-    _finder = app(conf.model.finder.node, conf.models)
+    _finder = join(conf.model.finder.node, conf.models)
     # node collection
-    _nodes = app(conf.model.collection.node, conf.models)
+    _nodes = join(conf.model.collection.node, conf.models)
 
     def __init__(self, model=None, kind=''):
         '''

graphalchemy/models/elements.py

 
 from stuf.utils import lazy_class, selfname
 
-from graphalchemy.core import octopus, app
+from graphalchemy.core import octopus, join
 from graphalchemy.mixins.elements import NodeMixin, ElementMixin
 
 __all__ = ['Node']
     '''node model'''
 
     # node collection
-    _nodes = app(conf.model.collector.node, conf.models)
+    _nodes = join(conf.model.collector.node, conf.models)
 
     @lazy_class
     def L(self):
         '''local settings'''
-        metas = dict()
-        # model name
-        metas['name'] = selfname(self)
         class_names = self.names
+        metas = dict(
+            # properties to index
+            indexed=set(k for k in class_names(indexed=True)),
+            # properties indexed for full text search
+            fts_indexed=set(k for k in class_names(full_text=True)),
+            # properties to HTML escape
+            escaped=set(k for k in class_names(escaped=True)),
+            # model name
+            name=selfname(self),
+        )
         # slug field
         try:
             metas['slug_from'] = class_names(slug_from=True)[0]
         except IndexError:
             metas['slug_from'] = ''
-        # properties to index
-        metas['indexed'] = set(k for k in class_names(indexed=True))
-        # properties indexed for full text search
-        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))
         return self.M.localize(self, metas)
 
     def _version(self):
 
     def anchor(self, anchor, **kw):
         '''link node to anchor'''
-        self._lw.create(self.L.anchor_link, self, anchor, kw)
+        self._l.create(self.L.anchor_link, self, anchor, kw)
 
     class Meta:
         # anchor link label

graphalchemy/models/finders.py

 from appspace import NoAppError
 from stuf.six import string_types
 
-from graphalchemy.core import octopus, app
+from graphalchemy.core import octopus, join
 
 __all__ = ['nodes']
 # settings
 
     '''node model finder'''
 
-    model = app(conf.direct.element.node, conf.models)
+    model = join(conf.direct.element.node, conf.models)
 
     def __call__(self, model=None, element=None):
         '''

graphalchemy/models/readers.py

 
 from appspace import AppLookupError
 
-from graphalchemy.core import octopus, app, factory
 from graphalchemy.mixins.workers import ReaderMixin
+from graphalchemy.core import octopus, join, factory
 
 __all__ = ['Nodes']
 # settings
     '''graph node model reader'''
 
     # model finder
-    _finder = app(conf.model.finder.node, conf.models)
+    _finder = join(conf.model.finder.node, conf.models)
     # direct node reader
     _r = factory(conf.read.node, backends, db)
     # direct node writer

graphalchemy/models/workers.py

 from appspace import AppLookupError
 
 from graphalchemy.mixins.workers import WriterMixin
-from graphalchemy.core import octopus, app, factory, defer
+from graphalchemy.core import octopus, app, join, factory, defer
 
 __all__ = ['Nodes']
 # settings
     # graph source
     _db = app(conf.key.backend, conf.userspace)
     # model finder
-    _finder = app(conf.model.finder.node, conf.models)
+    _finder = join(conf.model.finder.node, conf.models)
     # direct model
-    _model = app(conf.direct.element.node, conf.directs)
+    _model = join(conf.direct.element.node, conf.directs)
     # model query
     _query = app(conf.model.reader.node, conf.models)
     # model user

graphalchemy/models/writers.py

 
 from graphalchemy.errors import ReversionError
 from graphalchemy.mixins.workers import WriterMixin
-from graphalchemy.core import octopus, app, factory, defer
+from graphalchemy.core import octopus, app, join, factory, defer
 
 __all__ = ['Nodes']
 # settings
     # graph source
     _db = app(conf.key.backend, conf.userspace)
     # model finder
-    _finder = app(conf.model.finder.node, conf.models)
+    _finder = join(conf.model.finder.node, conf.models)
     # direct node reader
     _r = factory(conf.read.node, backends, db)
     # direct node writer