Ejemplo n.º 1
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     self.iface = model
     self.rebind(model)
     self._fields = OrderedDict()
     self._render_fields = OrderedDict()
     self._bound_pk = None
     for name, field in schema.getFieldsInOrder(self.iface):
         klass = field.__class__
         try:
             t = self._fields_mapping[klass]
         except KeyError:
             raise NotImplementedError('%s is not mapped to a type' % klass)
         else:
             self.append(Field(name=name, type=t))
             self._fields[name].label_text = field.title or name
             if field.description:
                 self._fields[name].set(instructions=field.description)
             if field.required:
                 self._fields[name].validators.append(validators.required)
             if klass is schema.Text:
                 self._fields[name].set(
                     renderer=fields.TextAreaFieldRenderer)
             if klass is schema.List:
                 value_type = self.iface[name].value_type
                 if isinstance(value_type, schema.Choice):
                     self._fields[name].set(options=value_type,
                                            multiple=True)
                 else:
                     self._fields[name].set(multiple=True)
             elif klass is schema.Choice:
                 self._fields[name].set(renderer=fields.SelectFieldRenderer,
                                        options=self.iface[name])
Ejemplo n.º 2
0
 def rebind(self, instances=None, session=None, data=None, request=None):
     """rebind to instances"""
     if instances is not None:
         _validate_iterable(instances)
     FieldSet.rebind(self, self.model, session, data, request)
     if instances is not None:
         self.rows = instances
Ejemplo n.º 3
0
 def rebind(self, instances=None, session=None, data=None):
     """rebind to instances"""
     if instances is not None:
         _validate_iterable(instances)
     FieldSet.rebind(self, self.model, session, data)
     if instances is not None:
         self.rows = instances
Ejemplo n.º 4
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     self.iface = model
     self.rebind(model)
     self._fields = OrderedDict()
     self._render_fields = OrderedDict()
     self._bound_pk = None
     for name, field in schema.getFieldsInOrder(self.iface):
         klass = field.__class__
         try:
             t = self._fields_mapping[klass]
         except KeyError:
             raise NotImplementedError('%s is not mapped to a type' % klass)
         else:
             self.append(Field(name=name, type=t))
             self._fields[name].label_text = field.title or name
             if field.description:
                 self._fields[name].set(instructions=field.description)
             if field.required:
                 self._fields[name].validators.append(validators.required)
             if klass is schema.Password:
                 self._fields[name].set(renderer=fields.PasswordFieldRenderer)
             if klass is schema.Text:
                 self._fields[name].set(renderer=fields.TextAreaFieldRenderer)
             if klass is schema.List:
                 value_type = self.iface[name].value_type
                 if isinstance(value_type, schema.Choice):
                     self._fields[name].set(options=value_type, multiple=True)
                 else:
                     self._fields[name].set(multiple=True)
             elif klass is schema.Choice:
                 self._fields[name].set(renderer=fields.SelectFieldRenderer,
                                        options=self.iface[name])
Ejemplo n.º 5
0
    def test_render_validate(self):
        params = {'Spot--the_geom': 'Point(0 1)'}

        spot_fieldset = FieldSet(Spot, data = params)

        spot_fieldset.validate()
        form = spot_fieldset.render()
        ok_("Point(0 1)'" in form, 'submitted value was not re-displayed in case of validation error')
Ejemplo n.º 6
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     BaseFieldSet.rebind(self, model, data=kwargs.get("data", None))
     for k, v in model.__dict__.items():
         if not k.startswith("_"):
             descriptor = type(v)
             t = self._mapping.get(descriptor)
             if t:
                 self.append(Field(name=k, type=t))
Ejemplo n.º 7
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     BaseFieldSet.rebind(self, model, data=kwargs.get('data', None))
     for k, v in model.__dict__.items():
         if not k.startswith('_'):
             descriptor = type(v)
             t = self._mapping.get(descriptor)
             if t:
                 self.append(Field(name=k, type=t))
Ejemplo n.º 8
0
 def configure(self, **kwargs):
     """
     The `Grid` `configure` method takes the same arguments as `FieldSet`
     (`pk`, `exclude`, `include`, `options`, `readonly`), except there is
     no `focus` argument.
     """
     if 'focus' in kwargs:
         del kwargs['focus']
     FieldSet.configure(self, **kwargs)
