[web2py] Re: Pypi
No because web2py is not a python module. On Apr 28, 12:12 am, Thadeus Burgess wrote: > Are we supposed to be able to easy_install this? > > -- > Thadeus > > On Tue, Apr 27, 2010 at 11:48 PM, mdipierro wrote: > > Does this work for you? > > >http://pypi.python.org/pypi?:action=display&name=web2py&version=1.77.3 > > > I posted 1.54 long ago but I forgot to uncheck the "hide" checkbox. > > > Massimo
Re: [web2py] Pypi
Are we supposed to be able to easy_install this? -- Thadeus On Tue, Apr 27, 2010 at 11:48 PM, mdipierro wrote: > Does this work for you? > > http://pypi.python.org/pypi?:action=display&name=web2py&version=1.77.3 > > I posted 1.54 long ago but I forgot to uncheck the "hide" checkbox. > > Massimo >
[web2py] Pypi
Does this work for you? http://pypi.python.org/pypi?:action=display&name=web2py&version=1.77.3 I posted 1.54 long ago but I forgot to uncheck the "hide" checkbox. Massimo
[web2py] Re: fatal bug in 1.77.3
I am short of ideas. You tell us that the variable output is a list but len(output) calls the __len__ method in the cgi.py module. Can anybody reproduce this behavior? Massimo On Apr 27, 8:09 pm, 王怀玉 wrote: > the output: > CHECK: [' Transitional > //EN" "http://www.w3.org/TR/xhtml1/DTD/xh... > > I try the bug in some platforms. python version is 2.5.4, web2py 1.77.3 > > winxp, bug appears sometimes > > win7, bug appears everytime > > centos5.3, bug appears sometimes > > 在2010-04-28 03:55:11,mdipierro 写道: >To help us > debug this.. > >before line 1162 in gluon/rocket.py > >if > hasattr(output, '__len__'): >sections = len(output) > >please > add > >if hasattr(output, '__len__'): >print > 'CHECK:',type(output), repr(output)[:100]+'...' >sections = > len(output) > >and try to reproduce the problem. What is the output? > > >On > Apr 25, 10:53 pm, hywang wrote: >> I run web2py from > source on centos 5.3. >> When upload a file, an error occurs. >> > -db.py--- >> db.define_table('easy_test', >> Field('picture', > 'upload') >> ) >> >> -controller file--- >> def hello(): > >> form = SQLFORM(db.easy_test) >> if form.accepts(request.vars, > session): >> request.flash = 'ok' >> return dict(form=form) >> >> > when submit the form, it returns 'server error' >> consel error msg : >> > ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): >> File > "E:\web2py\gluon\rocket.py", line 747, in run >> self.run_app(conn) >> > File "E:\web2py\gluon\rocket.py", line 1162, in run_app >> sections = > len(output) >> File "C:\Python25\lib\cgi.py", line 633, in __len__ >> > return len(self.keys()) >> File "C:\Python25\lib\cgi.py", line 609, in keys > >> raise TypeError, "not indexable" >> TypeError: not indexable >> >> -- > >> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
Re:[web2py] Re: fatal bug in 1.77.3
the output: CHECK: ['http://www.w3.org/TR/xhtml1/DTD/xh... I try the bug in some platforms. python version is 2.5.4, web2py 1.77.3 winxp, bug appears sometimes win7, bug appears everytime centos5.3, bug appears sometimes 在2010-04-28 03:55:11,mdipierro 写道: >To help us debug this.. > >before line 1162 in gluon/rocket.py > >if hasattr(output, '__len__'): >sections = len(output) > >please add > > if hasattr(output, '__len__'): >print 'CHECK:',type(output), repr(output)[:100]+'...' >sections = len(output) > >and try to reproduce the problem. What is the output? > > >On Apr 25, 10:53 pm, hywang wrote: >> I run web2py from source on centos 5.3. >> When upload a file, an error occurs. >> -db.py--- >> db.define_table('easy_test', >> Field('picture', 'upload') >> ) >> >> -controller file--- >> def hello(): >> form = SQLFORM(db.easy_test) >> if form.accepts(request.vars, session): >> request.flash = 'ok' >> return dict(form=form) >> >> when submit the form, it returns 'server error' >> consel error msg : >> ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): >> File "E:\web2py\gluon\rocket.py", line 747, in run >> self.run_app(conn) >> File "E:\web2py\gluon\rocket.py", line 1162, in run_app >> sections = len(output) >> File "C:\Python25\lib\cgi.py", line 633, in __len__ >> return len(self.keys()) >> File "C:\Python25\lib\cgi.py", line 609, in keys >> raise TypeError, "not indexable" >> TypeError: not indexable >> >> -- >> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Silent errors
If I understand the objection Python is a dynamic language. The line returns an error only if it is executed. There is nothing web2py can do about this. On Apr 27, 4:05 pm, Keith Edmunds wrote: > I've just found a stupid programming error of mine. Code: > > > task_rows = db(db.tasks.ref==request.vars.number).select() > if len(task_rows): > rows[0].update_record(status = request.vars.new) > > > At some point, I'd renamed the variable 'rows' to 'task_rows', but > omitted to change the last line quoted above. Blindingly obvious once you > see it, and there are 101 reasons why I shouldn't have made that mistake. > > However, it fails in Web2py without any indication. It wasn't until I ran > it under pydb that I saw this: > > (Pydb) n > NameError:"global name 'rows' is not defined" > > My question: is there any way Web2py can catch and notify me of errors > like that? > > Thanks > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: SEO
On Apr 27, 6:07 pm, howesc wrote: > another trick that web2py makes real easy, is make sure that each page > has a unique URL by using request.args. your url might look like: > > http://www.foo.com/default/index/43576/Image-title-here/another-thing > > where 43576 in the above URL is the ID (like in massimo's example), > but the other parts are never used by the app, see http://web2py.com/book/default/section/4/2?search=URL request.env.http_host == http://www.foo.com request.controller == default # i.e. default.py request.function == index # i.e. index() request.args == ['43576', 'image-title-here', 'antother-thing' ] request.vars == {} It is up to your application, specifically to the controller called to process request.args[] and request.vars{} as appropriate. It is certainly not accurate to say "the other parts are never used by the app". They may not be used by YOUR app, but that would be your specific way of using them (i.e. ignoring them, not handling them). Just want to be sure others are not confused / misled. Regards, - Yarko > but to google they look > like part of the URL that it indexes, and it will request each page > separately, thereby getting the unique page keywords. > > i'm no expert, so this might be a bad idea, but what about a hidden > div on the page with comment content? i don't know if the search > engine parses the css to know that the content is not visible to the > user. > > good luck, > > cfh > > On Apr 26, 6:33 pm, mdipierro wrote: > > > say you have: > > > db.define_table('paper',Field('image','upload')) > > db.define_table('tag',Field('paper',db.paper),Field('keyword')) > > > then you will have an action like: > > > def index(): > > paper=db.paper[request.args(0)] > > response.meta.keywords=','.join([tag.keyword for tag in > > db(db.tag.paper==paper.id).select()]) > > return > > dict(img=IMG(_src=URL(r=request,f='download',args=paper.image))) > > > On Apr 26, 7:23 pm, Al wrote: > > > > Thank you for all the comments... > > > The web site is just a few hundreds of SCANNED image of verd old > > > medical papers which can be searched by two database fields - Title > > > and Keywords, so essentially it is just one web page with not much to > > > be indexed on. There is also 'comments' people can add to each > > > article, but these comments are also stored in the DB. So I must find > > > a way to persist the data in these 3 searchable fields so that they > > > can be crawled by the search engine, I am not sure if > > > "response.meta.keyword=" can do such job. The keyword field will > > > be continuously updated - not static - so I cannot put all the > > > keywords into the meta descriptions beforehand. > > > > Al > > > > -- > > > Subscription > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: SEO
another trick that web2py makes real easy, is make sure that each page has a unique URL by using request.args. your url might look like: http://www.foo.com/default/index/43576/Image-title-here/another-thing where 43576 in the above URL is the ID (like in massimo's example), but the other parts are never used by the app, but to google they look like part of the URL that it indexes, and it will request each page separately, thereby getting the unique page keywords. i'm no expert, so this might be a bad idea, but what about a hidden div on the page with comment content? i don't know if the search engine parses the css to know that the content is not visible to the user. good luck, cfh On Apr 26, 6:33 pm, mdipierro wrote: > say you have: > > db.define_table('paper',Field('image','upload')) > db.define_table('tag',Field('paper',db.paper),Field('keyword')) > > then you will have an action like: > > def index(): > paper=db.paper[request.args(0)] > response.meta.keywords=','.join([tag.keyword for tag in > db(db.tag.paper==paper.id).select()]) > return > dict(img=IMG(_src=URL(r=request,f='download',args=paper.image))) > > On Apr 26, 7:23 pm, Al wrote: > > > Thank you for all the comments... > > The web site is just a few hundreds of SCANNED image of verd old > > medical papers which can be searched by two database fields - Title > > and Keywords, so essentially it is just one web page with not much to > > be indexed on. There is also 'comments' people can add to each > > article, but these comments are also stored in the DB. So I must find > > a way to persist the data in these 3 searchable fields so that they > > can be crawled by the search engine, I am not sure if > > "response.meta.keyword=" can do such job. The keyword field will > > be continuously updated - not static - so I cannot put all the > > keywords into the meta descriptions beforehand. > > > Al > > > -- > > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Silent errors
I've just found a stupid programming error of mine. Code: task_rows = db(db.tasks.ref==request.vars.number).select() if len(task_rows): rows[0].update_record(status = request.vars.new) At some point, I'd renamed the variable 'rows' to 'task_rows', but omitted to change the last line quoted above. Blindingly obvious once you see it, and there are 101 reasons why I shouldn't have made that mistake. However, it fails in Web2py without any indication. It wasn't until I ran it under pydb that I saw this: (Pydb) n NameError:"global name 'rows' is not defined" My question: is there any way Web2py can catch and notify me of errors like that? Thanks -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: How do i get this working?
Thanks Massimo, Then I guess I would be doing this with an iFrame and some JSONP magic with jQuery On Apr 27, 8:51 pm, mdipierro wrote: > It depends on what you put in the iframe. You can put in there js code > that reload the add. Exactly how you would do without the iframe. If > you do it without the iframe your JS may conflict with the JS of the > page and the content of the add may conflict with the CSS. With iframe > you have more control. > > On Apr 27, 2:22 pm, Pystar wrote: > > > > > Hi mdipierro, > > So you would advise me to go along the lines of iframes? that means > > that the new ads would not appear on the website without the visitor > > refreshing the page? For example, how do I develop a widget like does > > 3rd party twitter widgets that display realtime tweets? > > > On Apr 27, 12:57 am, mdipierro wrote: > > > > I will get a easier life with iframes because you completely decouple > > > embedding page with the embedded content so you will have complete > > > control on the latter. > > > > On Apr 26, 4:23 pm, Pystar wrote: > > > > > So Mdipierro, > > > > What do you suggest I use? > > > > > On Apr 26, 10:06 pm, mdipierro wrote: > > > > > > You can do jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote- > > > > > json-jsonp/) but I am not sure it solves the same prpblem you want to > > > > > solve. > > > > > > On Apr 26, 3:41 pm, Pystar wrote: > > > > > > > Hi guys, > > > > > > I am developing an sms-to-web advertising platform and I am having > > > > > > some problems, here is how it works. Interested website/blog owners > > > > > > register on the platform,then any visitor to that website can then > > > > > > text a 140 character advert to a short code, the user's prepaid > > > > > > account gets deducted, and the revenue is shared between the Telecom > > > > > > company, the shortcode provider, the ad platform owner and the > > > > > > website > > > > > > owner. > > > > > > My Problem: I was thinking of using iFrames to display the ad's from > > > > > > the ad platform on registered 3rd party sites, but I would like to > > > > > > know if there was a better way of doing this. I was advised to use > > > > > > JSONP, can I do that with web2py? and does anyone here have any > > > > > > experience with this kind of stuff? > > > > > > Thanks Guys, > > > > > > Pystar, > > > > > > Logiclabs Inc, > > > > > > Lagos, Nigeria > > > > > > > -- > > > > > > Subscription > > > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: fatal bug in 1.77.3
To help us debug this.. before line 1162 in gluon/rocket.py if hasattr(output, '__len__'): sections = len(output) please add if hasattr(output, '__len__'): print 'CHECK:',type(output), repr(output)[:100]+'...' sections = len(output) and try to reproduce the problem. What is the output? On Apr 25, 10:53 pm, hywang wrote: > I run web2py from source on centos 5.3. > When upload a file, an error occurs. > -db.py--- > db.define_table('easy_test', > Field('picture', 'upload') > ) > > -controller file--- > def hello(): > form = SQLFORM(db.easy_test) > if form.accepts(request.vars, session): > request.flash = 'ok' > return dict(form=form) > > when submit the form, it returns 'server error' > consel error msg : > ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): > File "E:\web2py\gluon\rocket.py", line 747, in run > self.run_app(conn) > File "E:\web2py\gluon\rocket.py", line 1162, in run_app > sections = len(output) > File "C:\Python25\lib\cgi.py", line 633, in __len__ > return len(self.keys()) > File "C:\Python25\lib\cgi.py", line 609, in keys > raise TypeError, "not indexable" > TypeError: not indexable > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: fatal bug in 1.77.3
On Apr 25, 10:53 pm, hywang wrote: > I run web2py from source on centos 5.3. > When upload a file, an error occurs. > -db.py--- > db.define_table('easy_test', > Field('picture', 'upload') > ) > > -controller file--- > def hello(): > form = SQLFORM(db.easy_test) > if form.accepts(request.vars, session): > request.flash = 'ok' > return dict(form=form) > > when submit the form, it returns 'server error' > consel error msg : > ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): > File "E:\web2py\gluon\rocket.py", line 747, in run > self.run_app(conn) > File "E:\web2py\gluon\rocket.py", line 1162, in run_app > sections = len(output) > File "C:\Python25\lib\cgi.py", line 633, in __len__ > return len(self.keys()) > File "C:\Python25\lib\cgi.py", line 609, in keys > raise TypeError, "not indexable" > TypeError: not indexable > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: How do i get this working?
It depends on what you put in the iframe. You can put in there js code that reload the add. Exactly how you would do without the iframe. If you do it without the iframe your JS may conflict with the JS of the page and the content of the add may conflict with the CSS. With iframe you have more control. On Apr 27, 2:22 pm, Pystar wrote: > Hi mdipierro, > So you would advise me to go along the lines of iframes? that means > that the new ads would not appear on the website without the visitor > refreshing the page? For example, how do I develop a widget like does > 3rd party twitter widgets that display realtime tweets? > > On Apr 27, 12:57 am, mdipierro wrote: > > > I will get a easier life with iframes because you completely decouple > > embedding page with the embedded content so you will have complete > > control on the latter. > > > On Apr 26, 4:23 pm, Pystar wrote: > > > > So Mdipierro, > > > What do you suggest I use? > > > > On Apr 26, 10:06 pm, mdipierro wrote: > > > > > You can do jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote- > > > > json-jsonp/) but I am not sure it solves the same prpblem you want to > > > > solve. > > > > > On Apr 26, 3:41 pm, Pystar wrote: > > > > > > Hi guys, > > > > > I am developing an sms-to-web advertising platform and I am having > > > > > some problems, here is how it works. Interested website/blog owners > > > > > register on the platform,then any visitor to that website can then > > > > > text a 140 character advert to a short code, the user's prepaid > > > > > account gets deducted, and the revenue is shared between the Telecom > > > > > company, the shortcode provider, the ad platform owner and the website > > > > > owner. > > > > > My Problem: I was thinking of using iFrames to display the ad's from > > > > > the ad platform on registered 3rd party sites, but I would like to > > > > > know if there was a better way of doing this. I was advised to use > > > > > JSONP, can I do that with web2py? and does anyone here have any > > > > > experience with this kind of stuff? > > > > > Thanks Guys, > > > > > Pystar, > > > > > Logiclabs Inc, > > > > > Lagos, Nigeria > > > > > > -- > > > > > Subscription > > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: LOAD function and web2py_trap_form proposal
I like your proposal. I will try it tonight and include in trunk. On Apr 27, 2:09 pm, Skiros wrote: > I am using LOAD function and I have some problems with forms that do > not use a submit button in order to send the data. This is because > web2py_trap_form only catch that type of "INPUT". > > The problem is when a form uses other ways to send the data. For > example "A" or "IMG" tags, and especially when there is some function > to copy or to validate things. > > My proposal is to modify web2py_trap_form to catch the event > "onsubmit" replacing this: > > function web2py_trap_form(... > jQuery('input[type="submit"]',this).click(function(){ > ...) > > with this > > function web2py_trap_form(... > this.onsubmit = function(){ > ...) > > This would allow us to include the function "onsubmit" within any > function that we need to execute before sending the information. And > to make reality things like > > > Function MyFunction(form,name){ > if (name != ""){ > form.onsubmit(); > }} > > > > > > > > > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: How do i get this working?
Hi mdipierro, So you would advise me to go along the lines of iframes? that means that the new ads would not appear on the website without the visitor refreshing the page? For example, how do I develop a widget like does 3rd party twitter widgets that display realtime tweets? On Apr 27, 12:57 am, mdipierro wrote: > I will get a easier life with iframes because you completely decouple > embedding page with the embedded content so you will have complete > control on the latter. > > On Apr 26, 4:23 pm, Pystar wrote: > > > > > So Mdipierro, > > What do you suggest I use? > > > On Apr 26, 10:06 pm, mdipierro wrote: > > > > You can do jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote- > > > json-jsonp/) but I am not sure it solves the same prpblem you want to > > > solve. > > > > On Apr 26, 3:41 pm, Pystar wrote: > > > > > Hi guys, > > > > I am developing an sms-to-web advertising platform and I am having > > > > some problems, here is how it works. Interested website/blog owners > > > > register on the platform,then any visitor to that website can then > > > > text a 140 character advert to a short code, the user's prepaid > > > > account gets deducted, and the revenue is shared between the Telecom > > > > company, the shortcode provider, the ad platform owner and the website > > > > owner. > > > > My Problem: I was thinking of using iFrames to display the ad's from > > > > the ad platform on registered 3rd party sites, but I would like to > > > > know if there was a better way of doing this. I was advised to use > > > > JSONP, can I do that with web2py? and does anyone here have any > > > > experience with this kind of stuff? > > > > Thanks Guys, > > > > Pystar, > > > > Logiclabs Inc, > > > > Lagos, Nigeria > > > > > -- > > > > Subscription > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] LOAD function and web2py_trap_form proposal
I am using LOAD function and I have some problems with forms that do not use a submit button in order to send the data. This is because web2py_trap_form only catch that type of "INPUT". The problem is when a form uses other ways to send the data. For example "A" or "IMG" tags, and especially when there is some function to copy or to validate things. My proposal is to modify web2py_trap_form to catch the event "onsubmit" replacing this: function web2py_trap_form(... jQuery('input[type="submit"]',this).click(function(){ ...) with this function web2py_trap_form(... this.onsubmit = function(){ ...) This would allow us to include the function "onsubmit" within any function that we need to execute before sending the information. And to make reality things like Function MyFunction(form,name){ if (name != ""){ form.onsubmit(); } } -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
Re: [web2py] Re: fatal bug in 1.77.3
I didn't originally, but did after you mentioned it. It worked both ways for me. On 4/27/2010 8:56 AM, mdipierro wrote: Tim, did you try with the IS_IMAGE validator? On Apr 27, 7:56 am, Timothy Farrell wrote: Let us know if it comes up again. -tim On 4/27/2010 1:30 AM, hywang wrote: when i try it again today, everything is ok today. I don't know why :-( On 4月26日, 下午11时42分, mdipierrowrote: I cannot reproduce this either. It is not an internationalization issue. I suspect something else in the code is causing this. We need to see at the entire code. On Apr 26, 10:37 am, Timothy Farrellwrote: My assumption that web2py is returning something other than a list comes from the traceback. Why would calling: len(returned_obj) go into the cgi module if it was a string? Rocket alone does not use the cgi module at all so the returned object must be related to it somehow. We know that lists that contain strings do not relate to the cgi module. All that aside, there's something more going on here. I've plugged hwangs code into a test application here and could not reproduce the problematic behavior. The only changes I made to the code posted was changing request.flash = 'ok' to response.flash = 'ok' and adding a db = DAL('sqlite://storage.db') to the model file. Could there be a i18n/l10n issue here? -tim On 4/26/2010 9:16 AM, mdipierro wrote: I think we need some debugging. His code is def hello(): form = SQLFORM(db.easy_test) if form.accepts(request.vars, session): request.flash = 'ok' return dict(form=form) and web2py returns a list with a string in this case (the generic view that renders the dict()). I do not see how web2py can return anything else. On Apr 26, 8:04 am, Timothy Farrell wrote: Massimo, I know you sent me an email on this but I can't find it so I'll just reply to the list. Rocket is dying in this case because the object it has received from web2py is not a valid WSGI response. A valid WSGI response must be either a list or generator (Rocket is a little more tolerant and will accept a string as well). But in this case it seems to be getting some form of a cgi.FieldStorage type as evidenced by the traceback going into the cgi module when Rocket tries to read the length of the returned object. Massimo, I've seen the web2py code that it normally scrubs returned objects. This was a while ago and may have changed since then. Rocket could die a little more gracefully, but I'd rather keep the code lean rather than checking every response for validity. As a test, there is a WSGI validator in the wsgiref module that works as middleware. You might hook that up to see what is really coming back. -tim On 4/26/2010 1:53 AM, hywang wrote: i has no view . when i test newest version in google hg server, web2py works well, but if I add IS_IMAGE() validator, some error occured again. ver1.6x works well On 4 26 , 2ʱ01 , mdipierro wrote: Do you have a view with a custom form? On Apr 25, 10:53 pm, hywang wrote: I run web2py from source on centos 5.3. When upload a file, an error occurs. -db.py--- db.define_table('easy_test', Field('picture', 'upload') ) -controller file--- def hello(): form = SQLFORM(db.easy_test) if form.accepts(request.vars, session): request.flash = 'ok' return dict(form=form) when submit the form, it returns 'server error' consel error msg : ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): File "E:\web2py\gluon\rocket.py", line 747, in run self.run_app(conn) File "E:\web2py\gluon\rocket.py", line 1162, in run_app sections = len(output) File "C:\Python25\lib\cgi.py", line 633, in __len__ return len(self.keys()) File "C:\Python25\lib\cgi.py", line 609, in keys raise TypeError, "not indexable" TypeError: not indexable -- Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
Re: [web2py] Re: Application logging
On Tue, 27 Apr 2010 09:31:50 -0700 (PDT), minkto...@gmail.com said: > I'd be interested in a step by step guide to setting up this kind of > logging. I found some older posts that helped in the end. I now have a modules/logging.py file that looks like: def _init_log(): """ From http://article.gmane.org/gmane.comp.python.web2py/11091 """ import logging from logging.handlers import SysLogHandler logger = logging.getLogger(request.application) logger.setLevel(logging.DEBUG) handler = SysLogHandler(address='/dev/log') handler.setLevel(logging.DEBUG) handler.setFormatter(logging.Formatter( '%s' % request.application + '[%(process)d]: %(levelname)s: %(filename)s at line %(lineno)d: %(message)s')) logger.addHandler(handler) return logger logging=cache.ram('once',lambda:_init_log(),time_expire=) Then, when I want to log something, I do: logging.debug("blah") ".debug" can be the other standard values including ".exception", ".error", ".info", etc I don't claim originality for the above: I adapted it slightly from the URL quoted. Given the unexpected challenges in implementing this in web2py, I think it would make sense to include it in the scaffolding (but I'm probably wrong). -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Application logging
In 'models' folder, i create the file named '0.py' like this : def _init_log(): import os, logging, logging.handlers logger = logging.getLogger(request.application) logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler(os.path.join(request.folder,'static','applog.txt'),'a', 1024*1024,1) handler.setLevel(logging.DEBUG) handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s % (filename)s:%(lineno)d %(funcName)s: %(message)s")) logger.addHandler(handler) return logger app_logging = cache.ram('app_wide_log', lambda:_init_log(), time_expire=None) and now in my application, i can write this : app_logging.info("My message") or app_logging.debug("x = %d" % myvar) Et voilà ! On 27 avr, 18:31, knitatoms wrote: > I'd be interested in a step by step guide to setting up this kind of > logging. I'm new to web2py and python and I think it would help my > learning. > > I already get some good info by monitoring the http log file with the > free Kiwi log viewer (on Windows) which tails the file. > > Could someone explain step by step how to set up the Python logging > module to write to a file from a web2py application. Thanks! > > On Apr 17, 8:37 pm, Keith Edmunds wrote: > > > > > What are others doing for application logging? I'm not referring to the > > HTTP logs, but program-generated logs. > > > I've recently been looking at the Python 'logging' module, which I've not > > used before. I initiate logging from a file in the 'modules' directory > > which does this: > > > --- > > - > > import logging > > from logging.handlers import SysLogHandler > > > logger = logging.getLogger("MyApp") > > logger.setLevel(logging.DEBUG) > > hdlr = SysLogHandler(address='/dev/log') > > formatter = logging.Formatter('tigerpy[%(process)d]: %(levelname)s: > > %(filename)s at line %(lineno)d: %(message)s') hdlr.setFormatter(formatter) > > logger.addHandler(hdlr) > > --- > > - > > > Then each file that I want to log from does this: > > > --- > > - > > import logging > > > logger = logging.getLogger("MyApp") > > . > > . > > logger.info("Something interesting happened") > > --- > > - > > > This logs to syslog: the only problem is that each logging message is > > written to syslog many (20-40) times(!). This isn't just in one place in > > my code, but throughout. I don't think the code is being executed multiple > > times, so I'm not sure why I'm getting so many log entries. > > > So, I'm interested in what others do to log application events. > > > -- > > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Webfaction rocks
Aurelien, Don't you have a domain name? I asked my domain registrar to point my domain name to WebFaction's domain name servers: ns1.webfaction.com ns2.webfaction.com ns3.webfaction.com ns4.webfaction.com Comment: Your domain name registrar may not require all four domain name servers; enter as many as your domain registrar supports. I then proceeded as described above, and didn't encounter the certificate problem, because I have a dedicated IP address. Regards, Annet. -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: questions on example in official web2py book
You are right. That happens in a few places. The problem is that dangling errors requires redirection to a different action therefore it makes the example more complex and shift the focus from the goal of the example. On Apr 27, 10:27 am, frankz wrote: > Thanks Yarko. > > Note I have no issues run the examples in the book. For example it > works if I openhttp://127.0.0.1/images/default/show/1 > it works great. > > the problem is the example seems not quite robust, if I point the > browser to htttp://127.0.0.1:8000/images/default/show > > It gives me an error. > > Ticket 127.0.0.1.2010-04-27.11-16-18.9e6c05a6-6ac6-446d-9e59- > f1c8b209343d > > Error traceback > > Traceback (most recent call last): > File "gluon/restricted.py", line 178, in restricted > File "C:/Documents and Settings/frank.zhu/My Documents/Downloads/ > web2py/applications/images/controllers/default.py", line 60, in > > File "gluon/globals.py", line 96, in > File "C:/Documents and Settings/frank.zhu/My Documents/Downloads/ > web2py/applications/images/controllers/default.py", line 16, in show > File "gluon/sql.py", line 3438, in __getitem__ > IndexError: list index out of range > > In file: C:\Documents and Settings\frank.zhu\My Documents\Downloads > \web2py\applications\images/controllers/default.py > > # -*- coding: utf-8 -*- > > # > ## This is a samples controller > ## - index is the default action of any application > ## - user is required for authentication and authorization > ## - download is for downloading files uploaded in the db (does > streaming) > ## - call exposes all registered services (none by default) > # > > def index(): > images = db().select(db.image.ALL, orderby=db.image.title) > return dict(images=images) > > def show(): > image = db(db.image.id==request.args(0)).select()[0] > if len(image) == 0: print "No images found!" > form = SQLFORM(db.comment) > form.vars.image_id = image.id > if form.accepts(request.vars, session): > response.flash = 'your comment is posted' > comments = db(db.comment.image_id==image.id).select() > return dict(image=image, comments=comments, form=form) > > I think now I know why, the request.args(0) doesn't contain any image > id, > so the following is one way to get around this issue > def show(): > id = request.args(0) or 1 # id default to 1 > image = db(db.image.id==id).select()[0] > form = SQLFORM(db.comment) > form.vars.image_id = image.id > if form.accepts(request.vars, session): > response.flash = 'your comment is posted' > comments = db(db.comment.image_id==image.id).select() > return dict(image=image, comments=comments, form=form) > > On Apr 26, 6:55 pm, Yarko Tymciurak > wrote: > > > On Apr 26, 4:38 pm, frankz wrote: > > > > Hi, > > > in the web2py official book, in the image blog example, > > > Referring tohttp://web2py.com/book/default/section/3/6?search=image+blog > > > > Could anyone help explain what the following line mean? > > > image = db(db.image.id==request.args(0)).select()[0] > > > This example code assume's you've entered an image in the database; if > > you have not, > > then the select()[0] reference would give you index out of > > range. > > > Here's why: > > > - This is a database select query; it's form is basically: > > > your_db_connection( WHERE clause; in this case where ID of the image > > table is same as what requested).select( fields - "ALL" by default) > > > This returns an array of records found in the database - if none, it > > returns an empty array, []. > > > A more robust way to write this (not used, so the example would be > > short) would be something like this: > > > images = db(db.image.id==request.args(0)).select() > > if len(images) == 0: print "No images found!" > > else: image = images[0] > > > I hope this has been helpful. > > Regards, > > - Yarko > > > > I duplicate the same code but I find URL > > > htttp://127.0.0.1:8000/images/default/show > > > gives me an error, "index out of range" > > > > How do I fix it? > > > > Thanks, > > > > -- > > > Subscription > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Application logging
I'd be interested in a step by step guide to setting up this kind of logging. I'm new to web2py and python and I think it would help my learning. I already get some good info by monitoring the http log file with the free Kiwi log viewer (on Windows) which tails the file. Could someone explain step by step how to set up the Python logging module to write to a file from a web2py application. Thanks! On Apr 17, 8:37 pm, Keith Edmunds wrote: > What are others doing for application logging? I'm not referring to the > HTTP logs, but program-generated logs. > > I've recently been looking at the Python 'logging' module, which I've not > used before. I initiate logging from a file in the 'modules' directory > which does this: > > --- > - > import logging > from logging.handlers import SysLogHandler > > logger = logging.getLogger("MyApp") > logger.setLevel(logging.DEBUG) > hdlr = SysLogHandler(address='/dev/log') > formatter = logging.Formatter('tigerpy[%(process)d]: %(levelname)s: > %(filename)s at line %(lineno)d: %(message)s') hdlr.setFormatter(formatter) > logger.addHandler(hdlr) > --- > - > > Then each file that I want to log from does this: > > --- > - > import logging > > logger = logging.getLogger("MyApp") > . > . > logger.info("Something interesting happened") > --- > - > > This logs to syslog: the only problem is that each logging message is > written to syslog many (20-40) times(!). This isn't just in one place in > my code, but throughout. I don't think the code is being executed multiple > times, so I'm not sure why I'm getting so many log entries. > > So, I'm interested in what others do to log application events. > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
Re: [web2py] Re: Webfaction rocks
You should be able to tell your browser (if firefox) to accept the SSL certificate anyways. At least, you have to do that with self-signed certificates as well. As far as publishing SSH, sometimes I just fire up a program called gFTP (for Ubuntu Linux), and SFTP (ssh-ftp) into my account, and just drag/drop my app over into the appropriate place. Ubuntu has nicely integrated FuseFS as well, so you can mount your server over SSH as just another folder on your system which is the way I work most of the time. Lately however, I have been using Fabric (a glorified python based Makefile) to publish my apps with one command. -- Thadeus On Tue, Apr 27, 2010 at 10:01 AM, Jonathan Lundell wrote: > On Apr 27, 2010, at 7:32 AM, aure wrote: > >> As I had started to do it your way before you even mentioned it >> (created 2 websites...), I decided to try your solution. >> Unfortunately, when I try to access the admin website I get this in >> Firefox: >> >> -- >> Secure Connection Failed >> >> admin.aurerua.webfactional.com uses an invalid security certificate. >> >> The certificate is only valid for the following names: >> *.webfaction.com , webfaction.com >> >> (Error code: ssl_error_bad_cert_domain) >> -- >> >> Do you remember getting this as well when you did your setup? I do not >> know how to solve this... > > I haven't been following this thead, but... > > Can you access it via aurerua.webfactional.com? (That is, leave off the > admin.) Both names resolve to the same IP, and the cert ought to work for the > shorter address. > > -- > Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en >
[web2py] Re: questions on example in official web2py book
Thanks Yarko. Note I have no issues run the examples in the book. For example it works if I open http://127.0.0.1/images/default/show/1 it works great. the problem is the example seems not quite robust, if I point the browser to htttp://127.0.0.1:8000/images/default/show It gives me an error. Ticket 127.0.0.1.2010-04-27.11-16-18.9e6c05a6-6ac6-446d-9e59- f1c8b209343d Error traceback Traceback (most recent call last): File "gluon/restricted.py", line 178, in restricted File "C:/Documents and Settings/frank.zhu/My Documents/Downloads/ web2py/applications/images/controllers/default.py", line 60, in File "gluon/globals.py", line 96, in File "C:/Documents and Settings/frank.zhu/My Documents/Downloads/ web2py/applications/images/controllers/default.py", line 16, in show File "gluon/sql.py", line 3438, in __getitem__ IndexError: list index out of range In file: C:\Documents and Settings\frank.zhu\My Documents\Downloads \web2py\applications\images/controllers/default.py # -*- coding: utf-8 -*- # ## This is a samples controller ## - index is the default action of any application ## - user is required for authentication and authorization ## - download is for downloading files uploaded in the db (does streaming) ## - call exposes all registered services (none by default) # def index(): images = db().select(db.image.ALL, orderby=db.image.title) return dict(images=images) def show(): image = db(db.image.id==request.args(0)).select()[0] if len(image) == 0: print "No images found!" form = SQLFORM(db.comment) form.vars.image_id = image.id if form.accepts(request.vars, session): response.flash = 'your comment is posted' comments = db(db.comment.image_id==image.id).select() return dict(image=image, comments=comments, form=form) I think now I know why, the request.args(0) doesn't contain any image id, so the following is one way to get around this issue def show(): id = request.args(0) or 1 # id default to 1 image = db(db.image.id==id).select()[0] form = SQLFORM(db.comment) form.vars.image_id = image.id if form.accepts(request.vars, session): response.flash = 'your comment is posted' comments = db(db.comment.image_id==image.id).select() return dict(image=image, comments=comments, form=form) On Apr 26, 6:55 pm, Yarko Tymciurak wrote: > On Apr 26, 4:38 pm, frankz wrote: > > > Hi, > > in the web2py official book, in the image blog example, > > Referring tohttp://web2py.com/book/default/section/3/6?search=image+blog > > > Could anyone help explain what the following line mean? > > image = db(db.image.id==request.args(0)).select()[0] > > This example code assume's you've entered an image in the database; if > you have not, > then the select()[0] reference would give you index out of > range. > > Here's why: > > - This is a database select query; it's form is basically: > > your_db_connection( WHERE clause; in this case where ID of the image > table is same as what requested).select( fields - "ALL" by default) > > This returns an array of records found in the database - if none, it > returns an empty array, []. > > A more robust way to write this (not used, so the example would be > short) would be something like this: > > images = db(db.image.id==request.args(0)).select() > if len(images) == 0: print "No images found!" > else: image = images[0] > > I hope this has been helpful. > Regards, > - Yarko > > > > > I duplicate the same code but I find URL > > htttp://127.0.0.1:8000/images/default/show > > gives me an error, "index out of range" > > > How do I fix it? > > > Thanks, > > > -- > > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
Re: [web2py] Re: Webfaction rocks
On Apr 27, 2010, at 7:32 AM, aure wrote: > As I had started to do it your way before you even mentioned it > (created 2 websites...), I decided to try your solution. > Unfortunately, when I try to access the admin website I get this in > Firefox: > > -- > Secure Connection Failed > > admin.aurerua.webfactional.com uses an invalid security certificate. > > The certificate is only valid for the following names: > *.webfaction.com , webfaction.com > > (Error code: ssl_error_bad_cert_domain) > -- > > Do you remember getting this as well when you did your setup? I do not > know how to solve this... I haven't been following this thead, but... Can you access it via aurerua.webfactional.com? (That is, leave off the admin.) Both names resolve to the same IP, and the cert ought to work for the shorter address. -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Decimal
Field('totalsale', 'decimal(10,8)')) # this is not required, it is automatic db.document.totalsale.requires=IS_DECIMAL() sqlite does not support decimal so this behaves as a double with sqlitle. I am using sqlite. On Apr 27, 9:42 am, greenpoise wrote: > I see a few threads on decimal values. What is the final status of > this? Is the field name type Numeric or Integer decimal? such as : > > Field('totalsale', 'integer')) > db.document.totalsale.requires=IS_DECIMAL() > > I am using sqlite. > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Webfaction rocks
Hello Thadeus, After trying Annet's solution, I tried yours. Now if I try to access my site I get a webfaction message: "Site not configured..." This seems to be because I have enables HTTPS. Is normal that I cannot access the website using HTTP now? I am a bit confused. Now if try to access the site using https I get the same message in Firefox as described in my reply to Annet, namely: -- Secure Connection Failed admin.aurerua.webfactional.com uses an invalid security certificate. The certificate is only valid for the following names: *.webfaction.com , webfaction.com (Error code: ssl_error_bad_cert_domain) -- Do you know what could cause the problem? Otherwise, you mentioned in some post above that you are "comfortable enough with ssh to publish the app manually". Maybe I could do that. I would not need to use the admin app online, is it true? In that case, how do you publish an app manually? Sorry for all these questions. I would be so glad to be able to put my first web2py app online! Aurelien On 25 avr, 17:16, Thadeus Burgess wrote: > - SSH into the machine, navigate to your root web2py directory > (containing web2py.py), and then run ``python2.5 web2py.py -a > `` > - Then rename parameters_8000.py to parameters_443.py > - Make sure you have HTTPS triggered for your domain inside the > webfaction control panel. > > Replace your app like any other web2py app, using the admin application. > > You can only have one web2py instance running on a domain and it has > to be the root domain. However you can have as many web2py apps > running on this instance as you want, and you can always use routes to > make sure things go to the correct place (say each app has its own > domain). > > -- > Thadeus > > On Sun, Apr 25, 2010 at 6:12 AM, aure wrote: > > ssible to have more than one application working on one > > domain? or spread them to subdom > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Decimal
I see a few threads on decimal values. What is the final status of this? Is the field name type Numeric or Integer decimal? such as : Field('totalsale', 'integer')) db.document.totalsale.requires=IS_DECIMAL() I am using sqlite. -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: Webfaction rocks
Hello Annet, As I had started to do it your way before you even mentioned it (created 2 websites...), I decided to try your solution. Unfortunately, when I try to access the admin website I get this in Firefox: -- Secure Connection Failed admin.aurerua.webfactional.com uses an invalid security certificate. The certificate is only valid for the following names: *.webfaction.com , webfaction.com (Error code: ssl_error_bad_cert_domain) -- Do you remember getting this as well when you did your setup? I do not know how to solve this... Kind regards, Aurelien Aurelien On 25 avr, 18:30, annet wrote: > I took a somewhat different approach. I signed up for a shared 1 plan > and got a dedicated IP address. Under domains I added two subdomains: > www and admin. Under applications I created a web2py application of > type custom install script (http://wiki.webfaction.com/wiki/Web2py- > LatestSource?format=txt). Under websites I created two websites one > with https disabled for mydomain.com andwww.mydomain.comand one with > https enabled for admin .mydomain.com in both cases I selected my > dedicated IP address from the IP menu. > > Now admin can be accessed from:https://admin.mydomain.comusing the > same initial password as the webfaction control panel. In my post of > 20 April I described how to install an application. > > Furthermore, according to Massimo this is not true: > > CAVEATS > * Web2py won't work properly if it is mounted to a sub-URL > likehttp://domain.com/web2py/. Instead, it must be mounted to the website > root, e.g.http://domain.com/ > > Massimo's comment on this caveat: > > "It is not true. It can be mounted in a sub-url but you the web server > or web2py routes must be instructed to remove the "web2py/" from the > url." > > Kind regards, > > Annet. > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: fatal bug in 1.77.3
Tim, did you try with the IS_IMAGE validator? On Apr 27, 7:56 am, Timothy Farrell wrote: > Let us know if it comes up again. > > -tim > > On 4/27/2010 1:30 AM, hywang wrote: > > > when i try it again today, everything is ok today. > > I don't know why :-( > > > On 4月26日, 下午11时42分, mdipierro wrote: > > >> I cannot reproduce this either. It is not an internationalization > >> issue. I suspect something else in the code is causing this. We need > >> to see at the entire code. > > >> On Apr 26, 10:37 am, Timothy Farrell wrote: > > >>> My assumption that web2py is returning something other than a list comes > >>> from the traceback. Why would calling: > > >>> len(returned_obj) > > >>> go into the cgi module if it was a string? Rocket alone does not use > >>> the cgi module at all so the returned object must be related to it > >>> somehow. We know that lists that contain strings do not relate to the > >>> cgi module. > > >>> All that aside, there's something more going on here. I've plugged > >>> hwangs code into a test application here and could not reproduce the > >>> problematic behavior. The only changes I made to the code posted was > >>> changing request.flash = 'ok' to response.flash = 'ok' and adding a db = > >>> DAL('sqlite://storage.db') to the model file. > > >>> Could there be a i18n/l10n issue here? > > >>> -tim > > >>> On 4/26/2010 9:16 AM, mdipierro wrote: > > I think we need some debugging. His code is > > def hello(): > form = SQLFORM(db.easy_test) > if form.accepts(request.vars, session): > request.flash = 'ok' > return dict(form=form) > > and web2py returns a list with a string in this case (the generic view > that renders the dict()). I do not see how web2py can return anything > else. > > On Apr 26, 8:04 am, Timothy Farrell wrote: > > > Massimo, I know you sent me an email on this but I can't find it so I'll > > just reply to the list. > > > Rocket is dying in this case because the object it has received from > > web2py is not a valid WSGI response. A valid WSGI response must be > > either a list or generator (Rocket is a little more tolerant and will > > accept a string as well). But in this case it seems to be getting some > > form of a cgi.FieldStorage type as evidenced by the traceback going into > > the cgi module when Rocket tries to read the length of the returned > > object. > > > Massimo, I've seen the web2py code that it normally scrubs returned > > objects. This was a while ago and may have changed since then. > > > Rocket could die a little more gracefully, but I'd rather keep the code > > lean rather than checking every response for validity. As a test, there > > is a WSGI validator in the wsgiref module that works as middleware. You > > might hook that up to see what is really coming back. > > > -tim > > > On 4/26/2010 1:53 AM, hywang wrote: > > >> i has no view . > >> when i test newest version in google hg server, web2py works well, > >> but if I add IS_IMAGE() validator, some error occured again. > > >> ver1.6x works well > > >> On 4 26 , 2ʱ01 , mdipierro wrote: > > >>> Do you have a view with a custom form? > > >>> On Apr 25, 10:53 pm, hywang wrote: > > I run web2py from source on centos 5.3. > When upload a file, an error occurs. > -db.py--- > db.define_table('easy_test', > Field('picture', 'upload') > ) > > -controller file--- > def hello(): > form = SQLFORM(db.easy_test) > if form.accepts(request.vars, session): > request.flash = 'ok' > return dict(form=form) > > when submit the form, it returns 'server error' > consel error msg : > ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): > File "E:\web2py\gluon\rocket.py", line 747, in run > self.run_app(conn) > File "E:\web2py\gluon\rocket.py", line 1162, in run_app > sections = len(output) > File "C:\Python25\lib\cgi.py", line 633, in __len__ > return len(self.keys()) > File "C:\Python25\lib\cgi.py", line 609, in keys > raise TypeError, "not indexable" > TypeError: not indexable > > -- > Subscription > settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] ASP vs Rails 3 (vs web2py?)
Who is brave enough to rewrite this and add web2py? http://anders.janmyr.com/2010/04/aspnet-mvc-vs-rails3.html -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: error occurs when use upload field + is_image()
Do you get the error only with IS_IMAGE? On Apr 27, 2:52 am, hywang wrote: > web2py Ver 1.77.3 > > db.define_table('test_pic', > Field('picture', 'upload') > ) > > def hello(): > form = SQLFORM(db.test_pic) > if form.accepts(request.vars, session): > response.flash = 'ok' > return dict(form=form) > > it works well. > > when add validator IS_IMAGE > db.define_table('test_pic', > Field('picture', 'upload', requires=IS_IMAGE(extensions=('png'))) > ) > > an error occurs : > ERROR:Rocket.Errors.Thread-7:Traceback (most recent call last): > File "E:\web2py\gluon\rocket.py", line 747, in run > self.run_app(conn) > File "E:\web2py\gluon\rocket.py", line 1162, in run_app > sections = len(output) > File "C:\Python25\lib\cgi.py", line 633, in __len__ > return len(self.keys()) > File "C:\Python25\lib\cgi.py", line 609, in keys > raise TypeError, "not indexable" > TypeError: not indexable > > This error also reproduced on different platforms > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Re: how can customize auth.table_user, I want to add avatar
which os? On Apr 27, 2:43 am, hywang wrote: > avatar is commonly used when user registers. But auth.table_user > dosen't has this field. > > Maybe I can add a Field('avatar', 'upload') to auth.table_user. I did > do it, but failed: an error occured. > ERROR:Rocket.Errors.Thread-7:Traceback (most recent call last): > File "E:\web2py\gluon\rocket.py", line 747, in run > self.run_app(conn) > File "E:\web2py\gluon\rocket.py", line 1162, in run_app > sections = len(output) > File "C:\Python25\lib\cgi.py", line 633, in __len__ > return len(self.keys()) > File "C:\Python25\lib\cgi.py", line 609, in keys > raise TypeError, "not indexable" > TypeError: not indexable > > this error can be reproduced, i try it on different platforms, dear > friends, you can try it by yourself. > > Is there another solution ? > thanks > > -- > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
Re: [web2py] Re: fatal bug in 1.77.3
Let us know if it comes up again. -tim On 4/27/2010 1:30 AM, hywang wrote: when i try it again today, everything is ok today. I don't know why :-( On 4月26日, 下午11时42分, mdipierro wrote: I cannot reproduce this either. It is not an internationalization issue. I suspect something else in the code is causing this. We need to see at the entire code. On Apr 26, 10:37 am, Timothy Farrell wrote: My assumption that web2py is returning something other than a list comes from the traceback. Why would calling: len(returned_obj) go into the cgi module if it was a string? Rocket alone does not use the cgi module at all so the returned object must be related to it somehow. We know that lists that contain strings do not relate to the cgi module. All that aside, there's something more going on here. I've plugged hwangs code into a test application here and could not reproduce the problematic behavior. The only changes I made to the code posted was changing request.flash = 'ok' to response.flash = 'ok' and adding a db = DAL('sqlite://storage.db') to the model file. Could there be a i18n/l10n issue here? -tim On 4/26/2010 9:16 AM, mdipierro wrote: I think we need some debugging. His code is def hello(): form = SQLFORM(db.easy_test) if form.accepts(request.vars, session): request.flash = 'ok' return dict(form=form) and web2py returns a list with a string in this case (the generic view that renders the dict()). I do not see how web2py can return anything else. On Apr 26, 8:04 am, Timothy Farrellwrote: Massimo, I know you sent me an email on this but I can't find it so I'll just reply to the list. Rocket is dying in this case because the object it has received from web2py is not a valid WSGI response. A valid WSGI response must be either a list or generator (Rocket is a little more tolerant and will accept a string as well). But in this case it seems to be getting some form of a cgi.FieldStorage type as evidenced by the traceback going into the cgi module when Rocket tries to read the length of the returned object. Massimo, I've seen the web2py code that it normally scrubs returned objects. This was a while ago and may have changed since then. Rocket could die a little more gracefully, but I'd rather keep the code lean rather than checking every response for validity. As a test, there is a WSGI validator in the wsgiref module that works as middleware. You might hook that up to see what is really coming back. -tim On 4/26/2010 1:53 AM, hywang wrote: i has no view . when i test newest version in google hg server, web2py works well, but if I add IS_IMAGE() validator, some error occured again. ver1.6x works well On 4 26 , 2ʱ01 , mdipierrowrote: Do you have a view with a custom form? On Apr 25, 10:53 pm, hywangwrote: I run web2py from source on centos 5.3. When upload a file, an error occurs. -db.py--- db.define_table('easy_test', Field('picture', 'upload') ) -controller file--- def hello(): form = SQLFORM(db.easy_test) if form.accepts(request.vars, session): request.flash = 'ok' return dict(form=form) when submit the form, it returns 'server error' consel error msg : ERROR:Rocket.Errors.Thread-3:Traceback (most recent call last): File "E:\web2py\gluon\rocket.py", line 747, in run self.run_app(conn) File "E:\web2py\gluon\rocket.py", line 1162, in run_app sections = len(output) File "C:\Python25\lib\cgi.py", line 633, in __len__ return len(self.keys()) File "C:\Python25\lib\cgi.py", line 609, in keys raise TypeError, "not indexable" TypeError: not indexable -- Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] error occurs when use upload field + is_image()
web2py Ver 1.77.3 db.define_table('test_pic', Field('picture', 'upload') ) def hello(): form = SQLFORM(db.test_pic) if form.accepts(request.vars, session): response.flash = 'ok' return dict(form=form) it works well. when add validator IS_IMAGE db.define_table('test_pic', Field('picture', 'upload', requires=IS_IMAGE(extensions=('png'))) ) an error occurs : ERROR:Rocket.Errors.Thread-7:Traceback (most recent call last): File "E:\web2py\gluon\rocket.py", line 747, in run self.run_app(conn) File "E:\web2py\gluon\rocket.py", line 1162, in run_app sections = len(output) File "C:\Python25\lib\cgi.py", line 633, in __len__ return len(self.keys()) File "C:\Python25\lib\cgi.py", line 609, in keys raise TypeError, "not indexable" TypeError: not indexable This error also reproduced on different platforms -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] how can customize auth.table_user, I want to add avatar
avatar is commonly used when user registers. But auth.table_user dosen't has this field. Maybe I can add a Field('avatar', 'upload') to auth.table_user. I did do it, but failed: an error occured. ERROR:Rocket.Errors.Thread-7:Traceback (most recent call last): File "E:\web2py\gluon\rocket.py", line 747, in run self.run_app(conn) File "E:\web2py\gluon\rocket.py", line 1162, in run_app sections = len(output) File "C:\Python25\lib\cgi.py", line 633, in __len__ return len(self.keys()) File "C:\Python25\lib\cgi.py", line 609, in keys raise TypeError, "not indexable" TypeError: not indexable this error can be reproduced, i try it on different platforms, dear friends, you can try it by yourself. Is there another solution ? thanks -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] uploadwidget bug
db.define_table('test_pic', Field('picture', 'upload') ) def reupload_pic(): form = SQLFORM(db.test_pic, 1, upload=URL(r=request, f='download')) if form.accepts(request.vars, session): response.flash = 'ok' return dict(form=form) I specify parameter 'upload' to show submited picture. record 1 is a girl's picture. when visit reupload_pic, webpage shows picture correctly, it is a girl's picture. however, if I change it to a boy's picture and submit the form, picture shown dosen't change, it is still the girl's picture . when visit the url again, it is ok. -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en