def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') from feedduty.models import ( BaseModel, MyModel, ) DBSession.configure(bind=engine) BaseModel.metadata.create_all(engine) with transaction.manager: model = MyModel(name='one', value=55) DBSession.add(model)
def collection_post(self): """ Create new object - Only accepts POST requests on the collection URI """ form = self.form(self.request.POST) obj = self.model() if form.validate(): # extract values from form and populate the feed instance form.populate_obj(obj) # Save the feed to the database DBSession.add(obj) resp = {'success': True, 'result': obj} else: resp = {'success': False, 'errors': {}} return resp