Ejemplo n.º 9
0
 def configure(self, **kwargs):
     """
     The `Grid` `configure` method takes the same arguments as `FieldSet`
     (`pk`, `exclude`, `include`, `options`, `readonly`), except there is
     no `focus` argument.
     """
     if 'focus' in kwargs:
         del kwargs['focus']
     FieldSet.configure(self, **kwargs)
Ejemplo n.º 10
0
 def sync_one(self, row):
     """
     Use to sync a single one of the instances that are
     bound to the `Grid`.
     """
     # we want to allow the user to sync just rows w/o errors, so this is public
     if self.readonly:
         raise Exception('Cannot sync a read-only Grid')
     self._set_active(row)
     FieldSet.sync(self)
Ejemplo n.º 11
0
    def __init__(self, cls, instances=[], session=None, data=None, request=None, prefix=None):
        if self.__sa__:
            from sqlalchemy.orm import class_mapper

            if not class_mapper(cls):
                raise Exception("Grid must be bound to an SA mapped class")
        FieldSet.__init__(self, model=cls, session=session, data=data, request=request, prefix=prefix)
        self.rows = instances
        self.readonly = False
        self._errors = {}
Ejemplo n.º 12
0
 def sync_one(self, row):
     """
     Use to sync a single one of the instances that are
     bound to the `Grid`.
     """
     # we want to allow the user to sync just rows w/o errors, so this is public
     if self.readonly:
         raise Exception('Cannot sync a read-only Grid')
     self._set_active(row)
     FieldSet.sync(self)
Ejemplo n.º 13
0
    def test_render_reproject(self):
        session = FakeSession()
        spot_fieldset = FieldSet(Spot, session=session)
        spot_fieldset.the_geom.set(options=[('map_srid', 900913)])

        spot = Spot()
        spot.id = 1
        spot.the_geom = PersistentSpatialElement(PersistentSpatialElement(WKBSpatialElement('010')));

        spot_fieldset = spot_fieldset.bind(spot)

        spot_fieldset.render()
        ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT');
        ok_(isinstance(session.scalar_args[0].arguments[0], functions.transform), 'The geometry was not reprojected');
 def test_render_options(self):
     spot_fieldset = FieldSet(Spot)
     spot_fieldset.the_geom.set(options=[
                     ('default_lat', 1),
                     ('default_lon', 2),
                     ('zoom', 3),
                     ('map_width', 4),
                     ('map_height', 5),
                     ('base_layer', 'new OpenLayers.Layer.DummyLayer("OSM")'),
                     ('openlayers_lib', '/js/OpenLayers.js')])
     
     form = spot_fieldset.render()
     
     ok_('1,\n            2,\n            3,            \'Point\',            new OpenLayers.Layer.DummyLayer("OSM"),', form)
     ok_('<script src="/js/OpenLayers.js"></script>' in form)
Ejemplo n.º 15
0
    def test_render_options(self):
        spot_fieldset = FieldSet(Spot)
        spot_fieldset.the_geom.set(options=[
                        ('default_lat', 1),
                        ('default_lon', 2),
                        ('zoom', 3),
                        ('map_width', 4),
                        ('map_height', 5),
                        ('base_layer', 'new OpenLayers.Layer.DummyLayer("OSM")'),
                        ('openlayers_lib', '/js/OpenLayers.js')])

        form = spot_fieldset.render()

        ok_('1,\n            2,\n            3,            \'Point\',            new OpenLayers.Layer.DummyLayer("OSM"),', form)
        ok_('<script src="/js/OpenLayers.js"></script>' in form)
        ok_('init_map(' in form)
Ejemplo n.º 16
0
    def test_render(self):
        session = FakeSession()
        spot_fieldset = FieldSet(Spot, session=session)

        spot = Spot()
        spot.id = 1
        spot.the_geom = PersistentSpatialElement(PersistentSpatialElement(WKBSpatialElement('010')));

        spot_fieldset = spot_fieldset.bind(spot)

        form = spot_fieldset.render()

        ok_("geoformalchemy.init_map(" in form, 'Template was not rendered')
        ok_("'Point'," in form, 'OpenLayers geometry was not mapped correctly ')
        ok_("false," in form, 'Geometry should not be a collection')
        ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT');
