def test_widget_populate(self):
     from sqlalchemy import create_engine
     from sqlalchemy.orm import sessionmaker
     from sqlalchemy.orm import scoped_session
     engine = create_engine('sqlite:///')
     Base.metadata.bind = engine
     Base.metadata.create_all()
     session = scoped_session(sessionmaker(bind=engine))()
     form = SQLAlchemyForm(Address,
                           bootstrap_form_style='form-vertical')
     form.populate_widgets(session)
Esempio n. 2
0
 def get_delete_form(self, request, **pks):
     route_name = self.routes['delete']
     btn = Button(name='submit',
                  title='Delete',
                  type='submit',
                  value='submit')
     form = SQLAlchemyForm(self.cls,
                           action=request.route_url(route_name, **pks),
                           formid=route_name,
                           buttons=(btn,),
                           readonly=True,
                           bootstrap_form_style='form-horizontal')
     session = self.session or getattr(request, self.db_session_key)
     form.populate_widgets(session)
     return form
Esempio n. 3
0
 def get_edit_form(self, context, request, **pks):
     route_name = self.routes['edit']
     edit = Button(name='submit',
                   title='Edit',
                   type='submit',
                   value='submit')
     action = request.route_url(route_name, **pks)
     form = SQLAlchemyForm(self.cls,
                           action=action,
                           formid=route_name,
                           buttons=(edit,),
                           readonly=True,
                           bootstrap_form_style='form-horizontal')
     session = self.session or getattr(request, self.db_session_key)
     form.populate_widgets(session)
     return form
Esempio n. 4
0
 def get_create_form(self, context, request):
     route_name = self.routes['create']
     action = request.route_url(route_name)
     save = Button(name='submit',
                   title='Save',
                   type='submit',
                   value='submit')
     style = 'form-horizontal'
     form = SQLAlchemyForm(self.cls,
                           action=action,
                           formid=route_name,
                           buttons=(save,),
                           bootstrap_form_style=style)
     session = self.session or getattr(request, self.db_session_key)
     form.populate_widgets(session)
     return form