예제 #1
0
파일: entityns.py 프로젝트: Schevo/schevo
 def __init__(self, name, instance):
     NamespaceExtension.__init__(self, name, instance)
     d = self._d
     for t_name in instance._t_selectionmethod_names:
         func = getattr(instance, t_name)
         name = t_name[2:]
         d[name] = func
예제 #2
0
파일: entityns.py 프로젝트: Schevo/schevo
 def __init__(self, name, instance):
     NamespaceExtension.__init__(self, name, instance)
     d = self._d
     for x_name in instance._x_instancemethod_names:
         func = getattr(instance, x_name)
         name = x_name[2:]
         d[name] = func
예제 #3
0
파일: viewns.py 프로젝트: Schevo/schevo
 def __init__(self, name, view):
     NamespaceExtension.__init__(self, name, view)
     d = self._d
     entity = view._entity
     # Start with the actions defined on the entity.
     for q_name in entity._q_instancemethod_names:
         func = getattr(entity, q_name)
         name = q_name[2:]
         d[name] = func
     # The add or override with actions defined on the view.
     cls = view.__class__
     q_names = []
     for attr in dir(cls):
         if attr.startswith('q_'):
             q_name = attr
             func = getattr(cls, q_name)
             q_names.append(q_name)
     for q_name in q_names:
         name = q_name[2:]
         func = getattr(view, q_name)
         # Assign a label if none exists.
         new_label = None
         if getattr(func, '_label', None) is None:
             new_label = label_from_name(name)
             if new_label is not None:
                 cls.__dict__[q_name]._label = new_label
         d[name] = func
예제 #4
0
    def test_len(self):
        ne = NamespaceExtension('n', None)
        ne._set('foo', 'bar')
        ne._set('baz', 'bof')
        assert len(ne) == 2
##         # Private attributes are not included.
##         ne._xyz = 123
        assert len(ne) == 2
예제 #5
0
파일: viewns.py 프로젝트: Schevo/schevo
 def __init__(self, name, cls):
     NamespaceExtension.__init__(self, name, cls)
     for key in dir(cls):
         if key.startswith('t_'):
             method = getattr(cls, key)
             if isselectionmethod(method):
                 name = key[2:]
                 self._set(name, method)
예제 #6
0
    def test_iter(self):
        ne = NamespaceExtension('n', None)
        ne._set('foo', 'bar')
        ne._set('baz', 'bof')
        L = sorted(ne)
        assert L == ['baz', 'foo']
##         # Private attributes are not included.
##         ne._xyz = 123
        L = sorted(ne)
        assert L == ['baz', 'foo']
예제 #7
0
파일: queryns.py 프로젝트: Schevo/schevo
 def __init__(self, name, query):
     NamespaceExtension.__init__(self, name, query)
     d = self._d
     # Note: could be optimized via using a metaclass with
     # ParamQuery.
     for name in dir(query):
         if name.startswith('h_'):
             func = getattr(query, name)
             name = name[2:]
             d[name] = func
예제 #8
0
파일: extent.py 프로젝트: gldnspud/schevo
 def __init__(self, name, instance, EntityClass):
     NamespaceExtension.__init__(self, name, instance)
     # Expose methods through this namespace.
     for name in dir(EntityClass):
         # Extender methods always have x_ prefix.
         if name.startswith('x_'):
             method = getattr(EntityClass, name)
             # Methods that apply to an extent are extentmethods.
             if isextentmethod(method):
                 # Drop the 'x_' prefix.
                 name = name[2:]
                 self._set(name, method)
예제 #9
0
파일: extent.py 프로젝트: gldnspud/schevo
 def __init__(self, name, instance, EntityClass):
     NamespaceExtension.__init__(self, name, instance)
     self._E = EntityClass
     # Expose transaction methods through this namespace.
     for key in dir(EntityClass):
         # Transaction methods always have t_ prefix.
         if key.startswith('t_'):
             method = getattr(EntityClass, key)
             # Transaction methods that apply to an extent are
             # extentmethods of an Entity class.
             if isextentmethod(method):
                 # Drop the 't_' prefix.
                 name = key[2:]
                 self._set(name, method)
예제 #10
0
파일: viewns.py 프로젝트: Schevo/schevo
 def __init__(self, name, view):
     NamespaceExtension.__init__(self, name, view)
     d = self._d
     cls = view.__class__
     x_names = []
     for attr in dir(cls):
         if attr.startswith('x_'):
             x_name = attr
             func = getattr(cls, x_name)
             x_names.append(x_name)
     for x_name in x_names:
         name = x_name[2:]
         func = getattr(view, x_name)
         d[name] = func
예제 #11
0
파일: entityns.py 프로젝트: Schevo/schevo
 def __init__(self, name, instance):
     NamespaceExtension.__init__(self, name, instance)
     d = self._d
     i = instance
     db = i._db
     extent_name = i._extent.name
     oid = i._oid
     last_extent_name = ''
     for other_extent_name, other_field_name in i._extent.relationships:
         # The first field for an other_extent becomes the default.
         if other_extent_name == last_extent_name:
             continue
         last_extent_name = other_extent_name
         many_name = _many_name(db.extent(other_extent_name)._plural)
         many_func = _many_func(db, extent_name, oid,
                                other_extent_name, other_field_name)
         d[many_name] = many_func
예제 #12
0
 def test_getitem(self):
     ne = NamespaceExtension('n', None)
     ne._set('foo', 'bar')
     ne._set('baz', 'bof')
     assert ne['foo'] == 'bar'
     assert ne['baz'] == 'bof'
예제 #13
0
 def test_getattr(self):
     ne = NamespaceExtension('n', None)
     ne._set('foo', 'bar')
     ne._set('baz', 'bof')
     assert ne.foo == 'bar'
     assert ne.baz == 'bof'
예제 #14
0
파일: viewns.py 프로젝트: Schevo/schevo
 def __init__(self, name, view):
     NamespaceExtension.__init__(self, name, view)
     # Copy one-to-many methods from the view's entity to the view
     # itself.
     self._d.update(view._entity.v._d)