Ejemplo n.º 17
0
 def render(self, lang=None):
     if self.readonly:
         html = pretty_html(DefaultFieldSet.render(self))
         for name, engine in templates.engines.items():
             if isinstance(engine, config.engine.__class__):
                 continue
             html_engine = pretty_html(engine('fieldset_readonly', fieldset=self))
             assert html == html_engine, (name, html, html_engine)
         return html
     html = pretty_html(DefaultFieldSet.render(self))
     for name, engine in templates.engines.items():
         if isinstance(engine, config.engine.__class__):
             continue
         html_engine = pretty_html(engine('fieldset', fieldset=self))
         assert html == html_engine, (name, html, html_engine)
     return html
Ejemplo n.º 18
0
 def __init__(self, model, session=None, data=None, prefix=None):
     self._fields = OrderedDict()
     self._render_fields = OrderedDict()
     self.model = self.session = None
     BaseFieldSet.rebind(self, model, data=data)
     self.prefix = prefix
     self.model = model
     self.readonly = False
     self.focus = True
     self._errors = []
     focus = True
     for k, v in model.__dict__.iteritems():
         if not k.startswith("_"):
             descriptor = type(v)
             t = self._mapping.get(descriptor)
             if t:
                 self.append(Field(name=k, type=t))
Ejemplo n.º 19
0
 def render(self, lang=None):
     if self.readonly:
         html = pretty_html(DefaultFieldSet.render(self))
         for name, engine in templates.engines.items():
             if isinstance(engine, config.engine.__class__):
                 continue
             html_engine = pretty_html(
                 engine('fieldset_readonly', fieldset=self))
             assert html == html_engine, (name, html, html_engine)
         return html
     html = pretty_html(DefaultFieldSet.render(self))
     for name, engine in templates.engines.items():
         if isinstance(engine, config.engine.__class__):
             continue
         html_engine = pretty_html(engine('fieldset', fieldset=self))
         assert html == html_engine, (name, html, html_engine)
     return html
Ejemplo n.º 20
0
    def test_render_additional_options(self):
        spot_fieldset = FieldSet(Spot)
        spot_fieldset.the_geom.set(options=[
                        ('default_lat', 1),
                        ('default_lon', 2),
                        ('zoom', 3),
                        ('map_width', 4),
                        ('map_height', 5),
                        ('base_layer', 'new OpenLayers.Layer.DummyLayer("OSM")'),
                        ('run_js', False),
                        ('insert_libs', False)
                        ])

        form = spot_fieldset.render()

        ok_('<script src="/js/OpenLayers.js"></script>' not in form)
        ok_('init_map(' not in form)
Ejemplo n.º 21
0
 def __init__(self,
              cls,
              instances=[],
              session=None,
              data=None,
              prefix=None):
     if self.__sa__:
         from sqlalchemy.orm import class_mapper
         if not class_mapper(cls):
             raise Exception('Grid must be bound to an SA mapped class')
     FieldSet.__init__(self,
                       model=cls,
                       session=session,
                       data=data,
                       prefix=prefix)
     self.rows = instances
     self.readonly = False
     self._errors = {}
Ejemplo n.º 22
0
 def __init__(self, model, session=None, data=None, prefix=None):
     self._fields = OrderedDict()
     self._render_fields = OrderedDict()
     self.model = self.session = None
     BaseFieldSet.rebind(self, model, data=data)
     self.prefix = prefix
     self.model = model
     self.readonly = False
     self.focus = True
     self._errors = []
     focus = True
     for k, v in model().iteritems():
         if not k.startswith('_'):
             try:
                 t = getattr(fatypes, v.__class__.__name__.replace('Property',''))
             except AttributeError:
                 raise NotImplementedError('%s is not mapped to a type' % v.__class__)
             else:
                 self.add(Field(name=k, type=t))
                 if v.required:
                     self._fields[k].validators.append(validators.required)
