[web2py:23813] Re: how to prevent deletion of referenced records
but can I manage warning messages for the user this way? I think could be preferable something at model level Marco --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23814] Re: getHelperById ?
@massimo: thanks for the clarification, I just remember seeing copy.copy-s there which mislead me. But does it work recursively ? @johnmc: I'm talking about server-side helpers, not browser-side html elements On Jun 10, 3:21 am, JohnMc wrote: > If form -- > > $('form').find('#whatever') > > works as well, though slower > > On Jun 9, 5:48 pm, mdipierro wrote: > > > it returns the actual helper, not a copy. > > > On Jun 9, 4:41 pm, AchipA wrote: > > > > Err... I was under the impression div.element only works on direct > > > child nodes and even there it returns just a copy on the helper (not > > > the reference to the actual one). Been quite a while since I looked in > > > html.py, so I might be wrong, though... > > > > On Jun 9, 10:33 pm, mdipierro wrote: > > > > > It is there already: > > > > > form.element(_id='something')['_class']='red' > > > > > On Jun 9, 2:58 pm, AchipA wrote: > > > > > > Another idea while I wait for some of my computations to finish. > > > > > Javascript can access HTML elements in different ways. With web2py > > > > > helpers, this can get a bit cumbersome. How about a generic > > > > > getHelperById method for the base helper class so it goes through it's > > > > > components and fetches the helper with the required id, saving us > > > > > plenty of for cycles/recursion and introspection ? It might especially > > > > > be useful adressing stuff like FORMs (like getting a particular INPUT > > > > > element which might be embedded into layers and layers of helpers > > > > > inside that FORM). --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23815] Re: web2py perfomance
On Jun 10, 7:01 am, Alexey Nezhdanov wrote: > I get these results (best timing): > try-variant: 10.24s > regex: 9.58s > So on my laptop try:except: function loses about 5% to regex - probably it > depends on hardware/OS. Interesting, which python/platform are you using ? > And as Massimo pointed out - we don't really check for an int - we check for > valid id. Function should be remamed, yes. Right, it's more like is_convertible_to_int. Now that we are more clear about what we're looking for, it sounds exactly like string.isdigit() to me. b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" "is_integer=integer_pat.match" 100 loops, best of 3: 3.64 msec per loop b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" "is_integer=integer_pat.match" "for i in s:" " is_integer(i)" 100 loops, best of 3: 9.87 msec per loop b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" "for i in s:" " i.isdigit()" 100 loops, best of 3: 4.63 msec per loop Which gives a 6.2x (!) faster result. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23816] Re: getHelperById ?
Not quite, but has the same effect (hence the copy) for every component processed, it 'adds' the child components to the end of the processing que. So it searches layer by layer On Wed, Jun 10, 2009 at 10:29 AM, AchipA wrote: > > @massimo: thanks for the clarification, I just remember seeing > copy.copy-s there which mislead me. But does it work recursively ? > > @johnmc: I'm talking about server-side helpers, not browser-side html > elements > > On Jun 10, 3:21 am, JohnMc wrote: >> If form -- >> >> $('form').find('#whatever') >> >> works as well, though slower >> >> On Jun 9, 5:48 pm, mdipierro wrote: >> >> > it returns the actual helper, not a copy. >> >> > On Jun 9, 4:41 pm, AchipA wrote: >> >> > > Err... I was under the impression div.element only works on direct >> > > child nodes and even there it returns just a copy on the helper (not >> > > the reference to the actual one). Been quite a while since I looked in >> > > html.py, so I might be wrong, though... >> >> > > On Jun 9, 10:33 pm, mdipierro wrote: >> >> > > > It is there already: >> >> > > > form.element(_id='something')['_class']='red' >> >> > > > On Jun 9, 2:58 pm, AchipA wrote: >> >> > > > > Another idea while I wait for some of my computations to finish. >> > > > > Javascript can access HTML elements in different ways. With web2py >> > > > > helpers, this can get a bit cumbersome. How about a generic >> > > > > getHelperById method for the base helper class so it goes through >> > > > > it's >> > > > > components and fetches the helper with the required id, saving us >> > > > > plenty of for cycles/recursion and introspection ? It might >> > > > > especially >> > > > > be useful adressing stuff like FORMs (like getting a particular INPUT >> > > > > element which might be embedded into layers and layers of helpers >> > > > > inside that FORM). > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23817] Re: global logging to file
WOW Iceberg! That should also work well for me. Thanks for sharing your solution idea! I'm going to try it later today. And I agree the 'uncomment me if you need app-logging' approach in combination with the per-application-log-file seems also to me the best (backward compatible, flexible). Since I'm going to implement that for me anyway I'll send my code when its finised...in case you want to improve it and/or Massimo wants to incorporate it in future web2py versions. On Jun 9, 9:02 pm, Iceberg wrote: > Mmm, even after this log.py goes into models/log.py, I think the line: > logging=cache.ram(...) > should be replaced by: > import logging > # logging=cache.ram(...) # Uncomment me if you need app-logging > > Because: > 1. My log.py will cause the an incremental system.log which will > eventually cram up your disk, hence it is not good for production > site, unless you use RotatingFileHandler instead. > 2. On GAE, you can not write to disk anyway, unless you use > SMTPHandler or HTTPHandler etc. > > You get the idea. //shrug > > On Jun10, 2:45am, Iceberg wrote: > > > I am glad you like it. So every new app will have a models/log.py > > soon? > > > BTW, I personally prefer this formatter, hope you do: > > "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message)s" > > > On Jun10, 2:22am, mdipierro wrote: > > > > I think you nailed it! I would change the file name so that it resides > > > inside the applicaitons folder: > > > > handler=logging.FileHandler(os.path.join(request.folder,"system.log")) > > > > we could also add a line in the admin to peek the log (like with > > > sql.log). > > > > On Jun 9, 12:18 pm, Iceberg wrote: > > > > > request.log(message) would be nice, but all the advantages of standard > > > > logging are too good to let go. So I came up with this little trick. > > > > > Add following codes inside model/log.py: > > > > > def _init_log(): > > > > import logging > > > > logger=logging.getLogger(request.application) > > > > logger.setLevel(logging.DEBUG) > > > > handler=logging.FileHandler("%s.log"%request.application) > > > > handler.setLevel(logging.DEBUG) > > > > handler.setFormatter(logging.Formatter( > > > > "%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message) > > > > s")) > > > > logger.addHandler(handler) > > > > return logger > > > > logging=cache.ram('once',lambda:_init_log(),time_expire=) > > > > > Then, in any of your controller, you can just do the usual: > > > > logging.warn('blah blah') > > > > The only tricky point is you can not do this inside your controller: > > > > import logging > > > > otherwise you lose the magic. ;-) > > > > > Besides, thanks for Hans for bringing up all the issue, which inspires > > > > me to find the solution (at least for me) for this problem haunting me > > > > for long time. > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23818] Re: web2py perfomance
On Wednesday 10 June 2009 12:40:44 AchipA wrote: > On Jun 10, 7:01 am, Alexey Nezhdanov wrote: > > I get these results (best timing): > > try-variant: 10.24s > > regex: 9.58s > > So on my laptop try:except: function loses about 5% to regex - probably > > it depends on hardware/OS. > > Interesting, which python/platform are you using ? Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Ubuntu 8.04 installed on ASUS A6Q00Km (Turion 64 1.6GHz, SiS motherboard, 1.5G RAM). > > And as Massimo pointed out - we don't really check for an int - we check > > for valid id. Function should be remamed, yes. > > Right, it's more like is_convertible_to_int. Now that we are more > clear about what we're looking for, it sounds exactly like > string.isdigit() to me. yes. I thought that there should be such function but failed to find it. Thank you for pointing this out. > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > "is_integer=integer_pat.match" > 100 loops, best of 3: 3.64 msec per loop Hmm? No loop... > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > "is_integer=integer_pat.match" "for i in s:" " is_integer(i)" > 100 loops, best of 3: 9.87 msec per loop roughly the same time here. > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > "for i in s:" " i.isdigit()" > 100 loops, best of 3: 4.63 msec per loop > Which gives a 6.2x (!) faster result. I'm sorry, how do you get 6.2x? 9.87/ 4.63 =2.13 here... And again - you still doing a lot of excess work. First, you populating the list, then you iterate over it. You don't need to do either. Look at my scripts attached. Anyways, my testing results are as follows: I get: 9.84s this time for regex-based 4M calls, 7.70s for function based on 'isdigit' 7.68s for lambda based on 'isdigit' 6.24s for direct 'isdigit' call. So, Massimo, I think it worths replacing globally each is_integer(str(x)) to str(x).isdigit() If you still prefer having is_integer function then here is it: is_integer = lambda x: str(x).isdigit() In this case please rename it to something like is_id. -- Sincerely yours Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- a.py Description: application/python b.py Description: application/python e.py Description: application/python c.py Description: application/python sh Description: application/shellscript d.py Description: application/python
[web2py:23819] Re: Texteditor
That looks nice and easy to implement,but does anyone know if this works with JQuery, since they both hook the onload event, (I think), or is there a different method Thanks in advance Victor On Jun 9, 5:46 pm, pk wrote: > oh thanks, it`s a cool tool. > > peter > > On 9 Jun., 18:16, annet wrote: > > > I am using NicEdit: > > >http://nicedit.com/ > > > Annet. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23820] Re: web2py perfomance
> > > So on my laptop try:except: function loses about 5% to regex - probably > > > it depends on hardware/OS. > > > Interesting, which python/platform are you using ? > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Hm, is it perhaps 32bit ? That could be related to int performance... > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > > "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > "is_integer=integer_pat.match" > > 100 loops, best of 3: 3.64 msec per loop > > Hmm? No loop... Timeit loops, it is looping over your code. So, the above means timeit ran the code 100 times. > I'm sorry, how do you get 6.2x? > 9.87/ 4.63 =2.13 here... Subtract the init (3.6msec) time from both. just wanted to avoid the extra cost of the import. However, even when doing it 'more right' I'm getting a significantly larger number (although unlike my firrst example this does not take into account the varying length of strings). blinky:~# python -m timeit -s "import re" -s "integer_pat=re.compile ('[0-9]+$')" -s "is_integer=integer_pat.match" "is_integer('123')" 100 loops, best of 3: 0.574 usec per loop blinky:~# python -m timeit "'123'.isdigit()" 1000 loops, best of 3: 0.141 usec per loop The problem of your methodology (timing a total run) is that you're averaging out results and polluting the results with load noise from the OS and other apps. Timeit (among other neat tricks) counts the timing of the *BEST* iterations. If one was slower than the other, that means that the other got interrupted somewhere (disk, app, multitaskting, etc). See http://docs.python.org/library/timeit.html , it's quite useful. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23821] Re: web2py perfomance
On Wednesday 10 June 2009 16:31:31 AchipA wrote: > > > > So on my laptop try:except: function loses about 5% to regex - > > > > probably it depends on hardware/OS. > > > > > > Interesting, which python/platform are you using ? > > > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > > Hm, is it perhaps 32bit ? That could be related to int performance... Yes. 64-bit OS was too buggy so after several attempts I gave up and continued using 32bit. > > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > > > "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > > "is_integer=integer_pat.match" > > > 100 loops, best of 3: 3.64 msec per loop > > > > Hmm? No loop... > > Timeit loops, it is looping over your code. So, the above means timeit > ran the code 100 times. > > > I'm sorry, how do you get 6.2x? > > 9.87/ 4.63 =2.13 here... > > Subtract the init (3.6msec) time from both. just wanted to avoid the > extra cost of the import. However, even when doing it 'more right' I'm > getting a significantly larger number (although unlike my firrst > example this does not take into account the varying length of > strings). I see. I'm not sure if we are allowed to do that (substraction) though. > blinky:~# python -m timeit -s "import re" -s "integer_pat=re.compile > ('[0-9]+$')" -s "is_integer=integer_pat.match" "is_integer('123')" > 100 loops, best of 3: 0.574 usec per loop > blinky:~# python -m timeit "'123'.isdigit()" > 1000 loops, best of 3: 0.141 usec per loop > > The problem of your methodology (timing a total run) is that you're > averaging out results and polluting the results with load noise from > the OS and other apps. Timeit (among other neat tricks) counts the > timing of the *BEST* iterations. If one was slower than the other, > that means that the other got interrupted somewhere (disk, app, > multitaskting, etc). > > See http://docs.python.org/library/timeit.html , it's quite useful. I was wondering during my previous testing if I should use only 'minimal' time. Thank you for the link, will read. -- Sincerely yours Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23822] Re: Texteditor
yes. This is done in the admin interface, the htmledit.html view. On Jun 10, 6:48 am, "http://voakujobi.blogspot.com"; wrote: > That looks nice and easy to implement,but does anyone know if this > works with JQuery, since they both hook the onload event, (I think), > or is there a different method > > Thanks in advance > > Victor > > On Jun 9, 5:46 pm, pk wrote: > > > oh thanks, it`s a cool tool. > > > peter > > > On 9 Jun., 18:16, annet wrote: > > > > I am using NicEdit: > > > >http://nicedit.com/ > > > > Annet. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23823] Bing Api
Add full web search capabilities to your app: http://www.reddit.com/r/programming/comments/8rajk/python_wrapper_on_bing_api/ they quote "Django" but this works great with web2py out of the box. Just copy "bingapi.py" into your app "modules" folder and import it. The file consists of 64 lines of code. Massimo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23824] Re: Bing Api
I ported bingapi to web2py: http://www.reddit.com/r/programming/comments/8rdqz/use_bing_search_engine_from_web2py_try_it_here/ I changed it a bit so that it uses web2py's simplejson and web2py's fetch, so that it runs on GAE too. Not you can run on Google and search with Microsoft! Perverse, isn't it? Massimo On Jun 10, 8:22 am, mdipierro wrote: > Add full web search capabilities to your app: > > http://www.reddit.com/r/programming/comments/8rajk/python_wrapper_on_... > > they quote "Django" but this works great with web2py out of the box. > Just copy "bingapi.py" into your app "modules" folder and import it. > The file consists of 64 lines of code. > > Massimo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23825] Re: web2py perfomance
Alexey, I am lost with all the attachments. If there is something you want me to include please send me by email one patch that applies to the lastest trunk. I would not yet include lazy table evals just yet since I need to think more about it. I think there may be an easier way of doing but since I am rewriting the DAL anyway I think it is best to wait. Massimo On Jun 10, 7:48 am, Alexey Nezhdanov wrote: > On Wednesday 10 June 2009 16:31:31 AchipA wrote:> > > > So on my laptop > try:except: function loses about 5% to regex - > > > > > probably it depends on hardware/OS. > > > > > Interesting, which python/platform are you using ? > > > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > > > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > > > Hm, is it perhaps 32bit ? That could be related to int performance... > > Yes. 64-bit OS was too buggy so after several attempts I gave up and continued > using 32bit. > > > > > > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in range(1)]" > > > > "import re" "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > > > "is_integer=integer_pat.match" > > > > 100 loops, best of 3: 3.64 msec per loop > > > > Hmm? No loop... > > > Timeit loops, it is looping over your code. So, the above means timeit > > ran the code 100 times. > > > > I'm sorry, how do you get 6.2x? > > > 9.87/ 4.63 =2.13 here... > > > Subtract the init (3.6msec) time from both. just wanted to avoid the > > extra cost of the import. However, even when doing it 'more right' I'm > > getting a significantly larger number (although unlike my firrst > > example this does not take into account the varying length of > > strings). > > I see. I'm not sure if we are allowed to do that (substraction) though. > > > blinky:~# python -m timeit -s "import re" -s "integer_pat=re.compile > > ('[0-9]+$')" -s "is_integer=integer_pat.match" "is_integer('123')" > > 100 loops, best of 3: 0.574 usec per loop > > blinky:~# python -m timeit "'123'.isdigit()" > > 1000 loops, best of 3: 0.141 usec per loop > > > The problem of your methodology (timing a total run) is that you're > > averaging out results and polluting the results with load noise from > > the OS and other apps. Timeit (among other neat tricks) counts the > > timing of the *BEST* iterations. If one was slower than the other, > > that means that the other got interrupted somewhere (disk, app, > > multitaskting, etc). > > > Seehttp://docs.python.org/library/timeit.html, it's quite useful. > > I was wondering during my previous testing if I should use only 'minimal' > time. Thank you for the link, will read. > > -- > Sincerely yours > Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23826] Re: web2py perfomance
Ok. Basically I'd like you to: 1) apply 'inits2.diff' - it optimises SQLTable.__init__ and SQLField.__init__ 2) remove is_integer altogether and replace it everywhere with str(id).isdigit() 3) apply custom_widget.diff. This one is not perfomance related so please regard it as usual feature request. I do not know if these are applicable against latest trunk and I has something to do tonight so I'll test all this either later today or perhaps tomorrow morning. On Wednesday 10 June 2009 19:36:40 mdipierro wrote: > Alexey, > > I am lost with all the attachments. If there is something you want me > to include please send me by email one patch that applies to the > lastest trunk. I would not yet include lazy table evals just yet since > I need to think more about it. I think there may be an easier way of > doing but since I am rewriting the DAL anyway I think it is best to > wait. > > Massimo > > On Jun 10, 7:48 am, Alexey Nezhdanov wrote: > > On Wednesday 10 June 2009 16:31:31 AchipA wrote:> > > > So on my laptop > > try:except: function loses about 5% to regex - > > > > > > > > probably it depends on hardware/OS. > > > > > > > > > > Interesting, which python/platform are you using ? > > > > > > > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > > > > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > > > > > > Hm, is it perhaps 32bit ? That could be related to int performance... > > > > Yes. 64-bit OS was too buggy so after several attempts I gave up and > > continued using 32bit. > > > > > > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in > > > > > range(1)]" "import re" > > > > > "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > > > > "is_integer=integer_pat.match" > > > > > 100 loops, best of 3: 3.64 msec per loop > > > > > > > > Hmm? No loop... > > > > > > Timeit loops, it is looping over your code. So, the above means timeit > > > ran the code 100 times. > > > > > > > I'm sorry, how do you get 6.2x? > > > > 9.87/ 4.63 =2.13 here... > > > > > > Subtract the init (3.6msec) time from both. just wanted to avoid the > > > extra cost of the import. However, even when doing it 'more right' I'm > > > getting a significantly larger number (although unlike my firrst > > > example this does not take into account the varying length of > > > strings). > > > > I see. I'm not sure if we are allowed to do that (substraction) though. > > > > > blinky:~# python -m timeit -s "import re" -s "integer_pat=re.compile > > > ('[0-9]+$')" -s "is_integer=integer_pat.match" "is_integer('123')" > > > 100 loops, best of 3: 0.574 usec per loop > > > blinky:~# python -m timeit "'123'.isdigit()" > > > 1000 loops, best of 3: 0.141 usec per loop > > > > > > The problem of your methodology (timing a total run) is that you're > > > averaging out results and polluting the results with load noise from > > > the OS and other apps. Timeit (among other neat tricks) counts the > > > timing of the *BEST* iterations. If one was slower than the other, > > > that means that the other got interrupted somewhere (disk, app, > > > multitaskting, etc). > > > > > > Seehttp://docs.python.org/library/timeit.html, it's quite useful. > > > > I was wondering during my previous testing if I should use only 'minimal' > > time. Thank you for the link, will read. > > > > -- > > Sincerely yours > > Alexey Nezhdanov > > -- Sincerely yours Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23827] Re: response.flash upgrade
Before making this post ... > I think it is a good idea to substitute the current calendar with a > more straightforward one. I had a look at the dynarch site, the > calender we use in web2py has been moved to the 'old stuff' > section ... I also had a look at the new dynarch calendar and read the discussion posts. It is definitely more user friendly and with some styling you could add to that. > I would prefer a calendar like the one demonstrated here: ... LIKE the on demonstrated here. It could be any calendar. From an IT point of view the date and date-time, JavaScript load and the number of options are important. I am developing web applications having a psychologist looking over my shoulder, from his point of view developing a web application is all about the limits to human perception and bounded rationality. He asked me whether I really think the average visitor to my site would figure this ... To select a date range, click the start date, then SHIFT+click on the end date. You can also use CTRL+click to select/unselect individual dates. You can use the mouse wheel to scroll through months. If the » or « or “Today” buttons are hovered, scroll through years. Keyboard operations, when the calendar is focused (note you can focus it with TAB): Arrows: highlight a date ENTER: select highlighted date CTRL-ENTER: toggle selection for highlighted date SHIFT-ENTER: select range end PAGE UP/DOWN, or CTRL-LEFT/RIGHT: select month CTRL-UP/DOWN: select year HOME: go Today SPACE: display menu, focus the year entry Type digit: display the menu, begin typing year Type letter: toggle between months that start with that letter (according to selected language) ESC: dismiss menu (if present). Otherwise, dismiss calendar popup if in popup mode ...out, without me providing any clues. Actually I don't. Kind regards, Annet --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23828] Re: Login_next
Massimo, I tried the version in trunk. Problem solved, thanks! Kind regards, Annet --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23829] Re: logging approach
I was involved in the older thread and went ahead used the logging module and haven't had any problems logging to file and to MySQL. I did a bit more research and think it's thread safe. But I haven't had many concurrent users so YMMV. Chris On Jun 9, 4:04 am, mdipierro wrote: > I forgot. Thanks for bringing this up. Let me give it some thought. > > Massimo > > On Jun 8, 9:13 pm, Richard wrote: > > > > > hi, > > > I want to log some requests and came across a thread describing > > potential problems with the logging > > module:http://groups.google.com/group/web2py/browse_thread/thread/3870cb582a... > > > I would rather not manually use open(file, 'w').write(...), so what > > would you suggest as alternative? > > > Massimo hinted: > > "Perhaps there should be a logging command in web2py to avoid the > > problems with the logging module. " > > Has there been any development on this? > > > Richard- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23830] Re: windows service problem in 1.63 (source)
Hi Hans, 2009/6/3 Hans Donner : > > see the docstring in gluon.Winservice > it needs the win32 lib, to be installed seperately. > Yes - sorry, I should have mentioned that I have Mark Hammond's Win32 extensions installed. -- Regards, PhilK Email: p...@xfr.co.uk 'a bell is a cup...until it is struck' --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23831] Re: windows service problem in 1.63 (source)
Hi Massimo, Apologies for the delay in following up. 2009/6/3 mdipierro : > If you start python from the web2py folder, can you do > import gluon.winservice? > If you start python from the gluon folder can you do > import winservice? > Can you edit main and at the bottom insert > print os.getcwd() > When you start web2py as service, what is the output? Is it your > web2py folder? > I've not yet tried the above, as I was contacted off-list by another web2py user who reported that he had patched /gluon/winservice.py at line 141 by updating 'winservice.Web2pyService' to 'gluon.winservice.Web2pyService'. I can confirm that this has worked for me, and I am now running web2py as a service under WinP, and can stop and start the service at the prompt as described in the AlterEgo page and using the Windows applet. (This was under version 1.63.5, freshly downloaded to test today, BTW). Is there anything else I can do to help with this, or does this clarify the issue from your PoV? -- Regards, PhilK Email: p...@xfr.co.uk 'a bell is a cup...until it is struck' --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23832] Re: windows service problem in 1.63 (source)
This is already fixed in trunk. Thanks for bringing it up. Massimo On Jun 10, 12:08 pm, Philip Kilner wrote: > Hi Massimo, > > Apologies for the delay in following up. > > 2009/6/3 mdipierro : > > > If you start python from the web2py folder, can you do > > import gluon.winservice? > > If you start python from the gluon folder can you do > > import winservice? > > Can you edit main and at the bottom insert > > print os.getcwd() > > When you start web2py as service, what is the output? Is it your > > web2py folder? > > I've not yet tried the above, as I was contacted off-list by another > web2py user who reported that he had patched /gluon/winservice.py at > line 141 by updating 'winservice.Web2pyService' to > 'gluon.winservice.Web2pyService'. > > I can confirm that this has worked for me, and I am now running web2py > as a service under WinP, and can stop and start the service at the > prompt as described in the AlterEgo page and using the Windows applet. > > (This was under version 1.63.5, freshly downloaded to test today, BTW). > > Is there anything else I can do to help with this, or does this > clarify the issue from your PoV? > > -- > > Regards, > > PhilK > > Email: p...@xfr.co.uk > > 'a bell is a cup...until it is struck' --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23833] Re: Login_next
On Jun 10, 12:17 am, mdipierro wrote: > Please try the version in trunk. No more request.env.referer. This was r897 right? This has caused problems for my app :/ I have pages which have a List at the top of the page (created by crud.select) & underneath a create form (created by crud.create). With r896 & earlier, submitting a new record would refresh the List. r897 & later need a manual refresh (URL bar otherwise it wants to resubmit the form data) This is reproduceable with the smallest controller like this: def test(): items = crud.select(db.table) form = crud.create(db.table) return dict(items=items, form=form) F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23834] Re: global logging to file
After changing from FileHandler to RotatingFileHandler, now I think the per-app log can be turned on by default (otherwise new comers won't notice this good feature). The only thing I am still not sure is whether one can use logging and its FileHander (or RotatingFileHander) on GAE's readonly filesystem. Tests are welcome. Anyway, this is my latest code. Maybe it can help you. import logging def _init_log(level=logging.DEBUG): import os,logging.handlers logger=logging.getLogger(request.application) logger.setLevel(level) if request.env.web2py_runtime_gae: # if running on Google App Engine handler=logging.handlers.HTTPHandler( request.env.http_host,URL(r=request,f='log')) # assuming there is an optional log action else: handler=logging.handlers.RotatingFileHandler( os.path.join (request.folder,'app.log'),maxBytes=1024*1024,backupCount=2) handler.setLevel(level) handler.setFormatter(logging.Formatter( "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message) s")) logger.addHandler(handler) return logger logging=cache.ram('mylog',lambda:_init_log(),time_expire=) OPTIONAL in controller: def log(): if request.vars: # append history=cache.ram('log_in_cache',lambda:[],time_expire=) history.append(request.vars) cache.ram('log_in_cache',lambda h=history:h,time_expire=0)#set else: # show return {'':TABLE(*[TR(item) for item in cache.ram('log_in_cache',lambda:None,time_expire=)])} On Jun10, 5:52pm, Hans wrote: > WOW Iceberg! That should also work well for me. Thanks for sharing > your solution idea! I'm going to try it later today. > And I agree the 'uncomment me if you need app-logging' approach in > combination with the per-application-log-file seems also to me the > best (backward compatible, flexible). > > Since I'm going to implement that for me anyway I'll send my code when > its finised...in case you want to improve it and/or Massimo wants to > incorporate it in future web2py versions. > > On Jun 9, 9:02 pm, Iceberg wrote: > > > Mmm, even after this log.py goes into models/log.py, I think the line: > > logging=cache.ram(...) > > should be replaced by: > > import logging > > # logging=cache.ram(...) # Uncomment me if you need app-logging > > > Because: > > 1. My log.py will cause the an incremental system.log which will > > eventually cram up your disk, hence it is not good for production > > site, unless you use RotatingFileHandler instead. > > 2. On GAE, you can not write to disk anyway, unless you use > > SMTPHandler or HTTPHandler etc. > > > You get the idea. //shrug > > > > > On Jun10, 2:22am, mdipierro wrote: > > > > > I think you nailed it! I would change the file name so that it resides > > > > inside the applicaitons folder: > > > > > handler=logging.FileHandler(os.path.join(request.folder,"system.log")) > > > > > we could also add a line in the admin to peek the log (like with > > > > sql.log). > > > > > On Jun 9, 12:18 pm, Iceberg wrote: > > > > > > request.log(message) would be nice, but all the advantages of standard > > > > > logging are too good to let go. So I came up with this little trick. > > > > > > Add following codes inside model/log.py: > > > > > > def _init_log(): > > > > > import logging > > > > > logger=logging.getLogger(request.application) > > > > > logger.setLevel(logging.DEBUG) > > > > > handler=logging.FileHandler("%s.log"%request.application) > > > > > handler.setLevel(logging.DEBUG) > > > > > handler.setFormatter(logging.Formatter( > > > > > "%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message) > > > > > s")) > > > > > logger.addHandler(handler) > > > > > return logger > > > > > logging=cache.ram('once',lambda:_init_log(),time_expire=) > > > > > > Then, in any of your controller, you can just do the usual: > > > > > logging.warn('blah blah') > > > > > The only tricky point is you can not do this inside your controller: > > > > > import logging > > > > > otherwise you lose the magic. ;-) > > > > > > Besides, thanks for Hans for bringing up all the issue, which inspires > > > > > me to find the solution (at least for me) for this problem haunting me > > > > > for long time. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23835] Re: web2py perfomance
Most of what you proposed is already in trunk (althought in s lightly different way). I added what was missing. Mind that it is not form.custom.widget.submit but form.custom.submit. Massimo On Jun 10, 11:10 am, Alexey Nezhdanov wrote: > Ok. > > Basically I'd like you to: > 1) apply 'inits2.diff' - it optimises SQLTable.__init__ and SQLField.__init__ > 2) remove is_integer altogether and replace it everywhere with > str(id).isdigit() > 3) apply custom_widget.diff. This one is not perfomance related so please > regard it as usual feature request. > > I do not know if these are applicable against latest trunk and I has something > to do tonight so I'll test all this either later today or perhaps tomorrow > morning. > > On Wednesday 10 June 2009 19:36:40 mdipierro wrote: > > > > > Alexey, > > > I am lost with all the attachments. If there is something you want me > > to include please send me by email one patch that applies to the > > lastest trunk. I would not yet include lazy table evals just yet since > > I need to think more about it. I think there may be an easier way of > > doing but since I am rewriting the DAL anyway I think it is best to > > wait. > > > Massimo > > > On Jun 10, 7:48 am, Alexey Nezhdanov wrote: > > > On Wednesday 10 June 2009 16:31:31 AchipA wrote:> > > > So on my laptop > > > try:except: function loses about 5% to regex - > > > > > > > > probably it depends on hardware/OS. > > > > > > > Interesting, which python/platform are you using ? > > > > > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > > > > > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > > > > > Hm, is it perhaps 32bit ? That could be related to int performance... > > > > Yes. 64-bit OS was too buggy so after several attempts I gave up and > > > continued using 32bit. > > > > > > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in > > > > > > range(1)]" "import re" > > > > > > "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > > > > > "is_integer=integer_pat.match" > > > > > > 100 loops, best of 3: 3.64 msec per loop > > > > > > Hmm? No loop... > > > > > Timeit loops, it is looping over your code. So, the above means timeit > > > > ran the code 100 times. > > > > > > I'm sorry, how do you get 6.2x? > > > > > 9.87/ 4.63 =2.13 here... > > > > > Subtract the init (3.6msec) time from both. just wanted to avoid the > > > > extra cost of the import. However, even when doing it 'more right' I'm > > > > getting a significantly larger number (although unlike my firrst > > > > example this does not take into account the varying length of > > > > strings). > > > > I see. I'm not sure if we are allowed to do that (substraction) though. > > > > > blinky:~# python -m timeit -s "import re" -s "integer_pat=re.compile > > > > ('[0-9]+$')" -s "is_integer=integer_pat.match" "is_integer('123')" > > > > 100 loops, best of 3: 0.574 usec per loop > > > > blinky:~# python -m timeit "'123'.isdigit()" > > > > 1000 loops, best of 3: 0.141 usec per loop > > > > > The problem of your methodology (timing a total run) is that you're > > > > averaging out results and polluting the results with load noise from > > > > the OS and other apps. Timeit (among other neat tricks) counts the > > > > timing of the *BEST* iterations. If one was slower than the other, > > > > that means that the other got interrupted somewhere (disk, app, > > > > multitaskting, etc). > > > > > Seehttp://docs.python.org/library/timeit.html, it's quite useful. > > > > I was wondering during my previous testing if I should use only 'minimal' > > > time. Thank you for the link, will read. > > > > -- > > > Sincerely yours > > > Alexey Nezhdanov > > -- > Sincerely yours > Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23836] Re: Login_next
Fran, I do not think this is creating the problem. Crud is still redirecting UNLESS you set crud.settings.keepvalues=True. If this what you are doing? Can you tell which lines causes the problem? Massimo On Jun 10, 1:41 pm, Fran wrote: > On Jun 10, 12:17 am, mdipierro wrote: > > > Please try the version in trunk. No more request.env.referer. > > This was r897 right? > > This has caused problems for my app :/ > > I have pages which have a List at the top of the page (created by > crud.select) & underneath a create form (created by crud.create). > With r896 & earlier, submitting a new record would refresh the List. > r897 & later need a manual refresh (URL bar otherwise it wants to > resubmit the form data) > > This is reproduceable with the smallest controller like this: > def test(): > items = crud.select(db.table) > form = crud.create(db.table) > return dict(items=items, form=form) > > F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23837] Re: web2py perfomance
В сообщении от Wednesday 10 June 2009 22:45:02 mdipierro написал(а): > Most of what you proposed is already in trunk (althought in s lightly > different way). I added what was missing. > > Mind that it is not form.custom.widget.submit but form.custom.submit. Ok, thank you. Will have a look at the trunk tomorrow morning. > Massimo > > On Jun 10, 11:10 am, Alexey Nezhdanov wrote: > > Ok. > > > > Basically I'd like you to: > > 1) apply 'inits2.diff' - it optimises SQLTable.__init__ and > > SQLField.__init__ 2) remove is_integer altogether and replace it > > everywhere with > > str(id).isdigit() > > 3) apply custom_widget.diff. This one is not perfomance related so please > > regard it as usual feature request. > > > > I do not know if these are applicable against latest trunk and I has > > something to do tonight so I'll test all this either later today or > > perhaps tomorrow morning. > > > > On Wednesday 10 June 2009 19:36:40 mdipierro wrote: > > > Alexey, > > > > > > I am lost with all the attachments. If there is something you want me > > > to include please send me by email one patch that applies to the > > > lastest trunk. I would not yet include lazy table evals just yet since > > > I need to think more about it. I think there may be an easier way of > > > doing but since I am rewriting the DAL anyway I think it is best to > > > wait. > > > > > > Massimo > > > > > > On Jun 10, 7:48 am, Alexey Nezhdanov wrote: > > > > On Wednesday 10 June 2009 16:31:31 AchipA wrote:> > > > So on my > > > > laptop try:except: function loses about 5% to regex - > > > > > > > > > > > > probably it depends on hardware/OS. > > > > > > > > > > > > > > Interesting, which python/platform are you using ? > > > > > > > > > > > > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > > > > > > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > > > > > > > > > > Hm, is it perhaps 32bit ? That could be related to int > > > > > performance... > > > > > > > > Yes. 64-bit OS was too buggy so after several attempts I gave up and > > > > continued using 32bit. > > > > > > > > > > > b...@black:/tmp$ python -m timeit "s=[str(i) for i in > > > > > > > range(1)]" "import re" > > > > > > > "integer_pat=re.compile('[+-]?[0-9]{1,15}$')" > > > > > > > "is_integer=integer_pat.match" > > > > > > > 100 loops, best of 3: 3.64 msec per loop > > > > > > > > > > > > Hmm? No loop... > > > > > > > > > > Timeit loops, it is looping over your code. So, the above means > > > > > timeit ran the code 100 times. > > > > > > > > > > > I'm sorry, how do you get 6.2x? > > > > > > 9.87/ 4.63 =2.13 here... > > > > > > > > > > Subtract the init (3.6msec) time from both. just wanted to avoid > > > > > the extra cost of the import. However, even when doing it 'more > > > > > right' I'm getting a significantly larger number (although unlike > > > > > my firrst example this does not take into account the varying > > > > > length of strings). > > > > > > > > I see. I'm not sure if we are allowed to do that (substraction) > > > > though. > > > > > > > > > blinky:~# python -m timeit -s "import re" -s > > > > > "integer_pat=re.compile ('[0-9]+$')" -s > > > > > "is_integer=integer_pat.match" "is_integer('123')" 100 loops, > > > > > best of 3: 0.574 usec per loop > > > > > blinky:~# python -m timeit "'123'.isdigit()" > > > > > 1000 loops, best of 3: 0.141 usec per loop > > > > > > > > > > The problem of your methodology (timing a total run) is that you're > > > > > averaging out results and polluting the results with load noise > > > > > from the OS and other apps. Timeit (among other neat tricks) counts > > > > > the timing of the *BEST* iterations. If one was slower than the > > > > > other, that means that the other got interrupted somewhere (disk, > > > > > app, multitaskting, etc). > > > > > > > > > > Seehttp://docs.python.org/library/timeit.html, it's quite useful. > > > > > > > > I was wondering during my previous testing if I should use only > > > > 'minimal' time. Thank you for the link, will read. > > > > > > > > -- > > > > Sincerely yours > > > > Alexey Nezhdanov > > > > -- > > Sincerely yours > > Alexey Nezhdanov > > -- Sincerely yours Alexey Nezhdanov --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23838] Re: web2py solution for debbuging with FirePHP/Firebug
Newer version uploaded and accessible by the link above. You can see screenshot of what you'll get: http://www.picamatic.com/view/3948659_109510221650-My-Desktop/ What's added: - skipping web2py debug messages (starts with "WEB2PY CRON") - situations: you have a page with self-submitting form or one view redirects to other, and all them executes some db queries; now you can see the request path and method (post/get) of latest executed http requests. If db queries are executed within one http request than this column is hidden. - you can see a very simple stack trace of code execution that initializes each db query. See screenshot. This feature is still alpha. TODO: - show some caching system statistics in form of db query stats (as FirePHP table): which keys are got, set and so on. - checking for duplicating db queries and highlighting them. On 3 июн, 18:00, mdipierro wrote: > You are now officially our firebug expert! > > Massimo > > On Jun 3, 5:19 am, sgtpep wrote: > > > > > Unfortunately I have no expirience in screencasting, and my English is > > buggy. > > > Debugging/logging tool is very useful thing for web development. I > > really like this one in Symfony framework (it is included to Symfony > > and made with JavaScript, screenshot > > -http://www.symfony-project.org/blog/2008/08/27/new-in-symfony-1-2-cus...). > > For Django there is third-party module Django Debug Toolbar (http:// > > rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/). > > > I think the most valuable things that this type of tools can show for > > developer are: accessible report to server-side logs pre request, info > > about queries executed during request and maybe some cache stats and > > variables list. > > > Firebug (http://getfirebug.com/) is the most popular Firefox extension > > for web developent, very handy and well-built. It implements > > JavaScript console, DOM traversing, JS-debugging and lot more. FirePHP > > (http://www.firephp.org/) is another extension that uses Firebug > > interface and resources and therefore requires Firebug for work. You > > can see demo here (Firefox with both extensions required, open and > > enable Firebug console to see output) > > -http://www.firephp.org/Examples/PHPArchitect/. > > In two words, FirePHP allows you to output log messages that you > > passed from PHP code, displays executed db queries, stack trace of > > exceptions, etc. It requires of using PHP class FirePHPCore/ > > FirePHP.class.php. Firepy (documentation and screenshot > > -http://code.google.com/p/firepy/wiki/Documentation) is the > > implementation for Python of the server-side FirePHP library, but it > > uses the same Firefox extension (FirePHP). And it includes Middleware > > for using with Django, but you can easily adopt it for any Python > > framework. > > > How-to for using FirePHP with web2py: > > 1) Open Firefox, install Firebug, FirePHP > > addons:https://addons.mozilla.org/ru/firefox/addon/1843,https://addons.mozil > > Restart browser. > > 2) Downloadhttp://www.box.net/shared/dtm0dhgze9andextract 'firepy' > > folder. > > 3) Open directory with your current web2py application, and copy > > 'firepy' folder into 'modules' directory of application. > > 4) Edit first file in 'models' folder in your application (via web- or > > desktop-editor). Place these lines in top of the file: > > > import sys > > sys.path += ['applications/%s/modules' % request.application] > > from firepy.web2py import start_firepy > > start_firepy(globals()) > > > 5) Edit some controller file and add this line to some controller > > function: logging.debug([1, {"asdf":(123, 2, "3")}, "3"]) > > 6) Click on bug icon on bottom status line of Firefox. This will bring > > up panel. Check the checkbox "Console" and click "Apply settings". > > Ensure that tab "Console" is showing. > > 7) Navigate from browser to this application/controller/function. And > > now you should see your logging output in console ([1, {"asdf":(123, > > 2, "3")}, "3"]). If controller executes some db queries, then console > > will contain some info about them (sample > > screenshothttp://firepy.googlecode.com/files/firepy.png). This is very > > interesting to know raw SQL-queries (especially for eduction, and for > > finding redundant or duplicating queries). > > > Notice: Logs shows only if you are autorized in admin application. > > This check prevents from showing debugging logs for non- > > administrators. > > > One disadvantage of this way is that it requires Firefox. But if you > > open your site in other browsers no errors will occur (logging info > > passes via HTTP headers). One possible way to support other browsers > > is to use Firebug Lite (pure JS implementation of extension) for them > > (http://getfirebug.com/lite.html) and modify or extend its code for > > adding FirePHP functionality. > > > BTW, web2py is great, I really was charmed with it. It is most pytonic > > web framework and more flexible than most of them (I t
[web2py:23839] slides in keynote and ppt
I posted the slides in Keynote format http://www.web2py.com/examples/static/cookbook2.key.zip and PowerPoint format http://www.web2py.com/examples/static/cookbook2.ppt.zip Sould be nice if you could add slides about - IS_IN_DB - IS_NOT_IN_DB - form.custom.widget - CRON Massimo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23840] Re: web2py solution for debbuging with FirePHP/Firebug
How do you propose we include this in web2py? Should I just dump it in contrib? I have a feeling this should integrated with the logging function recently proposed (for that what is logged is also sent to firebug). What do you think? Massimo On Jun 10, 2:12 pm, sgtpep wrote: > Newer version uploaded and accessible by the link above. > > You can see screenshot of what you'll > get:http://www.picamatic.com/view/3948659_109510221650-My-Desktop/ > > What's added: > - skipping web2py debug messages (starts with "WEB2PY CRON") > - situations: you have a page with self-submitting form or one view > redirects to other, and all them executes some db queries; now you can > see the request path and method (post/get) of latest executed http > requests. If db queries are executed within one http request than this > column is hidden. > - you can see a very simple stack trace of code execution that > initializes each db query. See screenshot. This feature is still > alpha. > > TODO: > - show some caching system statistics in form of db query stats (as > FirePHP table): which keys are got, set and so on. > - checking for duplicating db queries and highlighting them. > > On 3 июн, 18:00, mdipierro wrote: > > > You are now officially our firebug expert! > > > Massimo > > > On Jun 3, 5:19 am, sgtpep wrote: > > > > Unfortunately I have no expirience in screencasting, and my English is > > > buggy. > > > > Debugging/logging tool is very useful thing for web development. I > > > really like this one in Symfony framework (it is included to Symfony > > > and made with JavaScript, screenshot > > > -http://www.symfony-project.org/blog/2008/08/27/new-in-symfony-1-2-cus...). > > > For Django there is third-party module Django Debug Toolbar (http:// > > > rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/). > > > > I think the most valuable things that this type of tools can show for > > > developer are: accessible report to server-side logs pre request, info > > > about queries executed during request and maybe some cache stats and > > > variables list. > > > > Firebug (http://getfirebug.com/) is the most popular Firefox extension > > > for web developent, very handy and well-built. It implements > > > JavaScript console, DOM traversing, JS-debugging and lot more. FirePHP > > > (http://www.firephp.org/) is another extension that uses Firebug > > > interface and resources and therefore requires Firebug for work. You > > > can see demo here (Firefox with both extensions required, open and > > > enable Firebug console to see output) > > > -http://www.firephp.org/Examples/PHPArchitect/. > > > In two words, FirePHP allows you to output log messages that you > > > passed from PHP code, displays executed db queries, stack trace of > > > exceptions, etc. It requires of using PHP class FirePHPCore/ > > > FirePHP.class.php. Firepy (documentation and screenshot > > > -http://code.google.com/p/firepy/wiki/Documentation) is the > > > implementation for Python of the server-side FirePHP library, but it > > > uses the same Firefox extension (FirePHP). And it includes Middleware > > > for using with Django, but you can easily adopt it for any Python > > > framework. > > > > How-to for using FirePHP with web2py: > > > 1) Open Firefox, install Firebug, FirePHP > > > addons:https://addons.mozilla.org/ru/firefox/addon/1843,https://addons.mozil > > > Restart browser. > > > 2) Downloadhttp://www.box.net/shared/dtm0dhgze9andextract'firepy' > > > folder. > > > 3) Open directory with your current web2py application, and copy > > > 'firepy' folder into 'modules' directory of application. > > > 4) Edit first file in 'models' folder in your application (via web- or > > > desktop-editor). Place these lines in top of the file: > > > > import sys > > > sys.path += ['applications/%s/modules' % request.application] > > > from firepy.web2py import start_firepy > > > start_firepy(globals()) > > > > 5) Edit some controller file and add this line to some controller > > > function: logging.debug([1, {"asdf":(123, 2, "3")}, "3"]) > > > 6) Click on bug icon on bottom status line of Firefox. This will bring > > > up panel. Check the checkbox "Console" and click "Apply settings". > > > Ensure that tab "Console" is showing. > > > 7) Navigate from browser to this application/controller/function. And > > > now you should see your logging output in console ([1, {"asdf":(123, > > > 2, "3")}, "3"]). If controller executes some db queries, then console > > > will contain some info about them (sample > > > screenshothttp://firepy.googlecode.com/files/firepy.png). This is very > > > interesting to know raw SQL-queries (especially for eduction, and for > > > finding redundant or duplicating queries). > > > > Notice: Logs shows only if you are autorized in admin application. > > > This check prevents from showing debugging logs for non- > > > administrators. > > > > One disadvantage of this way is that it requires Firefox. But if you > > > open your site
[web2py:23841] Re: global logging to file
Why do you need to cache the logging module? Is this only for speed? On Jun 10, 1:44 pm, Iceberg wrote: > After changing from FileHandler to RotatingFileHandler, now I think > the per-app log can be turned on by default (otherwise new comers > won't notice this good feature). > > The only thing I am still not sure is whether one can use logging and > its FileHander (or RotatingFileHander) on GAE's readonly filesystem. > Tests are welcome. > > Anyway, this is my latest code. Maybe it can help you. > > import logging > def _init_log(level=logging.DEBUG): > import os,logging.handlers > logger=logging.getLogger(request.application) > logger.setLevel(level) > if request.env.web2py_runtime_gae: # if running on Google App > Engine > handler=logging.handlers.HTTPHandler( > request.env.http_host,URL(r=request,f='log')) # assuming there > is an optional log action > else: > handler=logging.handlers.RotatingFileHandler( > os.path.join > (request.folder,'app.log'),maxBytes=1024*1024,backupCount=2) > handler.setLevel(level) > handler.setFormatter(logging.Formatter( > "%(asctime)s %(levelname)s %(funcName)s():%(lineno)d %(message) > s")) > logger.addHandler(handler) > return logger > logging=cache.ram('mylog',lambda:_init_log(),time_expire=) > > OPTIONAL in controller: > > def log(): > if request.vars: # append > history=cache.ram('log_in_cache',lambda:[],time_expire=) > history.append(request.vars) > cache.ram('log_in_cache',lambda h=history:h,time_expire=0)#set > else: # show > return {'':TABLE(*[TR(item) for item in > cache.ram('log_in_cache',lambda:None,time_expire=)])} > > On Jun10, 5:52pm, Hans wrote: > > > WOW Iceberg! That should also work well for me. Thanks for sharing > > your solution idea! I'm going to try it later today. > > And I agree the 'uncomment me if you need app-logging' approach in > > combination with the per-application-log-file seems also to me the > > best (backward compatible, flexible). > > > Since I'm going to implement that for me anyway I'll send my code when > > its finised...in case you want to improve it and/or Massimo wants to > > incorporate it in future web2py versions. > > > On Jun 9, 9:02 pm, Iceberg wrote: > > > > Mmm, even after this log.py goes into models/log.py, I think the line: > > > logging=cache.ram(...) > > > should be replaced by: > > > import logging > > > # logging=cache.ram(...) # Uncomment me if you need app-logging > > > > Because: > > > 1. My log.py will cause the an incremental system.log which will > > > eventually cram up your disk, hence it is not good for production > > > site, unless you use RotatingFileHandler instead. > > > 2. On GAE, you can not write to disk anyway, unless you use > > > SMTPHandler or HTTPHandler etc. > > > > You get the idea. //shrug > > > > > On Jun10, 2:22am, mdipierro wrote: > > > > > > I think you nailed it! I would change the file name so that it resides > > > > > inside the applicaitons folder: > > > > > > handler=logging.FileHandler(os.path.join(request.folder,"system.log")) > > > > > > we could also add a line in the admin to peek the log (like with > > > > > sql.log). > > > > > > On Jun 9, 12:18 pm, Iceberg wrote: > > > > > > > request.log(message) would be nice, but all the advantages of > > > > > > standard > > > > > > logging are too good to let go. So I came up with this little trick. > > > > > > > Add following codes inside model/log.py: > > > > > > > def _init_log(): > > > > > > import logging > > > > > > logger=logging.getLogger(request.application) > > > > > > logger.setLevel(logging.DEBUG) > > > > > > handler=logging.FileHandler("%s.log"%request.application) > > > > > > handler.setLevel(logging.DEBUG) > > > > > > handler.setFormatter(logging.Formatter( > > > > > > "%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message) > > > > > > s")) > > > > > > logger.addHandler(handler) > > > > > > return logger > > > > > > logging=cache.ram('once',lambda:_init_log(),time_expire=) > > > > > > > Then, in any of your controller, you can just do the usual: > > > > > > logging.warn('blah blah') > > > > > > The only tricky point is you can not do this inside your controller: > > > > > > import logging > > > > > > otherwise you lose the magic. ;-) > > > > > > > Besides, thanks for Hans for bringing up all the issue, which > > > > > > inspires > > > > > > me to find the solution (at least for me) for this problem haunting > > > > > > me > > > > > > for long time. --~--~-~--~~~---~--~~ 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=e
[web2py:23842] Stuck again...
I have this fancy little help from you guys... But I can't quite seem to work with the data the way I like. Basically, I want to display a list of all users that have similar tags that I do. So I would get something like this: Tag Name 1 -- Massimo -- Jukka -- Billy Tag Name 2 -- Massimo -- Jukka Tag Name 3 -- Billy It's for a tag cloud I am making. This is the function: def status(): current_user_id=auth.user.id tags = db((db.users.id==db.user_tags.user_id) &(db.user_tags.tag_id==db.tag.id) &(db.user_tags.tag_id.belongs( db(db.user_tags.user_id==current_user_id)._select( db.user_tags.tag_id.select( db.users.ALL,db.tag.ALL,groupby=db.users.id) #Find all the users and put their tags into a list. singleTag = {} for tag in tags: if singleTag.has_key(tag.tag.id): singleTag[db(db.tag.id==tag.tag.id).select()].append(tag) else: singleTag[db(db.tag.id==tag.tag.id).select()] = [tag] response.title = "Your Profile Page" userForm = SQLFORM(db.users) if userForm.accepts(request.vars): response.flash='User Added!' elif userForm.errors: response.flash='Hmm... Something is wrong here...' return dict(tags= tags, userForm = userForm, today=today, user = auth.user, singleTag=singleTag) And the view: {{for interests in singleTag.keys():}} {{for interest in interests:}} {{=interest.name}} {{pass}} {{for user in singleTag[interests]:}} {{=user.users.first_name}} {{pass}} {{pass}} That get's me close... As you may notice, I like programming more than databases. :P But I prolly should learn more about those db's :D Any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23843] Controlling lazy T
I am using web2py on GAE. I am sending emails using GAE. I'd delimited the subject line with T ( ... ) and, you guessed it, GAE didn't like it at all. How can I have the subject string translated *before* the call to GAE's platform? example code: bSuccess = mail.send(to=to,subject=T('Lazy subjects'),message=message) Carl --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23844] Re: Custom Display Values
Massimo, Thank you so much for your feedback. Most of the changes you suggested certainly made the code simpler and easier to read, but I have a couple of issues that I don't understand. 1) It appears that the line: getattr(crud,session.action)(db[tablename],record) executes the crud call, but I don't understand how getattr() does that. Could you provide a brief explanation? 2) If I directly return the dictionary that results from setsubmit (tablename), what would the format of the return be and what should the variables in the form be named? I tried a couple of combinations (widgets, inpval, dspval) , but they all failed (widget) carried extra data (impval) or failed to display an on update. 3) In thefields(), the value of curform is: Poleno: EBW 1234Town Id: 1 . and curform.record is: at 0x9ff80d4>, 'npolesize': None, 'notifydate': datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': 1, Please notice that in both places, the value of town_id is 1 and not the value in the related table. When I set mydict = dict(form=curform) is was able to fix a syntax error 'mydict does not exist' but I'm not sure that's the right thing to do. However, the real problem is an error message that says curform.custom.widget is not iterable. Even if it fixes it, I'm still not sure what the variables in the form should be named. It seems that the original code that was generated using components[0] accomplished everything except providing the current values of 'lookup' fields in display mode. When used for add or update, they worked as expected - including error messages. I assume that the custom fields are meant to provide the same functionality, but I must be using them incorrectly. You help is greatly appreciated. On Jun 9, 11:34 pm, mdipierro wrote: > Allow me simplify it, else I do not understand it: > > def managetable(): > (tablename, id) = (request.args(0), request.args(1)) # can be > None > response.view = "%s/%s.html" % (request.controller, > tablename) > return thefields(setsubmit(tablename)) > # why not return dict(form=setsubmit(tablename)) ? > > # this I do not understand > # if session.signon[session.searchfield]: managetable = eval > # (session.signon[session.searchfield]+"(managetable)") > > def setsubmit(tablename,record=None): > if request.vars.submit1: command="create" > elif request.vars.submit2: command="read" > elif request.vars.submit3: command="update" > elif request.vars.submit4: command="delete" > return getattr(crud,command)(db[tablename],record) > > def thefields(curform): > mydict(form=curform) > for fieldname in curform.record: > if fieldname in curform.custom.widget: > mydict[fieldname] = curform.custom.widget[fieldname] > return mydict > > {{extend 'layout.html'}} > {{action = request.args(0)}} > location > {{if action == "update":}} Update > {{elif action == "create":}} Add > {{pass}} > > > > > Poleno: > > {{if action in ["update","create"]:}} > {{=" *** location_poleno"}} > {{else:}} > {{=form.custom.widget.poleno}} > {{pass}} > > > > id="location_town_id__label">Town > > Id: > {{if action in ["update","create"]:}} > {{=" *** location_town_id"}} > {{else:}} > > {{=form.custom.widget.town_id}} > {{pass}} > > > > Does this work as expected? I do not underatnd it well enough to > debug. sorry. > > Massimo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23845] Re: Login_next
On Jun 10, 7:48 pm, mdipierro wrote: > I do not think this is creating the problem. Crud is still redirecting > UNLESS you set crud.settings.keepvalues=True. If this what you are > doing? Yes, well done :) Can this be made to just take effect on 'update' not 'create' forms? (Didn't seem to work on create anyway) F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23846] Re: slides in keynote and ppt
On Jun 10, 8:12 pm, mdipierro wrote: > I posted the slides in Keynote format > http://www.web2py.com/examples/static/cookbook2.key.zip Works, but I don't have a Mac > and PowerPoint format > http://www.web2py.com/examples/static/cookbook2.ppt.zip 'Invalid request' F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23847] Re: how to prevent deletion of referenced records
Sqlite does offer triggers, tho. Is it possible to rewrite the ON DELETE...RESTRICT as a trigger and add it with pass-thru sql commands? On Jun 9, 6:56 am, carlo wrote: > Foreign key constraints are not implemented in Sqlite (although it > parses the command). > > See:http://www.sqlite.org/omitted.html > > but you can use triggers. > > carlo > > On 9 Giu, 15:46, annet wrote: > > > Marco, > > > Did you test this in Sqlite: > > > db.define_table('table', > > db.Field('field',...,ondelete='RESTRICT'), > > migrate='table.table') > > > It does set the ON DELETE to RESTRICT in the foreign key constraint in > > Postres. > > > Annet. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23848] Re: windows service problem in 1.63 (source)
Hi Massimo, 2009/6/10 mdipierro : > This is already fixed in trunk. Thanks for bringing it up. > Any objection to my adding a note to the AlterEgo page to help until that makes it into a release? (Feels like a silly question - meaning that I think I should, unless that release will be RSN - but am new here so sanity checking ettiquette) -- Regards, PhilK Email: p...@xfr.co.uk 'a bell is a cup...until it is struck' --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23849] Re: redirect
Massimo, Sorry for the delay. Work had me unplugged for a while. Hilights -- * trigger() just there to pop the form. * dwnld() I just took right out of your 'Rolling with...' document. * The jQuery set is on the input field and is bound to a double click. * The call to dwnld() is hardcoded for simplicity sake. * No validation applied and the file in question is assumed to be available in the upload directory. Technically its not a redirect, but does achieve what Fran was discussing. On my Linux clients, with Adobe 9/10 loaded, if the file is a PDF adobe comes up in the window with the file in view. Application(test): -- Controller(filedwn.py): -- # try something like def index(): return dict(message="hello from filedwn.py") def dwnld(): import gluon.contenttype filename=request.args[0] response.headers['Content-Type']=\ gluon.contenttype.contenttype(filename) return open('applications/%s/uploads/%s' % (request.application,filename),'rb').read() def trigger(): return dict() View(filedwn/trigger.html): - {{extend 'layout.html'}} //Set events for form $(document).ready(function() { //Bind getfile() to double click event $('form').find('#file_dwnld').css('color','blue').bind ('dblclick',function(){getfile();}); }); function getfile(){ var text = $('#file_dwnld').val(); var link = "/test/filedwn/dwnld/" + text; window.open (link,"mywindow","scrollbars=1,resizeable=1,width=600,heigth=450"); }; This is the filedwn example On Jun 9, 9:49 pm, mdipierro wrote: > could you post an example > > On Jun 9, 8:07 pm, JohnMc wrote: > > > Fran, > > > I do something very similar in jQuery. Bind a object to an event and > > use a anonymous function that calls Windows.Open(). The new window > > could call a download function. But I guess at that point its not a > > redirect. > > > JohnMc > > > On Jun 9, 1:56 pm, Fran wrote: > > > > On Jun 9, 7:19 pm, mdipierro wrote: > > > > > If your intention is to return the PDF to the > > > > user (http 200 ok) you cannot redirect (http 303 redirect). The two > > > > statements are not compatible. > > > > Whilst at first sight I'd say that's true, what could be done is to > > > return the PDF in another Window/Tab (A target="_blank") & then do the > > > redirect. > > > I would do this by calling the PDF controller function from a wrapper > > > function which has that page. > > > > F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23850] Using count in a where clause
Hi, I'm trying to do a query in which I use select() with count and groupby db().select(field1, field1.count(), groupby=field2) but I'd like to be able to use the count column to limit the results, adding a where clause to the SQL, something like "where count > x" Is that possible? how? Thanks, Marcos. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23851] Re: Controlling lazy T
If you run the code locally (whithout GAE) and click on [admin]/ [Languages]/[update languages] the string "Lazy subjects" will be added to the the language files. The problem may be that you need: subject=str(T('Lazy subjects')) Massimo On Jun 10, 3:27 pm, Carl wrote: > I am using web2py on GAE. > > I am sending emails using GAE. I'd delimited the subject line with T > ( ... ) and, you guessed it, GAE didn't like it at all. > > How can I have the subject string translated *before* the call to > GAE's platform? > > example code: > > bSuccess = mail.send(to=to,subject=T('Lazy subjects'),message=message) > > Carl --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23852] Re: Custom Display Values
On Jun 10, 3:49 pm, Gary wrote: > Massimo, > > Thank you so much for your feedback. Most of the changes you > suggested certainly made the code simpler and easier to read, but I > have a couple of issues that I don't understand. > > 1) It appears that the line: > > getattr(crud,session.action)(db[tablename],record) getattr(yyy,'xxx') is the same as yyy.xxx > executes the crud call, but I don't understand how getattr() does > that. Could you provide a brief explanation? > > 2) If I directly return the dictionary that results from setsubmit > (tablename), what would the format of the return be and what should > the variables in the form be named? I tried a couple of combinations > (widgets, inpval, dspval) , but they all failed (widget) carried extra > data (impval) or failed to display an on update. You only need widgets {{=form.custom.widget.field1}} {{=form.custom.widget.field2}} {{=form.custom.widget.field3}} {{=form.hidden_fields()}} > 3) In thefields(), the value of curform is: > > id="location_poleno__row"> id="location_poleno__label">Poleno: EBW 1234 td> for="location_town_id" id="location_town_id__label">Town Id: td>1 . > > and curform.record is: > > at 0x9ff80d4>, 'npolesize': None, 'notifydate': > datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, > 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, > 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': > 1, > > Please notice that in both places, the value of town_id is 1 and not > the value in the related table. > > When I set mydict = dict(form=curform) is was able to fix a syntax > error 'mydict does not exist' but I'm not sure that's the right thing > to do. However, the real problem is an error message that says > curform.custom.widget is not iterable. Even if it fixes it, I'm still > not sure what the variables in the form should be named. I think you can do: {{for fieldname in form.custom.widget:}} {{=form.custom.labels[fieldname]}}{{=form.custom.widget [fieldname]}} {{pass}} I do not think you need thefields since it only provides info that is alredy in the form. Not sure if this helps. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23853] Re: Login_next
Actually keepvalues=True only works and makes sense for create forms. Massimo On Jun 10, 3:55 pm, Fran wrote: > On Jun 10, 7:48 pm, mdipierro wrote: > > > I do not think this is creating the problem. Crud is still redirecting > > UNLESS you set crud.settings.keepvalues=True. If this what you are > > doing? > > Yes, well done :) > > Can this be made to just take effect on 'update' not 'create' forms? > (Didn't seem to work on create anyway) > > F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23854] Re: windows service problem in 1.63 (source)
I am planning to release 1.64 tomorrow if nothing comes up. Massimo On Jun 10, 4:32 pm, Philip Kilner wrote: > Hi Massimo, > > 2009/6/10 mdipierro : > > > This is already fixed in trunk. Thanks for bringing it up. > > Any objection to my adding a note to the AlterEgo page to help until > that makes it into a release? > > (Feels like a silly question - meaning that I think I should, unless > that release will be RSN - but am new here so sanity checking > ettiquette) > > -- > > Regards, > > PhilK > > Email: p...@xfr.co.uk > > 'a bell is a cup...until it is struck' --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23855] Re: Using count in a where clause
I do not think that is possible but I may be wrong. If you teach how to do it in SQL I will tell you how to translate in web2pyese. Massimo On Jun 10, 3:18 pm, Marcos Prieto wrote: > Hi, > > I'm trying to do a query in which I use select() with count and > groupby > > db().select(field1, field1.count(), groupby=field2) > > but I'd like to be able to use the count column to limit the results, > adding a where clause to the SQL, something like "where count > x" > > Is that possible? how? > > Thanks, > > Marcos. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23856] Form validation causes checkbox to get selected
Hello, I see a strange behavior when I try to validate a FORM. If there is a required field that is left empty Web2PY throws a "Cannot be empty" error message (good behavior). But along with this, the checkbox fields in the form also get selected even though they were left unchecked (unwanted action). I suspect this may be a bug during form validation. Any ideas on how to get around this? Thanks for your help. -Sebastian Web2py: 1.56.4 -Code fragment -- # db().select(db.resist.ALL) = 'test1', 'test2', 'test3', 'test4' ## from DB resist_mult = ['test2', 'test3'] form=FORM(TABLE( TR(TD("Name:",_class="right"),INPUT(_type="text", _size="", _name="name", value=str(a.name)+".1", requires=[IS_NOT_EMPTY (), IS_NOT_IN_DB(db, 'project.name')]), TD("Notebook:",_class="right"),INPUT (_type="text",_name="notebook",_size="8", requires=IS_NOT_EMPTY()), TD("Page:",_class="right"),INPUT (_type="text",_size="5",_name="page", requires=IS_NOT_EMPTY()), #BR(), TABLE( TR("Resistances:", *[TD(x.name, INPUT(_type="checkbox", name="resist_mult",_value=x.name, value=x.name in a.resist_mult)) for x in db().select(db.resist.ALL)]), ) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23857] Re: how to prevent deletion of referenced records
Here it is: http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers I got this from carlo who mentioned it in this group earlier. His post: http://groups.google.com/group/web2py/browse_thread/thread/2f19933298d64478/302d7442d1bec4e1?lnk=gst&q=sqlite+trigger#302d7442d1bec4e1 On Jun 10, 2:04 pm, Joe Barnhart wrote: > Sqlite does offer triggers, tho. Is it possible to rewrite the ON > DELETE...RESTRICT as a trigger and add it with pass-thru sql commands? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23858] Re: Using count in a where clause
In Oracle you can use rowcount, for example, select * from table where rowcount<200 In sql server I think you can set a rowcount: SET ROWCOUNT 100 (or whatever) then do your query SET ROWCOUNT 0 - sets it back to normal In other I don't know. A. C. Censi On Wed, Jun 10, 2009 at 7:05 PM, mdipierro wrote: > > I do not think that is possible but I may be wrong. If you teach how > to do it in SQL I will tell you how to translate in web2pyese. > > Massimo > > > On Jun 10, 3:18 pm, Marcos Prieto wrote: >> Hi, >> >> I'm trying to do a query in which I use select() with count and >> groupby >> >> db().select(field1, field1.count(), groupby=field2) >> >> but I'd like to be able to use the count column to limit the results, >> adding a where clause to the SQL, something like "where count > x" >> >> Is that possible? how? >> >> Thanks, >> >> Marcos. > > > -- A. C. Censi accensi [em] gmail [ponto] com accensi [em] montreal [ponto] com [ponto] br --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23859] Re: Custom Display Values
Massimo, Thank you. You mentioned before that widget worked in the trunk - you are, of course correct, but I just wanted to make note to others that it fails in the current version 1.63.5. Also, {{=form.custom.labels [fieldname]}} did not work in the trunk. It failed with "TypeError: 'NoneType' object is unsubscriptable". Just wanted you to know. Thanks again! On Jun 10, 5:59 pm, mdipierro wrote: > On Jun 10, 3:49 pm, Gary wrote: > > > Massimo, > > > Thank you so much for your feedback. Most of the changes you > > suggested certainly made the code simpler and easier to read, but I > > have a couple of issues that I don't understand. > > > 1) It appears that the line: > > > getattr(crud,session.action)(db[tablename],record) > > getattr(yyy,'xxx') is the same as yyy.xxx > > > executes the crud call, but I don't understand how getattr() does > > that. Could you provide a brief explanation? > > > 2) If I directly return the dictionary that results from setsubmit > > (tablename), what would the format of the return be and what should > > the variables in the form be named? I tried a couple of combinations > > (widgets, inpval, dspval) , but they all failed (widget) carried extra > > data (impval) or failed to display an on update. > > You only need widgets > > > {{=form.custom.widget.field1}} > {{=form.custom.widget.field2}} > {{=form.custom.widget.field3}} > > {{=form.hidden_fields()}} > > > > > > 3) In thefields(), the value of curform is: > > > > id="location_poleno__row"> > id="location_poleno__label">Poleno: EBW 1234 > td> > for="location_town_id" id="location_town_id__label">Town Id: > td>1 . > > > and curform.record is: > > > > at 0x9ff80d4>, 'npolesize': None, 'notifydate': > > datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, > > 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, > > 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': > > 1, > > > Please notice that in both places, the value of town_id is 1 and not > > the value in the related table. > > > When I set mydict = dict(form=curform) is was able to fix a syntax > > error 'mydict does not exist' but I'm not sure that's the right thing > > to do. However, the real problem is an error message that says > > curform.custom.widget is not iterable. Even if it fixes it, I'm still > > not sure what the variables in the form should be named. > > I think you can do: > > {{for fieldname in form.custom.widget:}} > {{=form.custom.labels[fieldname]}}{{=form.custom.widget > [fieldname]}} > {{pass}} > > I do not think you need thefields since it only provides info that is > alredy in the form. > > Not sure if this helps. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23860] Re: Custom Display Values
Massimo, I was so excited that the 'widget' worked that I failed to notice that I have the same problem that I started with - except the code is much cleaner. :-) When the crud read is executed, the valued returned is the value in the table. While this is fine for most fields, when the field is defined as an 'id' to another table, for example: db.location.town_id.requires=IS_IN_DB(db,db.town.id ,'%(townname)s') the widget and SQLFORM displays the update/create field as a with a value selected. So, on the update/create, the screen shows a pre-selected dropdown box with a town name, but on read, only the number representing the id is displayed. Can the widget for read be configured to display the selected value as text and check boxes (rather than True/False)? Thanks. On Jun 10, 9:58 pm, Gary wrote: > Massimo, > > Thank you. You mentioned before that widget worked in the trunk - you > are, of course correct, but I just wanted to make note to others that > it fails in the current version 1.63.5. Also, {{=form.custom.labels > [fieldname]}} did not work in the trunk. It failed with "TypeError: > 'NoneType' object is unsubscriptable". Just wanted you to know. > > Thanks again! > > On Jun 10, 5:59 pm, mdipierro wrote: > > > On Jun 10, 3:49 pm, Gary wrote: > > > > Massimo, > > > > Thank you so much for your feedback. Most of the changes you > > > suggested certainly made the code simpler and easier to read, but I > > > have a couple of issues that I don't understand. > > > > 1) It appears that the line: > > > > getattr(crud,session.action)(db[tablename],record) > > > getattr(yyy,'xxx') is the same as yyy.xxx > > > > executes the crud call, but I don't understand how getattr() does > > > that. Could you provide a brief explanation? > > > > 2) If I directly return the dictionary that results from setsubmit > > > (tablename), what would the format of the return be and what should > > > the variables in the form be named? I tried a couple of combinations > > > (widgets, inpval, dspval) , but they all failed (widget) carried extra > > > data (impval) or failed to display an on update. > > > You only need widgets > > > > > {{=form.custom.widget.field1}} > > {{=form.custom.widget.field2}} > > {{=form.custom.widget.field3}} > > > > {{=form.hidden_fields()}} > > > > > > 3) In thefields(), the value of curform is: > > > > > > id="location_poleno__row"> > > id="location_poleno__label">Poleno: EBW 1234 > > td> > > for="location_town_id" id="location_town_id__label">Town Id: > > td>1 . > > > > and curform.record is: > > > > > > at 0x9ff80d4>, 'npolesize': None, 'notifydate': > > > datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, > > > 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, > > > 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': > > > 1, > > > > Please notice that in both places, the value of town_id is 1 and not > > > the value in the related table. > > > > When I set mydict = dict(form=curform) is was able to fix a syntax > > > error 'mydict does not exist' but I'm not sure that's the right thing > > > to do. However, the real problem is an error message that says > > > curform.custom.widget is not iterable. Even if it fixes it, I'm still > > > not sure what the variables in the form should be named. > > > I think you can do: > > > {{for fieldname in form.custom.widget:}} > > {{=form.custom.labels[fieldname]}}{{=form.custom.widget > > [fieldname]}} > > {{pass}} > > > I do not think you need thefields since it only provides info that is > > alredy in the form. > > > Not sure if this helps. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23861] Re: Form validation causes checkbox to get selected
You are correct. I fixed it and I am uploading to trunk now (launchpad 904). Massimo On Jun 10, 5:52 pm, DJ wrote: > Hello, > > I see a strange behavior when I try to validate a FORM. If there is a > required field that is left empty Web2PY throws a "Cannot be empty" > error message (good behavior). But along with this, the checkbox > fields in the form also get selected even though they were left > unchecked (unwanted action). > > I suspect this may be a bug during form validation. Any ideas on how > to get around this? Thanks for your help. > > -Sebastian > > Web2py: 1.56.4 > > -Code fragment -- > # db().select(db.resist.ALL) = 'test1', 'test2', 'test3', 'test4' ## > from DB > resist_mult = ['test2', 'test3'] > > form=FORM(TABLE( > TR(TD("Name:",_class="right"),INPUT(_type="text", > _size="", _name="name", value=str(a.name)+".1", requires=[IS_NOT_EMPTY > (), IS_NOT_IN_DB(db, 'project.name')]), > TD("Notebook:",_class="right"),INPUT > (_type="text",_name="notebook",_size="8", requires=IS_NOT_EMPTY()), > TD("Page:",_class="right"),INPUT > (_type="text",_size="5",_name="page", requires=IS_NOT_EMPTY()), > > #BR(), > > TABLE( > TR("Resistances:", *[TD(x.name, INPUT(_type="checkbox", > name="resist_mult",_value=x.name, value=x.name in a.resist_mult)) for > x in db().select(db.resist.ALL)]), > > ) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23862] Re: how to prevent deletion of referenced records
Got a little lost. Sorry. If you want me to implement this please summarize the result and give an example of API and an example of the SQL that should be generated. Massimo On Jun 10, 6:52 pm, Joe Barnhart wrote: > Here it is: > > http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers > > I got this from carlo who mentioned it in this group earlier. His > post: > > http://groups.google.com/group/web2py/browse_thread/thread/2f19933298... > > On Jun 10, 2:04 pm, Joe Barnhart wrote: > > > Sqlite does offer triggers, tho. Is it possible to rewrite the ON > > DELETE...RESTRICT as a trigger and add it with pass-thru sql commands? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23863] Re: Using count in a where clause
I understand. You do not want to use count then db(...).select(...,limitby=(0,100)) will fetch the first 100 records. Massimo On Jun 10, 8:02 pm, "A. C. Censi" wrote: > In Oracle you can use rowcount, for example, select * from table where > rowcount<200 > > In sql server I think you can set a rowcount: > SET ROWCOUNT 100 (or whatever) > then do your query > SET ROWCOUNT 0 - sets it back to normal > > In other I don't know. > > A. C. Censi > > > > On Wed, Jun 10, 2009 at 7:05 PM, mdipierro wrote: > > > I do not think that is possible but I may be wrong. If you teach how > > to do it in SQL I will tell you how to translate in web2pyese. > > > Massimo > > > On Jun 10, 3:18 pm, Marcos Prieto wrote: > >> Hi, > > >> I'm trying to do a query in which I use select() with count and > >> groupby > > >> db().select(field1, field1.count(), groupby=field2) > > >> but I'd like to be able to use the count column to limit the results, > >> adding a where clause to the SQL, something like "where count > x" > > >> Is that possible? how? > > >> Thanks, > > >> Marcos. > > -- > A. C. Censi > accensi [em] gmail [ponto] com > accensi [em] montreal [ponto] com [ponto] br --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23864] Re: Custom Display Values
Now I understand the problem better. No problem. widget is always an input widget. Output widgets are called "represent" and usually much simpler. This will do what you want: db.location.town_id.represent=lambda id: SPAN(db.town[id].townname) Massimo On Jun 10, 9:28 pm, Gary wrote: > Massimo, > > I was so excited that the 'widget' worked that I failed to notice that > I have the same problem that I started with - except the code is much > cleaner. :-) > > When the crud read is executed, the valued returned is the value in > the table. While this is fine for most fields, when the field is > defined as an 'id' to another table, for example: > > db.location.town_id.requires=IS_IN_DB(db,db.town.id ,'%(townname)s') > > the widget and SQLFORM displays the update/create field as a > with a value selected. So, on the update/create, > the screen shows a pre-selected dropdown box with a town name, but on > read, only the number representing the id is displayed. Can the > widget for read be configured to display the selected value as text > and check boxes (rather than True/False)? > > Thanks. > > On Jun 10, 9:58 pm, Gary wrote: > > > Massimo, > > > Thank you. You mentioned before that widget worked in the trunk - you > > are, of course correct, but I just wanted to make note to others that > > it fails in the current version 1.63.5. Also, {{=form.custom.labels > > [fieldname]}} did not work in the trunk. It failed with "TypeError: > > 'NoneType' object is unsubscriptable". Just wanted you to know. > > > Thanks again! > > > On Jun 10, 5:59 pm, mdipierro wrote: > > > > On Jun 10, 3:49 pm, Gary wrote: > > > > > Massimo, > > > > > Thank you so much for your feedback. Most of the changes you > > > > suggested certainly made the code simpler and easier to read, but I > > > > have a couple of issues that I don't understand. > > > > > 1) It appears that the line: > > > > > getattr(crud,session.action)(db[tablename],record) > > > > getattr(yyy,'xxx') is the same as yyy.xxx > > > > > executes the crud call, but I don't understand how getattr() does > > > > that. Could you provide a brief explanation? > > > > > 2) If I directly return the dictionary that results from setsubmit > > > > (tablename), what would the format of the return be and what should > > > > the variables in the form be named? I tried a couple of combinations > > > > (widgets, inpval, dspval) , but they all failed (widget) carried extra > > > > data (impval) or failed to display an on update. > > > > You only need widgets > > > > > > > {{=form.custom.widget.field1}} > > > {{=form.custom.widget.field2}} > > > {{=form.custom.widget.field3}} > > > > > > {{=form.hidden_fields()}} > > > > > > > > 3) In thefields(), the value of curform is: > > > > > > > > id="location_poleno__row"> > > > id="location_poleno__label">Poleno: EBW 1234 > > > td> > > > for="location_town_id" id="location_town_id__label">Town Id: > > > td>1 . > > > > > and curform.record is: > > > > > > > > at 0x9ff80d4>, 'npolesize': None, 'notifydate': > > > > datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, > > > > 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, > > > > 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': > > > > 1, > > > > > Please notice that in both places, the value of town_id is 1 and not > > > > the value in the related table. > > > > > When I set mydict = dict(form=curform) is was able to fix a syntax > > > > error 'mydict does not exist' but I'm not sure that's the right thing > > > > to do. However, the real problem is an error message that says > > > > curform.custom.widget is not iterable. Even if it fixes it, I'm still > > > > not sure what the variables in the form should be named. > > > > I think you can do: > > > > {{for fieldname in form.custom.widget:}} > > > {{=form.custom.labels[fieldname]}}{{=form.custom.widget > > > [fieldname]}} > > > {{pass}} > > > > I do not think you need thefields since it only provides info that is > > > alredy in the form. > > > > Not sure if this helps. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23865] Re: problem with selfreference left outer join
Thanks, that worked! On Jun 10, 2:12 am, mdipierro wrote: --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23866] Re: new auth functions in trunk (basic, email/gmail, ldap)
I just sent you another (very simple) patch that forces auth to use the alternative login methods if present so, for example, LDAP will be queried each time. On Jun 9, 11:30 pm, mdipierro wrote: > Thanks! > > On Jun 9, 11:03 pm, "mr.freeze" wrote: > > > > > Massimo, you should have a patch in email for active directory ldap > >auth. As noted in my email: > > It works but we will also need to change tools.py so that it forces > > ldap authentication each time, not just the first (maybe track the > >authmethod in the db?). > > Currently after the account is authenticated through ldap, the > > credentials are stored in the db and ldap is never queried again. > > > Also, ideally the login form would be specific to the theauthtype so > > ldap/active directory could include a domain name field. > > Then we can tackle an LDAP membership provider! > > > On Jun 8, 11:52 pm, mdipierro wrote: > > > > only mode='uid' is implemented. I could use help debugging/ > > > implementing the other modes > > > > Massimo > > > > On Jun 8, 10:38 pm, "mr.freeze" wrote: > > > > > Sorry, I saw 'raise SyntaxError, "Not yet implemented"' under the 'ad' > > > > and 'domino' if statements of ldap_auth_aux in ldap_auth.py and > > > > thought you weren't done. I tried it and it seems that if ad/ldapis > > > > enabled that it will take any username with a blank password. > > > > > On Jun 8, 10:04 pm, mdipierro wrote: > > > > > >ldapshould work already. Please test it. > > > > > > On Jun 8, 9:29 pm, "mr.freeze" wrote: > > > > > > > Massimo, I can testldapagainst AD when it is finished. > > > > > > > On May 13, 12:01 am, mdipierro wrote: > > > > > > > > Please try this > > > > > > > > 1) to authenticate with gmail > > > > > > > >auth=Auth(globals(),db) > > > > > > > from gluon.contrib.login_methods.email_auth import email_auth > > > > > > >auth.settings.login_methods.append(email_auth()) > > > > > > > > 2) to authenticate using basic authentication of a third party > > > > > > > server > > > > > > > >auth=Auth(globals(),db) > > > > > > > from gluon.contrib.login_methods.basic_auth import basic_auth > > > > > > >auth.settings.login_methods.append(basic_auth('http://server')) > > > > > > > > 3) to authenticate usingLDAP server > > > > > > > >auth=Auth(globals(),db) > > > > > > > from gluon.contrib.login_methods.ldap_auth import ldap_auth > > > > > > >auth.settings.login_methods.append(ldap_auth(...)) > > > > > > > > (requiresldaplibrary installed. look into gluon/contrib/ > > > > > > > login_methods/ldap_auth.py for ... options). > > > > > > > > Please let me know if this works for you. > > > > > > > > CAS client will be next- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23867] Re: Custom Display Values
> You only need widgets > > > {{=form.custom.widget.field1}} > {{=form.custom.widget.field2}} > {{=form.custom.widget.field3}} > > {{=form.hidden_fields()}} > better is to use {{=form.start}} in stead of , this will take over any actions/methods etc that are used in the SQLFORM, and for now {{=form.close}} and are the same unless I can figure out how to include the {{=form.hidden_fields()}} properly in {{=form.close}} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23868] Re: Custom Display Values
done but it is now {{=form.custom.form.begin}} {{=form.custom.widget.field1}} {{=form.custom.widget.field2}} {{=form.custom.widget.field3}} {{=form.custom.form.end}} includes hidden fields! Massimo On Jun 10, 11:27 pm, Hans Donner wrote: > > You only need widgets > > > > > {{=form.custom.widget.field1}} > > {{=form.custom.widget.field2}} > > {{=form.custom.widget.field3}} > > > > {{=form.hidden_fields()}} > > > > better is to use {{=form.start}} in stead of , this will take > over any actions/methods etc that are used in the SQLFORM, > and for now {{=form.close}} and are the same unless I can > figure out how to include the {{=form.hidden_fields()}} properly in > {{=form.close}} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23869] Re: new auth functions in trunk (basic, email/gmail, ldap)
I did not receive your patch but if you now do: auth.settings.login.methods=[ldap_login(..)] then it does not store password in db and always requres ldap auth. If you do: auth.settings.login.methods=[ldap_login(..), auth] same as above but does store password in db. if you do auth.settings.login.methods=[auth, ldap_login(..)] tries to login locally first, else tries ldap. Of course you can do auth.settings.login.methods=[auth, ldap_login(...), email_login (...), basic_login(...)] and combinations thereof. Please give this a try. Massimo On Jun 10, 11:06 pm, "mr.freeze" wrote: > I just sent you another (very simple) patch that forces auth to use > the alternative login methods if present so, for example, LDAP will be > queried each time. > > On Jun 9, 11:30 pm, mdipierro wrote: > > > Thanks! > > > On Jun 9, 11:03 pm, "mr.freeze" wrote: > > > > Massimo, you should have a patch in email for active directory ldap > > >auth. As noted in my email: > > > It works but we will also need to change tools.py so that it forces > > > ldap authentication each time, not just the first (maybe track the > > >authmethod in the db?). > > > Currently after the account is authenticated through ldap, the > > > credentials are stored in the db and ldap is never queried again. > > > > Also, ideally the login form would be specific to the theauthtype so > > > ldap/active directory could include a domain name field. > > > Then we can tackle an LDAP membership provider! > > > > On Jun 8, 11:52 pm, mdipierro wrote: > > > > > only mode='uid' is implemented. I could use help debugging/ > > > > implementing the other modes > > > > > Massimo > > > > > On Jun 8, 10:38 pm, "mr.freeze" wrote: > > > > > > Sorry, I saw 'raise SyntaxError, "Not yet implemented"' under the 'ad' > > > > > and 'domino' if statements of ldap_auth_aux in ldap_auth.py and > > > > > thought you weren't done. I tried it and it seems that if ad/ldapis > > > > > enabled that it will take any username with a blank password. > > > > > > On Jun 8, 10:04 pm, mdipierro wrote: > > > > > > >ldapshould work already. Please test it. > > > > > > > On Jun 8, 9:29 pm, "mr.freeze" wrote: > > > > > > > > Massimo, I can testldapagainst AD when it is finished. > > > > > > > > On May 13, 12:01 am, mdipierro wrote: > > > > > > > > > Please try this > > > > > > > > > 1) to authenticate with gmail > > > > > > > > >auth=Auth(globals(),db) > > > > > > > > from gluon.contrib.login_methods.email_auth import email_auth > > > > > > > >auth.settings.login_methods.append(email_auth()) > > > > > > > > > 2) to authenticate using basic authentication of a third party > > > > > > > > server > > > > > > > > >auth=Auth(globals(),db) > > > > > > > > from gluon.contrib.login_methods.basic_auth import basic_auth > > > > > > > >auth.settings.login_methods.append(basic_auth('http://server')) > > > > > > > > > 3) to authenticate usingLDAP server > > > > > > > > >auth=Auth(globals(),db) > > > > > > > > from gluon.contrib.login_methods.ldap_auth import ldap_auth > > > > > > > >auth.settings.login_methods.append(ldap_auth(...)) > > > > > > > > > (requiresldaplibrary installed. look into gluon/contrib/ > > > > > > > > login_methods/ldap_auth.py for ... options). > > > > > > > > > Please let me know if this works for you. > > > > > > > > > CAS client will be next- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23870] Re: Custom Display Values
On Thu, Jun 11, 2009 at 3:12 PM, mdipierro wrote: > > done but it is now > > {{=form.custom.form.begin}} > {{=form.custom.widget.field1}} > {{=form.custom.widget.field2}} > {{=form.custom.widget.field3}} > > {{=form.custom.form.end}} includes hidden fields! Fantastic! That's easy and intuitive and yet so flexible and powerful. Thanks - this is really getting somewhere now. Horst --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23871] Re: Custom Display Values
Nice, > can be done with {{=form.custom.submit}} and if you want to add the delete? checkbox {{=form.custom.deletable}} On Thu, Jun 11, 2009 at 7:12 AM, mdipierro wrote: > > done but it is now > > {{=form.custom.form.begin}} > {{=form.custom.widget.field1}} > {{=form.custom.widget.field2}} > {{=form.custom.widget.field3}} > > {{=form.custom.form.end}} includes hidden fields! > > Massimo > > On Jun 10, 11:27 pm, Hans Donner wrote: >> > You only need widgets >> >> > >> > {{=form.custom.widget.field1}} >> > {{=form.custom.widget.field2}} >> > {{=form.custom.widget.field3}} >> > >> > {{=form.hidden_fields()}} >> > >> >> better is to use {{=form.start}} in stead of , this will take >> over any actions/methods etc that are used in the SQLFORM, >> and for now {{=form.close}} and are the same unless I can >> figure out how to include the {{=form.hidden_fields()}} properly in >> {{=form.close}} > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23872] sqllite web2py gen question
Hi, I am developing a website with web2py and sqllite. I am expecting no. of users of the site would increase to 50k. My question is would the sqllite in web2py support for 50k users or I need to migrate to mysql. The database would contain user information, messages and some blogs. thanks durga --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23873] Re: sqllite web2py gen question
On Jun 11, 6:42 am, durga wrote: > I am developing a website with web2py and sqllite. I am expecting no. > of users of the site would increase to 50k. My question is would the > sqllite in web2py support for 50k users or I need to migrate to > mysql. The database would contain user information, messages and some > blogs. I would switch away from SQLite for that size of production use. MySQL should be fine :) F --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23874] Re: how to prevent deletion of referenced records
I don't think it is something you need to add to web2py. This is really a workaround for sqlite because it doesn't respect the normal keywords of ON DELETE RESTRICT or CASCADE. It's a simple enough work- around that is added to the model file for sqlite but not the other databases. On Jun 10, 7:32 pm, mdipierro wrote: > Got a little lost. Sorry. If you want me to implement this please > summarize the result and give an example of API and an example of the > SQL that should be generated. > > Massimo --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[web2py:23875] Re: how to prevent deletion of referenced records
Massimo, I am using Postgres. In my application I have these tables: db.define_table('provincie', SQLField('provincie',label='Provincie * ',length=18,default='',notnull=True,unique=True), migrate=False) db.provincie.provincie.requires=[IS_LENGTH(18,error_message=T('length exceeds 18')),IS_NOT_EMPTY(),IS_NOT_IN_DB (db,'provincie.provincie',error_message=T('provincie already in database'))] db.define_table('gemeente', SQLField('gemeente',label='Gemeente * ',length=30,default='',notnull=True,unique=True), SQLField('provincie',db.provincie,label='Provincie * ',default='',notnull=True,ondelete='RESTRICT'), migrate=False) db.gemeente.gemeente.requires=[IS_LENGTH(30,error_message=T('length exceeds 30')),IS_NOT_EMPTY(),IS_NOT_IN_DB (db,'gemeente.gemeente',error_message=T('gemeente already in database'))] db.gemeente.provincie.requires=IS_IN_DB(db,db.provincie.id,'% (provincie)s') When I update record 1 in the province table, check the 'check to delete' box and submit the page, an error ticket is issued: Traceback (most recent call last): File "/Library/Python/2.5/site-packages/web2pyfitwise/gluon/sql.py", line 722, in self._execute = lambda *a, **b: self._cursor.execute(*a,**b) IntegrityError: update or delete on table "provincie" violates foreign key constraint "gemeente_provincie_fkey" on table "gemeente" DETAIL: Key (id)=(1) is still referenced from table "gemeente". Isn't displaying a warning message just a matter of 'translating' this error ticket into a response.message or response.flash 'thing'? Kind regards, Annet. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---