yes confirmed, the controller is called multiple times. the reason I
found is that the redirect() statements I use cause this. every
redirect() seems to call the controller, not only the redirection
target function.

for example my index is mainly a redirect function, based on settings
its for instance doing
 redirect(URL(r=request,f='f1'))

then also in other functions I use redirects e.g. based on rights/
settings.

I'm using 1.63.5 on WinXP SP3.

Is there a better function than redirect() for avoiding to call the
general controller stuff multiple times?
Is redirect() supposed to also call the general controller stuff or
only directly the redirection target function ?

Thanks,
Hans
On Jun 4, 10:48 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Odd I think your controller is being called 3 times. Is that possible?
> I would add a print statement to check.
>
> On Jun 4, 2:29 pm, Hans <johann.scheibelho...@easytouch-edv.com>
> wrote:
>
> > I tried to define a global logging for a web2py app. The problem with
> > that is that if I place the following code in my default.py controller
> > or db.py model then in both cases its executed more than
> > once...resulting into having every log line written multiple times
> > into the log file.
>
> > either starting the default.py or db.py with those lines is yielding
> > the same result
> >     import logging, logging.handlers
>
> >     # Make a global logging object.
> >     lox = logging.getLogger("log")
> >     lox.setLevel(logging.DEBUG)
>
> >     # This handler writes everything to a file.
> >     h1 = logging.FileHandler("/var/log/myapp.log")
> >     f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %
> > (lineno)d %(message)s")
> >     h1.setFormatter(f)
> >     h1.setLevel(logging.DEBUG)
> >     lox.addHandler(h1)
>
> >     # This handler emails me anything that is an error or worse.
> >     h2 = logging.handlers.SMTPHandler('localhost', '....@test.com',
> > ['tobenotif...@test.com'], 'ERROR log')
> >     h2.setLevel(logging.ERROR)
> >     h2.setFormatter(f)
> >     lox.addHandler(h2)
>
> > log usage example in controller...
> >     def index():
> >         log = logging.getLogger("log")
> >         log.debug("starting...")
> >         ....do something
> >         log.debug("finishing...")
> >         return()
>
> > log file looks like:
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:45,617 index 1 starting...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
> > DEBUG 2009-06-04 20:27:50,617 index 1 finishing...
>
> > how can I fix the 'multiple problem' ?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to