Ejemplo n.º 23
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     if model is not None and isinstance(model, schema.Document):
         BaseFieldSet.rebind(self, model.__class__, data=kwargs.get('data', None))
         self.doc = model.__class__
         self.model = model
         self._bound_pk = fields._pk(model)
     else:
         BaseFieldSet.rebind(self, model, data=kwargs.get('data', None))
         self.doc = model
     values = self.doc._properties.values()
     values.sort(lambda a, b: cmp(a.creation_counter, b.creation_counter))
     for v in values:
         if getattr(v, 'name'):
             k = v.name
             sch = None
             if isinstance(v, schema.SchemaListProperty):
                 t = fatypes.List
                 sch = v._schema
             elif isinstance(v, schema.SchemaProperty):
                 t = fatypes.String
                 sch = v._schema
             else:
                 try:
                     t = getattr(fatypes, v.__class__.__name__.replace('Property',''))
                 except AttributeError:
                     raise NotImplementedError('%s is not mapped to a type for field %s (%s)' % (v.__class__, k, v.__class__.__name__))
             self.append(Field(name=k, type=t, schema=sch))
             if v.required:
                 self._fields[k].validators.append(validators.required)
Ejemplo n.º 24
0
 def __init__(self, model, **kwargs):
     BaseFieldSet.__init__(self, model, **kwargs)
     if model is not None and isinstance(model, schema.Document):
         BaseFieldSet.rebind(self, model.__class__, data=kwargs.get('data', None))
         self.doc = model.__class__
         self.model = model
         self._bound_pk = fields._pk(model)
     else:
         BaseFieldSet.rebind(self, model, data=kwargs.get('data', None))
         self.doc = model
     values = self.doc._properties.values()
     values.sort(lambda a, b: cmp(a.creation_counter, b.creation_counter))
     for v in values:
         if getattr(v, 'name'):
             k = v.name
             sch = None
             if isinstance(v, schema.SchemaListProperty):
                 t = fatypes.List
                 sch = v._schema
             elif isinstance(v, schema.SchemaProperty):
                 t = fatypes.String
                 sch = v._schema
             else:
                 try:
                     t = getattr(fatypes, v.__class__.__name__.replace('Property',''))
                 except AttributeError:
                     raise NotImplementedError('%s is not mapped to a type for field %s (%s)' % (v.__class__, k, v.__class__.__name__))
             self.append(Field(name=k, type=t, schema=sch))
             if v.required:
                 self._fields[k].validators.append(validators.required)
Ejemplo n.º 25
0
 def __init__(self, model, session=None, data=None, prefix=None):
     self._fields = OrderedDict()
     self._request = None
     self._render_fields = OrderedDict()
     if isinstance(model, node.Node):
         self._original_cls = model.__class__
     else:
         self._original_cls = model
     self.model = self.session = None
     BaseFieldSet.rebind(self, model, data=data)
     self._prefix = prefix
     self.model = model
     self.readonly = False
     self.focus = True
     self._format = u'%(model)s-%(pk)s-%(name)s'
     self._errors = []
     focus = True
     for k, v in model.properties():
         type = v.__class__.__name__.replace('Property', '')
         if type == 'Unicode':
             type = 'String'
         elif type == 'SetOfNodes':
             type = 'Set'
         elif type == 'ListOfGroups':
             continue
         elif type == 'ListOfGroupNodes':
             type = 'List'
         try:
             t = getattr(fatypes, type)
         except AttributeError:
             raise NotImplementedError('%s is not mapped to a type' %
                                       v.__class__)
         else:
             self.append(Field(name=k, type=t, prop=v))
             field = self[k]
             field.set(label=v.title)
             if v.description:
                 field.set(instructions=v.description)
             if v.required:
                 field.validators.append(validators.required)
Ejemplo n.º 26
0
 def bind(self, instances, session=None, data=None, request=None):
     """bind to instances"""
     _validate_iterable(instances)
     if not session:
         i = iter(instances)
         try:
             instance = i.next()
         except StopIteration:
             pass
         else:
             from sqlalchemy.orm import object_session
             session = object_session(instance)
     mr = FieldSet.bind(self, self.model, session, data)
     mr.rows = instances
     mr._request = request
     return mr
Ejemplo n.º 27
0
 def bind(self, instances, session=None, data=None, request=None):
     """bind to instances"""
     _validate_iterable(instances)
     if not session:
         i = iter(instances)
         try:
             instance = i.next()
         except StopIteration:
             pass
         else:
             from sqlalchemy.orm import object_session
             session = object_session(instance)
     mr = FieldSet.bind(self, self.model, session, data, request)
     mr.rows = instances
     mr._request = request
     return mr
