> So, wherever you are now using request.args(0), you would instead 
> reference something like session.nodeID. If session.nodeID doesn't exist, 
> you then redirect to your router so it can be set.
>

That's what I've been experimenting with the last couple of days, it works 
fine for the single page views, however, nodes can have sites with multiple 
views, and different nodes can be visited in more than one browser window.

In case of sites with multiple views, the router function always routes to 
an index function, in which I build the menu for the current node and store 
it in session[id], this is part of the code:

aboutnav=db((db.NodeNav.nodeID==id)&(db.NodeNav.navID==db.Nav.id)&(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list()
if aboutnav:
session[id].aboutnav=True
for r in aboutnav:
    if r['Nav']['id']==ABOUTNAVID and r['NodeNav']['frontend']:
        session[id].site_menu.append([T(r['Nav']['name']),False,'#'])
    elif r['NodeNav']['frontend']:
        
session[id].about_dropdown.append([T(r['Nav']['name']),False,URL(r['Nav']['frontendcontroller'],r['Nav']['function'],args=id)])
        f=r['Nav']['function']
        if f:
            session[id].f=True

The last three lines, are what I am experimenting with right now. Every 
function that is referenced by a menu item starts with:

def eventList():
    f=request.function
    if not len(request.args):
        redirect(URL('addressbook','router'))
    elif not session[request.args(0)]:
        redirect(URL('addressbook','router',args=request.args(0)))
    elif not session[request.args(0)].f:
        redirect(URL('addressbook','router',args=request.args(0)))
    else:
        ....

So far, this seems to solve the problem.

Is it possible to put these conditions in a separate function, and call 
that function from every function that needs it? Something like:

def access():
    f=request.function
    if not len(request.args):
        redirect(URL('addressbook','router'))
    elif not session[request.args(0)]:
        redirect(URL('addressbook','router',args=request.args(0)))
    elif not session[request.args(0)].f:
        redirect(URL('addressbook','router',args=request.args(0)))
    else:
        return True
    
def eventList():
    if access()
    ....


Kind regards,

Annet

-- 



Reply via email to