cirfu wrote:
> does webpy support model-view-controller design?
>
well if I can disagree with the author, I'll say mostly. code.py acts
like the controller and template files (under /templates) are the
views. There is no "model" per say - I've had to create my own model.py
file since webpy doesn't provide one (although webpy allows you to add
an ORM or just a model.py). In the model.py file I add the db
connection and create a class for each table - in each class I add the
CRUD type methods
You can combine them into single processor.
def sa_processor(handler):
session = scoped_session(
sessionmaker(
autoflush=True,
transactional=True,
bind=engine
)
)
web.ctx.sadbsession = session
web.ctx.sadb = session()
try:
return handler()
finally:
web.ctx.sadb.close()
web.ctx.sadbsession.remove()
app.add_processor(sa_processor)