Ejemplo n.º 28
0
 def copy(self, *args):
     """return a copy of the fieldset. args is a list of field names or field
     objects to render in the new fieldset"""
     mr = FieldSet.bind(self, self.model, self.session)
     mr.rows = []
     mr.readonly = self.readonly
     mr._errors = {}
     _fields = self._render_fields or self._fields
     _new_fields = []
     if args:
         for field in args:
             if isinstance(field, basestring):
                 if field in _fields:
                     field = _fields.get(field)
                 else:
                     raise AttributeError('%r as not field named %s' % (self, field))
             assert isinstance(field, fields.AbstractField), field
             field.bind(mr)
             _new_fields.append(field)
         mr._render_fields = OrderedDict([(field.key, field) for field in _new_fields])
     return mr
Ejemplo n.º 29
0
 def copy(self, *args):
     """return a copy of the fieldset. args is a list of field names or field
     objects to render in the new fieldset"""
     mr = FieldSet.bind(self, self.model, self.session)
     mr.rows = []
     mr.readonly = self.readonly
     mr._errors = {}
     _fields = self._render_fields or self._fields
     _new_fields = []
     if args:
         for field in args:
             if isinstance(field, basestring):
                 if field in _fields:
                     field = _fields.get(field)
                 else:
                     raise AttributeError('%r as not field named %s' %
                                          (self, field))
             assert isinstance(field, fields.AbstractField), field
             field.bind(mr)
             _new_fields.append(field)
         mr._render_fields = OrderedDict([(field.key, field)
                                          for field in _new_fields])
     return mr
 def test_deserialize_reproject(self):
     params = {'Spot--the_geom': 'Point(0 1)', 'Spot--name': 'dummy'}
     session = FakeSession()
     
     spot_fieldset = FieldSet(Spot, data = params, session=session)
     spot_fieldset.the_geom.set(options=[('map_srid', 900913)])
     
     spot_fieldset.validate()
     spot_fieldset.sync()
     ok_(isinstance(spot_fieldset.model.the_geom, WKTSpatialElement), 'Geometry was not assigned to model')
     eq_(spot_fieldset.model.the_geom.desc, 'geometry', 'The geometry was not reprojected for the insertion into the db')
     
     spot_fieldset.render()
     ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT')
     ok_(isinstance(session.scalar_args[0].arguments[0], functions.transform), 'The geometry was not reprojected')
     
     params = {'Spot--the_geom': ' ', 'Spot--name': ''}
     spot_fieldset = FieldSet(Spot, data = params, session=session)
     spot_fieldset.validate()
     spot_fieldset.sync()
     ok_(spot_fieldset.model.the_geom is None, 'Geometry is not set to None for empty strings')
Ejemplo n.º 31
0
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

## Initialize fieldsets
GroupDefinition = FieldSet(model.GroupDefinition)
GroupDefinition.configure(pk=False,
                exclude=[GroupDefinition.members]
                )

GroupDefinitionAdd = FieldSet(model.GroupDefinition)
GroupDefinitionAdd.configure(pk=False,
                exclude=[GroupDefinitionAdd.members]
                )
## Initialize grids
GroupDefinitionGrid = Grid(model.GroupDefinition)
GroupDefinitionGrid.configure(pk=False,
                exclude=[GroupDefinitionGrid.members]
                )
Ejemplo n.º 32
0
    def test_deserialize(self):
        params = {'Spot--the_geom': 'Point(0 1)', 'Spot--name': 'dummy'}
        session = FakeSession()

        spot_fieldset = FieldSet(Spot, data = params, session=session)
        spot_fieldset.the_geom.set(options=[('map_srid', 4326)])

        spot_fieldset.validate()
        spot_fieldset.sync()
        ok_(isinstance(spot_fieldset.model.the_geom, WKTSpatialElement), 'Geometry was not assigned to model')
        eq_(str(spot_fieldset.model.the_geom), 'Point(0 1)', 'wkt is wrong')

        params = {'Spot--the_geom': ' ', 'Spot--name': ''}
        spot_fieldset = FieldSet(Spot, data = params, session=session)
        spot_fieldset.validate()
        spot_fieldset.sync()
        ok_(spot_fieldset.model.the_geom is None, 'Geometry is not set to None for empty strings')
