* basic SQLAlchemy model
* menu handling code * SQLAlchemy setup in environent.py, base.py and websetup.py
This commit is contained in:
parent
292c102db8
commit
096df406b8
9 changed files with 125 additions and 5 deletions
|
@ -12,15 +12,24 @@ from pylons.templating import render
|
|||
|
||||
import gnuviechadminweb.lib.helpers as h
|
||||
import gnuviechadminweb.model as model
|
||||
from gnuviechadminweb.model import meta
|
||||
|
||||
class BaseController(WSGIController):
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
"""Invoke the Controller"""
|
||||
# WSGIController.__call__ dispatches to the Controller method
|
||||
# the request is routed to. This routing information is
|
||||
# available in environ['pylons.routes_dict']
|
||||
return WSGIController.__call__(self, environ, start_response)
|
||||
conn = meta.engine.connect()
|
||||
meta.Session.configure(bind=conn)
|
||||
c.menu = model.Menu.allowed(session['user'] if 'user' in session \
|
||||
else None)
|
||||
try:
|
||||
# WSGIController.__call__ dispatches to the Controller method
|
||||
# the request is routed to. This routing information is
|
||||
# available in environ['pylons.routes_dict']
|
||||
return WSGIController.__call__(self, environ, start_response)
|
||||
finally:
|
||||
meta.Session.remove()
|
||||
conn.close()
|
||||
|
||||
# Include the '_' function in the public names
|
||||
__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
|
||||
|
|
|
@ -4,3 +4,11 @@ Consists of functions to typically be used within templates, but also
|
|||
available to Controllers. This module is available to both as 'h'.
|
||||
"""
|
||||
from webhelpers import *
|
||||
|
||||
def cssclasses(menuitem):
|
||||
cssclassnames=['menuitem']
|
||||
return " ".join(cssclassnames)
|
||||
|
||||
def menulink(menuitem):
|
||||
return link_to(menuitem.title, url(controller=menuitem.controller,
|
||||
action=menuitem.action))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue