On 8 Aug 2012, at 3:10 AM, Annet <[email protected]> wrote:
> My application is completely nodeID driven, so all front end function run the 
> following test:
> 
> if  not len(request.args) or request.args(0)!=session.id:
>         redirect(URL('addressbook','router',args=request.args(0)))

If you can identify your front-end functions, why not just rewrite 
request.{controller,function} here?

if request.args(0) != session.id:
    request.controller = 'addressbook'
    request.function = 'router'

(Minor point: if len(request.args) is 0, then request.args(0) is None.)

> 
> 
> This is the router function:
> 
> def router():
>     if not len(request.args):
>         session.flash='Aan de URL ontbreken argumenten. Formuleer een 
> zoekopdracht. ' + response.flash_form
>         redirect(URL('addressbook','index'))
>     else:  
>         
> session.organization=session.address=session.telecom=session.account=None
>         session.id=request.args(0)
>         
> account=db(db.NodeAccount.nodeID==session.id).select(db.NodeAccount.ALL).first()
>         if account:
>             if account.statusID!=1:
>                 generateContact(session.id)
>                 redirect(URL('card',args=session.id))
>             elif account.accountID==BASICACCOUNTID:
>                 session.account=BASICACCOUNTID
>                 generateContact(session.id)
>                 redirect(URL('vcard',args=session.id))
>             elif account.accountID==ADVANCEDACCOUNTID:
>                 session.account=ADVANCEDACCOUNTID
>                 generateContact(session.id)
>                 redirect(URL('site','index',args=session.id))
>             elif account.accountID==BASICCONNECTORACCOUNTID:
>                 session.account=BASICCONNECTORACCOUNTID
>                 generateConnectorContact(session.id)
>                 redirect(URL('vconnector',args=session.id))
>             elif account.accountID==ADVANCEDCONNECTORACCOUNTID:
>                 session.account=ADVANCEDCONNECTORACCOUNTID
>                 generateConnectorContact(session.id)
>                 redirect(URL('connector','index',args=session.id))
>         else:
>             generateContact(session.id)
>             redirect(URL('card',args=session.id))
>         return None
> 
> In case request.args(0)!=session.id is True instead of redirecting to a 
> predetermined function I'd like to redirect to the function that redirected 
> to the router. How do I code this?

I'm not following your requirement here. args(0)!=session.id is your condition 
for redirecting to the router, right?

-- 



Reply via email to