Ejemplo n.º 33
0
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

## Initialize fieldsets
Service = FieldSet(model.Service)
Service.configure(pk=False, exclude=[Service.timestamp])

ServiceAdd = FieldSet(model.Service)
ServiceAdd.configure(pk=False, exclude=[ServiceAdd.timestamp])
## Initialize grids
ServiceGrid = Grid(model.Service)
ServiceGrid.configure(pk=False, exclude=[ServiceGrid.timestamp])
Ejemplo n.º 34
0
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

group_definitions = []
for i in meta.Session.query(model.GroupDefinition).all():
    group_definitions.append((i.name,i.id))
    
## Initialize fieldsets
User = FieldSet(model.User)
User.configure(pk=False,
                options=[User.groups.dropdown(options=group_definitions)],
                exclude=[User.password,User.last_login_date,User.created,User.last_login_ip,User.messages_sent,User.messages_by_user]
                )

UserAdd = FieldSet(model.User)
UserAdd.configure(pk=False,
                options=[UserAdd.groups.dropdown(options=group_definitions),
                         UserAdd.verified.checkbox()],
                exclude=[UserAdd.verified,UserAdd.password,UserAdd.last_login_date,UserAdd.created,UserAdd.last_login_ip,UserAdd.messages_sent,UserAdd.messages_by_user]
                )
## Initialize grids
group_definitions = []
for i in model.meta.Session.query(model.GroupDefinition).all():
    group_definitions.append((i.id,i.name))
UserGrid = Grid(model.User)
UserGrid.configure(pk=False,
                options=[UserGrid.groups.dropdown(options=group_definitions)],
                exclude=[UserGrid.password,UserGrid.last_login_date,UserGrid.created,UserGrid.last_login_ip,UserGrid.messages_sent,UserGrid.messages_by_user]
Ejemplo n.º 35
0
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

## Initialize fieldsets
Group = FieldSet(model.Group)
Group.configure(pk=False,
                exclude=[Group.messages_by_group]
                )

GroupAdd = FieldSet(model.Group)
GroupAdd.configure(pk=False,
                exclude=[GroupAdd.messages_by_group]
                )
## Initialize grids
GroupGrid = Grid(model.Group)
GroupGrid.configure(pk=False,
                exclude=[GroupGrid.messages_by_group]
                )
Ejemplo n.º 36
0
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

## Initialize fieldsets
QueueInfo = FieldSet(model.QueueInfo)
QueueInfo.configure(pk=False,
                exclude=[QueueInfo.timestamp]
                )

QueueInfoAdd = FieldSet(model.QueueInfo)
QueueInfoAdd.configure(pk=False,
                exclude=[QueueInfoAdd.timestamp]
                )
## Initialize grids
QueueInfoGrid = Grid(model.QueueInfo)
QueueInfoGrid.configure(pk=False,
                exclude=[QueueInfoGrid.timestamp]
                )
Ejemplo n.º 37
0
from pylons import config
from formalchemy.forms import FieldSet
from formalchemy.tables import Grid

from cyberweb import model
from cyberweb.model import meta

users = []
for i in meta.Session.query(model.User).all():
    users.append((i.username,i.id))

Account = FieldSet(model.Account)
Account.configure(pk=False,
                      exclude=[Account.insert_date]
                     )

AccountAdd = FieldSet(model.Account)
AccountAdd.configure(pk=False,
                      exclude=[AccountAdd.insert_date]
                     )
## Initialize grids
AccountGrid = Grid(model.Account)
AccountGrid.configure(pk=False,
                      options=[AccountGrid.user.dropdown(options=users)],
                      exclude=[AccountGrid.authkey,AccountGrid.password,AccountGrid.insert_date]
                     )
Ejemplo n.º 38
0
 def _set_active(self, instance, session=None):
     FieldSet.rebind(self, instance, session or self.session, self.data)
Ejemplo n.º 39
0
 def _set_active(self, instance, session=None):
     FieldSet.rebind(self, instance, session or self.session, self.data)