[web2py] Re: JS question
Massimo, You go above and beyond! Thanks you so much for the through explanation. This second version is much much cleaner then the version before it - thanks for hacking trunk to add the change! Now I have to integrate it and make sure I understand how everything works! -Rob On Aug 8, 4:32 pm, mdipierro wrote: > Actually your questions gave me some ideas on how to simplify the > web2py syntax in using components. With the code in trunk you can now > rewrite the component > > {{=LOAD('rsvp','rsvp',ajax=True)}} > > as follows: > > def rsvp(): > > """ > self contained component to handle RSVP requests and > notificaitons > """ > rsvp = db.rsvp(event=request.args(0),attendee=auth.user_id) > if not rsvp and not auth.user: > return A('login to > rsvp',_href=URL('default','user',args='login')) > elif request.args(1)=='yes' and not rsvp: > db.rsvp.insert(event=request.args(0),attendee=auth.user_id) > response.js='jQuery("#%s").hide().fadeIn("slow")' % > request.cid > return 'Thanks for RSVPing for this event' > elif rsvp: > return 'You are registered for this event' > else: > return A('You are not registered for this event, click to > RSVP', > > _href=URL(args=(request.args(0),'yes')),cid=request.cid) > > Notice how: > - request.cid is the ID of the ... that contains the > component and it is assigned automatically > - If A(...,cid=request.cid) is set the target of the link stays in the > component > - response.js sets the JS to be executed after component response > > All component logic stays in one function. This function could have > its own view but in this case it is not needed. > > REQUIRES TRUNK! > > On Aug 8, 1:20 pm, mdipierro wrote: > > > > > > > I would do this (on top of the scaffolding app) > > > 1) model/db_rsvp.py > > > db.define_table('event', > > Field('name',requires=IS_NOT_EMPTY()), > > Field('start_time','datetime'), > > Field('location'), > > > Field('posted_by',db.auth_user,default=auth.user_id,writable=False)) > > db.define_table('rsvp', > > Field('attendee',db.auth_user), > > Field('event',db.event)) > > > 2) controllers/srvp.py > > > def events(): > > > """ > > List future events and allow to create new events if logged- > > in > > """ > > form = auth.user and crud.create(db.event) > > events = db(db.event.start_time>request.now).select() > > return dict(events=events,form=form) > > > @auth.requires_login() > > def show(): > > > """ > > Show info avout event id==arg(0), list attendees and allow rsvp > > via load > > Also allow event owner to edit > > event > > """ > > event = db.event(request.args(0),posted_by=auth.user_id) > > form = event and crud.update(db.event,event) > > rsvps = db(db.rsvp.event==event.id).select() > > attendees = db(db.auth_user.id.belongs(r.attendee for r in > > rsvps)).select() > > return dict(event=event,attendees=attendees,form=form) > > > 3) views/rsvp/events.html > > > {{extend 'layout.html'}} > > {{for event in events:}} > > {{=event.start_time}} > > {{=A(event.name,_href=URL('show',args=event.id))}} > > {{pass}} > > {{=form or A('login to post a new > > event',_href=URL('download','user',args='login'))}} > > > 4) views/rsvp/show.html > > > {{extend 'layout.html'}} > > {{=event.name}} > > {{=event.location}} @ {{=prettydate(event.start_time)}} > > {{=LOAD('rsvp','rsvp',args=event.id,ajax=True)}} > > Registered Attendees > > {{for attendee in attendees:}} > > {{='%(first_name)s %(last_name)s' % attendee}} > > {{pass}} > > > 5) ajax callback that handles RSVP component: > > > def rsvp(): > > > """ > > self contained component to handle RSVP requests and > > notificaitons > > """ > > component_url = URL(r=request,args=(request.args(0),'yes')) > > component_id = request.env.http_web2py_component_element > > rsvp = db.rsvp(event=request.args(0),attendee=auth.user_id) > > if not rsvp and not auth.user: > > return A('login to > > rsvp',_href=URL('default','user',args='login')) > > elif request.args(1)=='yes' and not rsvp: > > db.rsvp.insert(event=request.args(0),attendee=auth.user_id) > > response.headers['web2py-component- > > command']='alert("Thanks!");' > > return SPAN('Thanks for RSVPing for this event') > > elif rsvp: > > return SPAN('You are registered for this event') > > else: > > return SPAN('You are not registered for this event ', > > A('click here to RSVP', > > > _onclick='web2py_ajax_page("GET","%s",null,"%s");return false' % \ > > (component_url,component_id))) > > > perhaps can simplify the API a bit.
[web2py] Re: Web2py Application Exhibition -- Winners!
On Aug 7, 3:09 pm, Vasile Ermicioi wrote: > me too Actually i have written a website and also have an application (Ticket Management) written and gelled in it. Its far more than just ticket management app, it encompasses patch management, change mgt, complete integration with emails, graphs and PDF reports etc. Multi user support, team support it has concept of workspaces. The problem in submitting the application was that its ".w2p" was itself 207MB+ zipped. Also I wanted to submit the app as closed source app. Although the app is free for personal use ;-) . The way of making it I discovered only recently. :( Anyways I am in India and am working things out with my webservices provider to host and upload my web2py powered site. Once that is done, I'll mail the link available to all. I'll be posting this app as showcase app as technology demo on my site. Cheers, Rahul Dhakate
Re: [web2py] Book in Italian, Spanish, Portuguese, Chinese and Russian (sort of)
Portuguese version is really funny :o| , absolutelly wrong, as portuguese is a "strange", non semantic and complex language. Look how the Python Chapter were translated back into english.. - Python is a general purpose, and about programming of very high level languages. By the way, this is very useful to be used as a guide for a human translator. Tks 2010/8/8 mdipierro > I have been playing with google translate and I managed to get a > complete translation of the book in Italian, Spanish, Portuguese, > Chinese and Russian. > > DISCLAMER: > > - The translation is bad but for non-english speakers, it is still > better than the english version. > - The translation was completely automated with NO MANUAL > intervention. > - I only read (partially) the italian translation. It is quite funny > and often wrong. > - The translation only includes the alpha version of the book. > - This is a proof of concept. The idea is to use this as a blueprint > so that translators can fix it online before we make proper corrected > production version. > - The license is Artistic License and YOU CAN redistribute the files. > - You are not allowed to use this admittedly bad translations to > complain about the quality of web2py. ;-) > > Here are the PDF: > > http://web2py.com/book/static/web2py_manual_it.pdf > http://web2py.com/book/static/web2py_manual_es.pdf > http://web2py.com/book/static/web2py_manual_pt.pdf > > And here are Russian and Chinese in Latex zipped: > > http://web2py.com/book/static/web2py_manual_zh.zip > http://web2py.com/book/static/web2py_manual_ru.zip > (I have been unable to process these perhaps you can help me) > > You can laugh (LOL) but please DO NOT jam my web server. The PDF files > are huge ~6MB and ~530 pages. > -- http://rochacbruno.com.br
Re: [web2py] Book in Italian, Spanish, Portuguese, Chinese and Russian (sort of)
On Mon, Aug 9, 2010 at 09:10, mdipierro wrote: > I have been playing with google translate and I managed to get a > complete translation of the book in Italian, Spanish, Portuguese, > Chinese and Russian. > e that realy can not read by Chinese...; in fact we base web2py manual ed2,start translation and publishing: http://obp.stdyun.com/w2py_manual_zh/ base Sphinx ;-) so this TeX veriosn,is base http://web2py.com/book ? can we merge the ed2 chinese version into the online 3rd Ed. - alpha? - notice the http://web2py.com/book is one perfect Wiki, should we make branch for Chinese? (base english) so we can base wiki completed chiese translation? - or we fixed the TeX verion ,and submit for u,and make new Chinese branch in http://web2py.com/book ? > DISCLAMER: > > - The translation is bad but for non-english speakers, it is still > better than the english version. > - The translation was completely automated with NO MANUAL > intervention. > - I only read (partially) the italian translation. It is quite funny > and often wrong. > - The translation only includes the alpha version of the book. > - This is a proof of concept. The idea is to use this as a blueprint > so that translators can fix it online before we make proper corrected > production version. > - The license is Artistic License and YOU CAN redistribute the files. > - You are not allowed to use this admittedly bad translations to > complain about the quality of web2py. ;-) > > Here are the PDF: > > http://web2py.com/book/static/web2py_manual_it.pdf > http://web2py.com/book/static/web2py_manual_es.pdf > http://web2py.com/book/static/web2py_manual_pt.pdf > > And here are Russian and Chinese in Latex zipped: > > http://web2py.com/book/static/web2py_manual_zh.zip > http://web2py.com/book/static/web2py_manual_ru.zip > (I have been unable to process these perhaps you can help me) > > You can laugh (LOL) but please DO NOT jam my web server. The PDF files > are huge ~6MB and ~530 pages. > -- http://zoomquiet.org 人生苦短? Pythonic!
Re: [web2py] routes_in 153, me 0
On Aug 8, 2010, at 6:15 PM, Andrew Thompson wrote: > On 8/8/2010 9:10 PM, Jonathan Lundell wrote: >> Is it possible that lighttpd is altering the URL enough that it doesn't >> match what you've got in routes.py? > > Perhaps. I've got to figure out how to test for that. I'll try to send Massimo a logging patch tomorrow, but if you look at rewrite.py, it should be semi-clear how to do it yourself. filter_in is where you want to log, and I'd log the arguments and return value of the filter_url call. In your case, the return value 'path' is what you want to see.
Re: [web2py] routes_in 153, me 0
On 8/8/2010 9:10 PM, Jonathan Lundell wrote: Is it possible that lighttpd is altering the URL enough that it doesn't match what you've got in routes.py? Perhaps. I've got to figure out how to test for that. -- Andrew Thompson http://aktzero.com/
Re: [web2py] routes_in 153, me 0
On 8/8/2010 8:33 PM, Thadeus Burgess wrote: The routes.example.py contains some unit tests. I have found this to be the most effective way of testing my routes to make sure they do what I want. Perhaps email clients munged it, but I have an existing filter_url doctest that seems to indicate that I'm doing the right thing. -- Andrew Thompson http://aktzero.com/
[web2py] Book in Italian, Spanish, Portuguese, Chinese and Russian (sort of)
I have been playing with google translate and I managed to get a complete translation of the book in Italian, Spanish, Portuguese, Chinese and Russian. DISCLAMER: - The translation is bad but for non-english speakers, it is still better than the english version. - The translation was completely automated with NO MANUAL intervention. - I only read (partially) the italian translation. It is quite funny and often wrong. - The translation only includes the alpha version of the book. - This is a proof of concept. The idea is to use this as a blueprint so that translators can fix it online before we make proper corrected production version. - The license is Artistic License and YOU CAN redistribute the files. - You are not allowed to use this admittedly bad translations to complain about the quality of web2py. ;-) Here are the PDF: http://web2py.com/book/static/web2py_manual_it.pdf http://web2py.com/book/static/web2py_manual_es.pdf http://web2py.com/book/static/web2py_manual_pt.pdf And here are Russian and Chinese in Latex zipped: http://web2py.com/book/static/web2py_manual_zh.zip http://web2py.com/book/static/web2py_manual_ru.zip (I have been unable to process these perhaps you can help me) You can laugh (LOL) but please DO NOT jam my web server. The PDF files are huge ~6MB and ~530 pages.
Re: [web2py] routes_in 153, me 0
On Aug 8, 2010, at 6:00 PM, Andrew Thompson wrote: > On 8/8/2010 8:30 PM, Jonathan Lundell wrote: >> On Aug 8, 2010, at 5:10 PM, Andrew Thompson wrote: >> >>> I can not wrap my head around routes_in. I'm attempting to host 3 sites via >>> lighttpd and fcgihandler.py (is this the best way?) >>> >>> I ripped this mostly from a mdpierro post, and tweaked it for my domain, >>> but I'm just not making progress: >>> >>> ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', >>> '/mysite/static/favicon.ico'), >>> >>> http://mysite.com/mysite/static/favicon.ico<-- this link works. >>> http://myste.com/favicon.ico<-- Invalid request >> You meant 'mysite', right? > Yeah, examplification typo. > >>> I've been playing with the builtin doctest, and this passes: >>> >> filter_url('http://mysite.com/favicon.ico') >>> 'http://mysite.com/mysite/static/favicon.ico' >>> >>> Any ideas what I'm doing wrong? >> You're restarting web2py when you change routes.py? > Yes, I am. > >> I think it'd be useful to be able to turn on logging of URL rewriting. It'd >> be pretty verbose, I suppose, but useful for this kind of problem. >> >>> I do need the / to /mysite's to keep the sites separated from each other, >>> don't I? >> I don't follow the question. > Ignore it, I realized the initial domain to site mapping is happening in > lighttpd. Is it possible that lighttpd is altering the URL enough that it doesn't match what you've got in routes.py?
Re: [web2py] routes_in 153, me 0
On 8/8/2010 8:30 PM, Jonathan Lundell wrote: On Aug 8, 2010, at 5:10 PM, Andrew Thompson wrote: I can not wrap my head around routes_in. I'm attempting to host 3 sites via lighttpd and fcgihandler.py (is this the best way?) I ripped this mostly from a mdpierro post, and tweaked it for my domain, but I'm just not making progress: ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', '/mysite/static/favicon.ico'), http://mysite.com/mysite/static/favicon.ico<-- this link works. http://myste.com/favicon.ico<-- Invalid request You meant 'mysite', right? Yeah, examplification typo. I've been playing with the builtin doctest, and this passes: filter_url('http://mysite.com/favicon.ico') 'http://mysite.com/mysite/static/favicon.ico' Any ideas what I'm doing wrong? You're restarting web2py when you change routes.py? Yes, I am. I think it'd be useful to be able to turn on logging of URL rewriting. It'd be pretty verbose, I suppose, but useful for this kind of problem. I do need the / to /mysite's to keep the sites separated from each other, don't I? I don't follow the question. Ignore it, I realized the initial domain to site mapping is happening in lighttpd. -- Andrew Thompson http://aktzero.com/
[web2py] Re: Autocompletion Widget
You must have computed field that contains the contend you want to use 'name + town' On Aug 8, 7:06 pm, villas wrote: > I have the following requirements: > > 1) The widget to show the 'name' but save the 'id' > 2) The widget to reveal the fields 'name' plus 'town' in the drop down > selection. > > The built-in autocomplete widget provides 1) but I cannot see how to > do 2). > > The code in sqlhtml.py seems rather complex. I tried to use a > virtualfield to join the two fields together and show that, but it > does not seem to work. > > Mr Freeze's slice 66 seems like it might be easier to adapt, but I > would need to add both requirements, which is still probably beyond my > skills. > (http://www.web2pyslices.com/main/slices/take_slice/66) > > Can anyone give me a pointer, thanks. > -- > David
Re: [web2py] routes_in 153, me 0
On Aug 8, 2010, at 5:33 PM, Thadeus Burgess wrote: > The routes.example.py contains some unit tests. I have found this to > be the most effective way of testing my routes to make sure they do > what I want. Also, I sent a note (yesterday?) to this list on how to use compile_re() in doctest to see what the regex turned into (web2py munges it a little). That can be helpful. filter_url in the doctest has to convert the "incoming" URL to a set of env variables, in imitation of the web server. So the action of the server isn't in the loop, which could make a difference in some circumstances, I suppose. That's why I'd like to see logging. rewrite.py already does some logging. I'll take a look at doing something simpleminded. Maybe a logging-enable variable in routes.py I'm hacking in there anyway at the moment. > > -- > Thadeus > > > > > > On Sun, Aug 8, 2010 at 7:30 PM, Jonathan Lundell wrote: >> On Aug 8, 2010, at 5:10 PM, Andrew Thompson wrote: >> >>> I can not wrap my head around routes_in. I'm attempting to host 3 sites via >>> lighttpd and fcgihandler.py (is this the best way?) >>> >>> I ripped this mostly from a mdpierro post, and tweaked it for my domain, >>> but I'm just not making progress: >>> >>> ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', >>> '/mysite/static/favicon.ico'), >>> >>> http://mysite.com/mysite/static/favicon.ico <-- this link works. >>> http://myste.com/favicon.ico <-- Invalid request >> >> You meant 'mysite', right? >> >>> >>> I've been playing with the builtin doctest, and this passes: >>> >> filter_url('http://mysite.com/favicon.ico') >>> 'http://mysite.com/mysite/static/favicon.ico' >>> >>> Any ideas what I'm doing wrong? >> >> You're restarting web2py when you change routes.py? >> >> I think it'd be useful to be able to turn on logging of URL rewriting. It'd >> be pretty verbose, I suppose, but useful for this kind of problem. >> >>> >>> I have two more lines commented out that I also want to put in: >>> >>> ('(.*):https?://(.*)mysite\.com:(.*) /$anything', '/mysite/$anything'), >>> ('(.*):https?://(.*)mysite\.com:(.*) /images/$anything', >>> '/mysite/static/images/$anything'), >>> >>> I'm not sure, is $anything is compatible with all those .*'es? >> >> I think so. No need to parenthesize them, since there's no capture going on. >> I might use .*? instead. But .* should work in this case. >> >>> >>> I do need the / to /mysite's to keep the sites separated from each other, >>> don't I? >> >> I don't follow the question. >> >>> >>> Any help appreciated. >>> >>> -- >>> Andrew Thompson >>> http://aktzero.com/ >>> >> >> >>
Re: [web2py] routes_in 153, me 0
The routes.example.py contains some unit tests. I have found this to be the most effective way of testing my routes to make sure they do what I want. -- Thadeus On Sun, Aug 8, 2010 at 7:30 PM, Jonathan Lundell wrote: > On Aug 8, 2010, at 5:10 PM, Andrew Thompson wrote: > >> I can not wrap my head around routes_in. I'm attempting to host 3 sites via >> lighttpd and fcgihandler.py (is this the best way?) >> >> I ripped this mostly from a mdpierro post, and tweaked it for my domain, but >> I'm just not making progress: >> >> ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', >> '/mysite/static/favicon.ico'), >> >> http://mysite.com/mysite/static/favicon.ico <-- this link works. >> http://myste.com/favicon.ico <-- Invalid request > > You meant 'mysite', right? > >> >> I've been playing with the builtin doctest, and this passes: >> >> >>> filter_url('http://mysite.com/favicon.ico') >> 'http://mysite.com/mysite/static/favicon.ico' >> >> Any ideas what I'm doing wrong? > > You're restarting web2py when you change routes.py? > > I think it'd be useful to be able to turn on logging of URL rewriting. It'd > be pretty verbose, I suppose, but useful for this kind of problem. > >> >> I have two more lines commented out that I also want to put in: >> >> ('(.*):https?://(.*)mysite\.com:(.*) /$anything', '/mysite/$anything'), >> ('(.*):https?://(.*)mysite\.com:(.*) /images/$anything', >> '/mysite/static/images/$anything'), >> >> I'm not sure, is $anything is compatible with all those .*'es? > > I think so. No need to parenthesize them, since there's no capture going on. > I might use .*? instead. But .* should work in this case. > >> >> I do need the / to /mysite's to keep the sites separated from each other, >> don't I? > > I don't follow the question. > >> >> Any help appreciated. >> >> -- >> Andrew Thompson >> http://aktzero.com/ >> > > >
Re: [web2py] routes_in 153, me 0
On Aug 8, 2010, at 5:10 PM, Andrew Thompson wrote: > I can not wrap my head around routes_in. I'm attempting to host 3 sites via > lighttpd and fcgihandler.py (is this the best way?) > > I ripped this mostly from a mdpierro post, and tweaked it for my domain, but > I'm just not making progress: > > ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', > '/mysite/static/favicon.ico'), > > http://mysite.com/mysite/static/favicon.ico <-- this link works. > http://myste.com/favicon.ico <-- Invalid request You meant 'mysite', right? > > I've been playing with the builtin doctest, and this passes: > > >>> filter_url('http://mysite.com/favicon.ico') > 'http://mysite.com/mysite/static/favicon.ico' > > Any ideas what I'm doing wrong? You're restarting web2py when you change routes.py? I think it'd be useful to be able to turn on logging of URL rewriting. It'd be pretty verbose, I suppose, but useful for this kind of problem. > > I have two more lines commented out that I also want to put in: > > ('(.*):https?://(.*)mysite\.com:(.*) /$anything', '/mysite/$anything'), > ('(.*):https?://(.*)mysite\.com:(.*) /images/$anything', > '/mysite/static/images/$anything'), > > I'm not sure, is $anything is compatible with all those .*'es? I think so. No need to parenthesize them, since there's no capture going on. I might use .*? instead. But .* should work in this case. > > I do need the / to /mysite's to keep the sites separated from each other, > don't I? I don't follow the question. > > Any help appreciated. > > -- > Andrew Thompson > http://aktzero.com/ >
Re: [web2py] routes_in 153, me 0
('.*:https?://dashboard\.thadeusb\.com:.* /admin(?P.*)', '/admin\g'), ('.*:https?://thadeusb\.com:.* /(?P.*)', '/blogitizor/\g'), This is what I am currently using. -- Thadeus On Sun, Aug 8, 2010 at 7:10 PM, Andrew Thompson wrote: > I can not wrap my head around routes_in. I'm attempting to host 3 sites via > lighttpd and fcgihandler.py (is this the best way?) > > I ripped this mostly from a mdpierro post, and tweaked it for my domain, but > I'm just not making progress: > > ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', > '/mysite/static/favicon.ico'), > > http://mysite.com/mysite/static/favicon.ico <-- this link works. > http://myste.com/favicon.ico <-- Invalid request > > I've been playing with the builtin doctest, and this passes: > filter_url('http://mysite.com/favicon.ico') > 'http://mysite.com/mysite/static/favicon.ico' > > Any ideas what I'm doing wrong? > > I have two more lines commented out that I also want to put in: > > ('(.*):https?://(.*)mysite\.com:(.*) /$anything', '/mysite/$anything'), > ('(.*):https?://(.*)mysite\.com:(.*) /images/$anything', > '/mysite/static/images/$anything'), > > I'm not sure, is $anything is compatible with all those .*'es? > > I do need the / to /mysite's to keep the sites separated from each other, > don't I? > > Any help appreciated. > > -- > Andrew Thompson > http://aktzero.com/ > >
[web2py] routes_in 153, me 0
I can not wrap my head around routes_in. I'm attempting to host 3 sites via lighttpd and fcgihandler.py (is this the best way?) I ripped this mostly from a mdpierro post, and tweaked it for my domain, but I'm just not making progress: ('(.*):https?://(.*)mysite\.com:(.*) /favicon.ico', '/mysite/static/favicon.ico'), http://mysite.com/mysite/static/favicon.ico <-- this link works. http://myste.com/favicon.ico <-- Invalid request I've been playing with the builtin doctest, and this passes: >>> filter_url('http://mysite.com/favicon.ico') 'http://mysite.com/mysite/static/favicon.ico' Any ideas what I'm doing wrong? I have two more lines commented out that I also want to put in: ('(.*):https?://(.*)mysite\.com:(.*) /$anything', '/mysite/$anything'), ('(.*):https?://(.*)mysite\.com:(.*) /images/$anything', '/mysite/static/images/$anything'), I'm not sure, is $anything is compatible with all those .*'es? I do need the / to /mysite's to keep the sites separated from each other, don't I? Any help appreciated. -- Andrew Thompson http://aktzero.com/
[web2py] Autocompletion Widget
I have the following requirements: 1) The widget to show the 'name' but save the 'id' 2) The widget to reveal the fields 'name' plus 'town' in the drop down selection. The built-in autocomplete widget provides 1) but I cannot see how to do 2). The code in sqlhtml.py seems rather complex. I tried to use a virtualfield to join the two fields together and show that, but it does not seem to work. Mr Freeze's slice 66 seems like it might be easier to adapt, but I would need to add both requirements, which is still probably beyond my skills. (http://www.web2pyslices.com/main/slices/take_slice/66) Can anyone give me a pointer, thanks. -- David
[web2py] Re: JS question
Actually your questions gave me some ideas on how to simplify the web2py syntax in using components. With the code in trunk you can now rewrite the component {{=LOAD('rsvp','rsvp',ajax=True)}} as follows: def rsvp(): """ self contained component to handle RSVP requests and notificaitons """ rsvp = db.rsvp(event=request.args(0),attendee=auth.user_id) if not rsvp and not auth.user: return A('login to rsvp',_href=URL('default','user',args='login')) elif request.args(1)=='yes' and not rsvp: db.rsvp.insert(event=request.args(0),attendee=auth.user_id) response.js='jQuery("#%s").hide().fadeIn("slow")' % request.cid return 'Thanks for RSVPing for this event' elif rsvp: return 'You are registered for this event' else: return A('You are not registered for this event, click to RSVP', _href=URL(args=(request.args(0),'yes')),cid=request.cid) Notice how: - request.cid is the ID of the ... that contains the component and it is assigned automatically - If A(...,cid=request.cid) is set the target of the link stays in the component - response.js sets the JS to be executed after component response All component logic stays in one function. This function could have its own view but in this case it is not needed. REQUIRES TRUNK! On Aug 8, 1:20 pm, mdipierro wrote: > I would do this (on top of the scaffolding app) > > 1) model/db_rsvp.py > > db.define_table('event', > Field('name',requires=IS_NOT_EMPTY()), > Field('start_time','datetime'), > Field('location'), > > Field('posted_by',db.auth_user,default=auth.user_id,writable=False)) > db.define_table('rsvp', > Field('attendee',db.auth_user), > Field('event',db.event)) > > 2) controllers/srvp.py > > def events(): > > """ > List future events and allow to create new events if logged- > in > """ > form = auth.user and crud.create(db.event) > events = db(db.event.start_time>request.now).select() > return dict(events=events,form=form) > > @auth.requires_login() > def show(): > > """ > Show info avout event id==arg(0), list attendees and allow rsvp > via load > Also allow event owner to edit > event > """ > event = db.event(request.args(0),posted_by=auth.user_id) > form = event and crud.update(db.event,event) > rsvps = db(db.rsvp.event==event.id).select() > attendees = db(db.auth_user.id.belongs(r.attendee for r in > rsvps)).select() > return dict(event=event,attendees=attendees,form=form) > > 3) views/rsvp/events.html > > {{extend 'layout.html'}} > {{for event in events:}} > {{=event.start_time}} > {{=A(event.name,_href=URL('show',args=event.id))}} > {{pass}} > {{=form or A('login to post a new > event',_href=URL('download','user',args='login'))}} > > 4) views/rsvp/show.html > > {{extend 'layout.html'}} > {{=event.name}} > {{=event.location}} @ {{=prettydate(event.start_time)}} > {{=LOAD('rsvp','rsvp',args=event.id,ajax=True)}} > Registered Attendees > {{for attendee in attendees:}} > {{='%(first_name)s %(last_name)s' % attendee}} > {{pass}} > > 5) ajax callback that handles RSVP component: > > def rsvp(): > > """ > self contained component to handle RSVP requests and > notificaitons > """ > component_url = URL(r=request,args=(request.args(0),'yes')) > component_id = request.env.http_web2py_component_element > rsvp = db.rsvp(event=request.args(0),attendee=auth.user_id) > if not rsvp and not auth.user: > return A('login to > rsvp',_href=URL('default','user',args='login')) > elif request.args(1)=='yes' and not rsvp: > db.rsvp.insert(event=request.args(0),attendee=auth.user_id) > response.headers['web2py-component- > command']='alert("Thanks!");' > return SPAN('Thanks for RSVPing for this event') > elif rsvp: > return SPAN('You are registered for this event') > else: > return SPAN('You are not registered for this event ', > A('click here to RSVP', > > _onclick='web2py_ajax_page("GET","%s",null,"%s");return false' % \ > (component_url,component_id))) > > perhaps can simplify the API a bit.
[web2py] Re: Why is routes.py not recommended for production?
Jonathan is right. That sentence is also a relic of older version of the manual when routes was not very well tested. I will correct or move those statements. On Aug 8, 4:48 pm, Jonathan Lundell wrote: > On Aug 8, 2010, at 2:35 PM, mwolfe02 wrote: > > > > > According to the web2py book, routes.py should not be used in > > production environment (http://web2py.com/book/default/chapter/04? > > search=lighttpd). Instead, Apache/lighttpd web server rewrite is > > suggested. > > > I assumed this was due to some overhead that using routes.py would > > incur. However, massimo's response in this post from January (http:// > > groups.google.com/group/web2py/browse_thread/thread/39e72dc4a68f33a1) > > seems to suggest that's not the case. His response to the question, > > Why is routes.py not preferred? "No reason. No overhead." > > > If that's the case, then that's great news. I would much rather > > rewrite my urls inside web2py. > > > If there is overhead involved, how does it compare to whatever > > overhead may be involved with Django's urls.py? Is there a > > fundamental difference between how the two frameworks implement url > > rewriting (other than the fact that it is required in Django and > > optional in web2py)? > > The reason (I think) is that Apache can serve certain static files and the > like directly, without invoking web2py at all. It's not the overhead of using > routes.py; it's the overhead of having web2py serve stuff that it doesn't > need to. > > There might be more to it than that.
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
:-) On Aug 8, 3:31 pm, Zhe Li wrote: > Finally!! It works now! I switched my dev server to ubuntu 9.10 and > everything works now! I couldn't find a repository for python2.5- > psycopg2 in ubuntu 10.04 so I didn't try that. > > Regards, > Zhe > > On Aug 8, 8:57 pm, Zhe Li wrote: > > > Just now I found that it was using python2.5 and python2.5-psycopg2 in > > the script, but in ubuntu 10.04 they have been removed from > > repository. I will try to re-install it manually. > > > Cheers, > > Zhe > > > On Aug 8, 8:27 pm, Zhe Li wrote: > > > > Just an interesting note. Yesterday after the fresh re-installation, I > > > tried to run "python web2py.py -a 0 -i 0.0.0.0" without psycog2, it > > > gave me an "unable to connect to db" too, but didn't say that psycopg2 > > > is missing. Can it be the reason here? But I installed psycopg2 with > > > apt-get it should set the path correctly. > > > > Cheers, > > > Zhe > > > > On Aug 8, 8:18 pm, Zhe Li wrote: > > > > > Hi, > > > > > I changed > > > > > local all web2py ident > > > > > to > > > > > local all all md5 > > > > > in pg_hba.conf, but it still can't connect to it. > > > > but i can connect to the database using: > > > > > sudo -u www-data psql -h localhost labdb -U web2py > > > > > Does that mean www-data has the permissions? By the way I was using > > > > setup_web2py_ubuntu.sh so if it works on other machines, it should > > > > work here too. Maybe I should try to set it manually following the > > > > instructions in your book. > > > > > Cheers, > > > > Zhe > > > > > On Aug 8, 7:31 pm, mdipierro wrote: > > > > > > aha! I think it is a problem with permissions of contect of databases > > > > > folder. Make sure the apache/www-data user has permissions to read and > > > > > write > > > > > > On Aug 8, 6:32 am, Zhe Li wrote: > > > > > > > Hi Massimo, > > > > > > > Yes this time I was running it from a fresh installed ubuntu server > > > > > > so > > > > > > PostgreSQL was using the default port. > > > > > > > I changed the pool_size to 0 and tried a couple of combinations. > > > > > > Maybe > > > > > > it is a configuration problem with my PostgreSQL? > > > > > > > 1. If I run: > > > > > > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > > > > > > I will got an error of "ProgrammingError: relation 'auth_group' > > > > > > already exists". > > > > > > > 2. visit the site runs on WSGI+apache gives me: > > > > > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > > > > > 3. Launch site with the identical web2py code in my folder: > > > > > > > python web2py.py -a 0 -i 0.0.0.0 > > > > > > > it runs without any problems. > > > > > > > Here is part of my pg_hba.conf: > > > > > > > local all postgres ident > > > > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > > > > > local all web2py ident > > > > > > host all all 192.168.0.0/24 md5 > > > > > > host all all 127.0.0.1/32 md5 > > > > > > host all all ::1/128 md5 > > > > > > > and my postgresql.conf is: > > > > > > > listen_addresses = '*' # what IP address(es) to listen on; > > > > > > port = 5432 # (change requires restart) > > > > > > max_connections = 100 # (change requires restart) > > > > > > > Thank you very much! > > > > > > > Regards, > > > > > > Zhe > > > > > > > On Aug 8, 2:30 am, mdipierro wrote: > > > > > > > > Didn't you say? > > > > > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > > > > > pool_size=10) > > > > > > > > is the DB at port 1216 or 5432? > > > > > > > Can you try with pool_size=0 just to isolate the problem. > > > > > > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > > > > > Hi Massimo, > > > > > > > > > I am using PostgreSQL 8.4. > > > > > > > > > I added print(msg) and got the message when runnning python > > > > > > > > web2.py -a > > > > > > > > 123, the string looks like > > > > > > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > > > > > > password='test123' > > > > > > > > > I only have this error when using web2py with WSGI. But if I go > > > > > > > > to the > > > > > > > > shell from the admin page running with WSGI, I could use > > > > > > > > PostgreSQL > > > > > > > > without any problems. I tried this: > > > > > > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' > > > > > > > > host='localhost' > > > > > > > > port=5432 password='test123'") > > > > > > > > > and it works, I successfully added a table and a test record... > > > > > > > > > Thank you! > > > > > > > > > Cheers, > > > > > > > > Zhe > > > > > > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > > > > > > One more test: > > > > > > > > > > In gluon/sql.py > > > > > > > > > > before line 957, print your connection string: > > >
Re: [web2py] Why is routes.py not recommended for production?
- very *little overhead* - routes.py is loaded only when web2py starts and regex patterns are compiled, and this is just a string operation (regex) on a short string (url) why I prefer to rewrite urls in web2py: - *no external dependencies*, like mod_rewrite - *portability - *is mod rewrite the same for nginx, lighttpd, apache, IIS etc ? - I found it *easier *to rewrite urls in web2py( http://web2py.com/book/default/chapter/04?search=lighttpd#URL-Rewrite ) than with apache mod_rewrite( http://httpd.apache.org/docs/2.0/misc/rewriteguide.html), when I first read about mod_rewrite I was scared :), even having a quite long experience with regex
[web2py] Re: LOAD... and jquerytools
Change cdn.jquerytools.org to jqueryui , it works fine. On 8 août, 22:04, JmiXIII wrote: > Well in fact it does not render for N°1=>N°3 in my code > Yet I'm not used to using javascript and ajax and does not know > firebug enough. > But here is the code rendered : > > > > Date/Heure > > controle 1 > controle 2 > Hello World type="text/javascript"> N°1 > > > ... > > enreg 1 > enreg 2 > > > > As I can find the {{=LOAD('default','index.load')}} this is not a > web2py issue. I Just have find why this does not render. > Thanks > > On 8 août, 19:32, mdipierro wrote: > > > Please clarify what you mean by does not work. Did you try firebug? is > > the ajax call executed? Do you get a response? If so, it is a JS > > problem. > > > On Aug 8, 7:19 am, JmiXIII wrote: > > > > Hello ! > > > > Here is a view in which I am using LOAD helper > > > I have put {{=LOAD('default','index.load')}} N°# in several places in > > > the code below > > > I am also using jquerytools > > > :http://cdn.jquerytools.org/1.2.1/jquery.tools.min.js > > > from my controler > > > > The only {{=LOAD('default','index.load')}} working is N°#4 outside the > > > div affected by jquerytools > > > > Can someone explain me why the other doesn't work ? Does that mean I > > > can't use LOAD with jquerytools ? > > > > Thanks a lot > > > > {{extend 'layout.html'}} > > > {{=Selection}} > > > {{=CArt}}{{=ArtOF}} > > > > > > > > > Suivi Prod > > > Synthèse OF > > > Non conformités > > > Suivi de contrôle > > > > > > > > > > > > > > > > stuffs > > > > > > > > > stuffs > > > > > > > > > stuffs > > > > > > > > > > > > > > > Date/Heure > > > controle 1 > > > controle 2 > > > {{=LOAD('default','index.load')}} N°1 > > > > > > > > > ... > > > enreg 1 > > > enreg 2 > > > > > > > > > {{=LOAD('default','index.load')}} N°2 > > > > > > {{=LOAD('default','index.load')}} N°3 > > > > > > {{=LOAD('default','index.load')}} N°4 > > > > > > > > > $(function() { > > > // :first selector is optional if you have only one tabs on the > > > page > > > $(".css-tabs:first").tabs(".css-panes:first > div");}); > > > >
Re: [web2py] Why is routes.py not recommended for production?
On Aug 8, 2010, at 2:35 PM, mwolfe02 wrote: > According to the web2py book, routes.py should not be used in > production environment (http://web2py.com/book/default/chapter/04? > search=lighttpd). Instead, Apache/lighttpd web server rewrite is > suggested. > > I assumed this was due to some overhead that using routes.py would > incur. However, massimo's response in this post from January (http:// > groups.google.com/group/web2py/browse_thread/thread/39e72dc4a68f33a1) > seems to suggest that's not the case. His response to the question, > Why is routes.py not preferred? "No reason. No overhead." > > If that's the case, then that's great news. I would much rather > rewrite my urls inside web2py. > > If there is overhead involved, how does it compare to whatever > overhead may be involved with Django's urls.py? Is there a > fundamental difference between how the two frameworks implement url > rewriting (other than the fact that it is required in Django and > optional in web2py)? The reason (I think) is that Apache can serve certain static files and the like directly, without invoking web2py at all. It's not the overhead of using routes.py; it's the overhead of having web2py serve stuff that it doesn't need to. There might be more to it than that.
[web2py] Why is routes.py not recommended for production?
According to the web2py book, routes.py should not be used in production environment (http://web2py.com/book/default/chapter/04? search=lighttpd). Instead, Apache/lighttpd web server rewrite is suggested. I assumed this was due to some overhead that using routes.py would incur. However, massimo's response in this post from January (http:// groups.google.com/group/web2py/browse_thread/thread/39e72dc4a68f33a1) seems to suggest that's not the case. His response to the question, Why is routes.py not preferred? "No reason. No overhead." If that's the case, then that's great news. I would much rather rewrite my urls inside web2py. If there is overhead involved, how does it compare to whatever overhead may be involved with Django's urls.py? Is there a fundamental difference between how the two frameworks implement url rewriting (other than the fact that it is required in Django and optional in web2py)? Thanks, Mike
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Finally!! It works now! I switched my dev server to ubuntu 9.10 and everything works now! I couldn't find a repository for python2.5- psycopg2 in ubuntu 10.04 so I didn't try that. Regards, Zhe On Aug 8, 8:57 pm, Zhe Li wrote: > Just now I found that it was using python2.5 and python2.5-psycopg2 in > the script, but in ubuntu 10.04 they have been removed from > repository. I will try to re-install it manually. > > Cheers, > Zhe > > On Aug 8, 8:27 pm, Zhe Li wrote: > > > > > Just an interesting note. Yesterday after the fresh re-installation, I > > tried to run "python web2py.py -a 0 -i 0.0.0.0" without psycog2, it > > gave me an "unable to connect to db" too, but didn't say that psycopg2 > > is missing. Can it be the reason here? But I installed psycopg2 with > > apt-get it should set the path correctly. > > > Cheers, > > Zhe > > > On Aug 8, 8:18 pm, Zhe Li wrote: > > > > Hi, > > > > I changed > > > > local all web2py ident > > > > to > > > > local all all md5 > > > > in pg_hba.conf, but it still can't connect to it. > > > but i can connect to the database using: > > > > sudo -u www-data psql -h localhost labdb -U web2py > > > > Does that mean www-data has the permissions? By the way I was using > > > setup_web2py_ubuntu.sh so if it works on other machines, it should > > > work here too. Maybe I should try to set it manually following the > > > instructions in your book. > > > > Cheers, > > > Zhe > > > > On Aug 8, 7:31 pm, mdipierro wrote: > > > > > aha! I think it is a problem with permissions of contect of databases > > > > folder. Make sure the apache/www-data user has permissions to read and > > > > write > > > > > On Aug 8, 6:32 am, Zhe Li wrote: > > > > > > Hi Massimo, > > > > > > Yes this time I was running it from a fresh installed ubuntu server so > > > > > PostgreSQL was using the default port. > > > > > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > > > > > it is a configuration problem with my PostgreSQL? > > > > > > 1. If I run: > > > > > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > > > > > I will got an error of "ProgrammingError: relation 'auth_group' > > > > > already exists". > > > > > > 2. visit the site runs on WSGI+apache gives me: > > > > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > > > > 3. Launch site with the identical web2py code in my folder: > > > > > > python web2py.py -a 0 -i 0.0.0.0 > > > > > > it runs without any problems. > > > > > > Here is part of my pg_hba.conf: > > > > > > local all postgres ident > > > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > > > > local all web2py ident > > > > > host all all 192.168.0.0/24 md5 > > > > > host all all 127.0.0.1/32 md5 > > > > > host all all ::1/128 md5 > > > > > > and my postgresql.conf is: > > > > > > listen_addresses = '*' # what IP address(es) to listen on; > > > > > port = 5432 # (change requires restart) > > > > > max_connections = 100 # (change requires restart) > > > > > > Thank you very much! > > > > > > Regards, > > > > > Zhe > > > > > > On Aug 8, 2:30 am, mdipierro wrote: > > > > > > > Didn't you say? > > > > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > > > > pool_size=10) > > > > > > > is the DB at port 1216 or 5432? > > > > > > Can you try with pool_size=0 just to isolate the problem. > > > > > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > > > > Hi Massimo, > > > > > > > > I am using PostgreSQL 8.4. > > > > > > > > I added print(msg) and got the message when runnning python > > > > > > > web2.py -a > > > > > > > 123, the string looks like > > > > > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > > > > > password='test123' > > > > > > > > I only have this error when using web2py with WSGI. But if I go > > > > > > > to the > > > > > > > shell from the admin page running with WSGI, I could use > > > > > > > PostgreSQL > > > > > > > without any problems. I tried this: > > > > > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' > > > > > > > host='localhost' > > > > > > > port=5432 password='test123'") > > > > > > > > and it works, I successfully added a table and a test record... > > > > > > > > Thank you! > > > > > > > > Cheers, > > > > > > > Zhe > > > > > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > > > > > One more test: > > > > > > > > > In gluon/sql.py > > > > > > > > > before line 957, print your connection string: > > > > > > > > print msg > > > > > > > > Would that connection string work on the shell? Which postgresql > > > > > > > > version are you using? > > > > > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > > > > > Yeah, that works fine. It's so odd and frust
[web2py] Re: LOAD... and jquerytools
Well in fact it does not render for N°1=>N°3 in my code Yet I'm not used to using javascript and ajax and does not know firebug enough. But here is the code rendered : Date/Heure controle 1 controle 2 Hello World N°1 ... enreg 1 enreg 2 As I can find the {{=LOAD('default','index.load')}} this is not a web2py issue. I Just have find why this does not render. Thanks On 8 août, 19:32, mdipierro wrote: > Please clarify what you mean by does not work. Did you try firebug? is > the ajax call executed? Do you get a response? If so, it is a JS > problem. > > On Aug 8, 7:19 am, JmiXIII wrote: > > > Hello ! > > > Here is a view in which I am using LOAD helper > > I have put {{=LOAD('default','index.load')}} N°# in several places in > > the code below > > I am also using jquerytools > > :http://cdn.jquerytools.org/1.2.1/jquery.tools.min.js > > from my controler > > > The only {{=LOAD('default','index.load')}} working is N°#4 outside the > > div affected by jquerytools > > > Can someone explain me why the other doesn't work ? Does that mean I > > can't use LOAD with jquerytools ? > > > Thanks a lot > > > {{extend 'layout.html'}} > > {{=Selection}} > > {{=CArt}}{{=ArtOF}} > > > > > > Suivi Prod > > Synthèse OF > > Non conformités > > Suivi de contrôle > > > > > > > > > > > stuffs > > > > > > stuffs > > > > > > stuffs > > > > > > > > > > Date/Heure > > controle 1 > > controle 2 > > {{=LOAD('default','index.load')}} N°1 > > > > > > ... > > enreg 1 > > enreg 2 > > > > > > {{=LOAD('default','index.load')}} N°2 > > > > {{=LOAD('default','index.load')}} N°3 > > > > {{=LOAD('default','index.load')}} N°4 > > > > > > $(function() { > > // :first selector is optional if you have only one tabs on the page > > $(".css-tabs:first").tabs(".css-panes:first > div");}); > > >
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Just now I found that it was using python2.5 and python2.5-psycopg2 in the script, but in ubuntu 10.04 they have been removed from repository. I will try to re-install it manually. Cheers, Zhe On Aug 8, 8:27 pm, Zhe Li wrote: > Just an interesting note. Yesterday after the fresh re-installation, I > tried to run "python web2py.py -a 0 -i 0.0.0.0" without psycog2, it > gave me an "unable to connect to db" too, but didn't say that psycopg2 > is missing. Can it be the reason here? But I installed psycopg2 with > apt-get it should set the path correctly. > > Cheers, > Zhe > > On Aug 8, 8:18 pm, Zhe Li wrote: > > > > > Hi, > > > I changed > > > local all web2py ident > > > to > > > local all all md5 > > > in pg_hba.conf, but it still can't connect to it. > > but i can connect to the database using: > > > sudo -u www-data psql -h localhost labdb -U web2py > > > Does that mean www-data has the permissions? By the way I was using > > setup_web2py_ubuntu.sh so if it works on other machines, it should > > work here too. Maybe I should try to set it manually following the > > instructions in your book. > > > Cheers, > > Zhe > > > On Aug 8, 7:31 pm, mdipierro wrote: > > > > aha! I think it is a problem with permissions of contect of databases > > > folder. Make sure the apache/www-data user has permissions to read and > > > write > > > > On Aug 8, 6:32 am, Zhe Li wrote: > > > > > Hi Massimo, > > > > > Yes this time I was running it from a fresh installed ubuntu server so > > > > PostgreSQL was using the default port. > > > > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > > > > it is a configuration problem with my PostgreSQL? > > > > > 1. If I run: > > > > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > > > > I will got an error of "ProgrammingError: relation 'auth_group' > > > > already exists". > > > > > 2. visit the site runs on WSGI+apache gives me: > > > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > > > 3. Launch site with the identical web2py code in my folder: > > > > > python web2py.py -a 0 -i 0.0.0.0 > > > > > it runs without any problems. > > > > > Here is part of my pg_hba.conf: > > > > > local all postgres ident > > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > > > local all web2py ident > > > > host all all 192.168.0.0/24 md5 > > > > host all all 127.0.0.1/32 md5 > > > > host all all ::1/128 md5 > > > > > and my postgresql.conf is: > > > > > listen_addresses = '*' # what IP address(es) to listen on; > > > > port = 5432 # (change requires restart) > > > > max_connections = 100 # (change requires restart) > > > > > Thank you very much! > > > > > Regards, > > > > Zhe > > > > > On Aug 8, 2:30 am, mdipierro wrote: > > > > > > Didn't you say? > > > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > > > pool_size=10) > > > > > > is the DB at port 1216 or 5432? > > > > > Can you try with pool_size=0 just to isolate the problem. > > > > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > > > Hi Massimo, > > > > > > > I am using PostgreSQL 8.4. > > > > > > > I added print(msg) and got the message when runnning python web2.py > > > > > > -a > > > > > > 123, the string looks like > > > > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > > > > password='test123' > > > > > > > I only have this error when using web2py with WSGI. But if I go to > > > > > > the > > > > > > shell from the admin page running with WSGI, I could use PostgreSQL > > > > > > without any problems. I tried this: > > > > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' > > > > > > host='localhost' > > > > > > port=5432 password='test123'") > > > > > > > and it works, I successfully added a table and a test record... > > > > > > > Thank you! > > > > > > > Cheers, > > > > > > Zhe > > > > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > > > > One more test: > > > > > > > > In gluon/sql.py > > > > > > > > before line 957, print your connection string: > > > > > > > print msg > > > > > > > Would that connection string work on the shell? Which postgresql > > > > > > > version are you using? > > > > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > > > > > I have no idea. Can you connect from a pure python shell > > > > > > > > > using the > > > > > > > > > driver API? > > > > > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > > > > > thanks! > > > > > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 > > > > > > > > > > (it's > > > > > > > > > > actually ip). but it doesn't
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Just an interesting note. Yesterday after the fresh re-installation, I tried to run "python web2py.py -a 0 -i 0.0.0.0" without psycog2, it gave me an "unable to connect to db" too, but didn't say that psycopg2 is missing. Can it be the reason here? But I installed psycopg2 with apt-get it should set the path correctly. Cheers, Zhe On Aug 8, 8:18 pm, Zhe Li wrote: > Hi, > > I changed > > local all web2py ident > > to > > local all all md5 > > in pg_hba.conf, but it still can't connect to it. > but i can connect to the database using: > > sudo -u www-data psql -h localhost labdb -U web2py > > Does that mean www-data has the permissions? By the way I was using > setup_web2py_ubuntu.sh so if it works on other machines, it should > work here too. Maybe I should try to set it manually following the > instructions in your book. > > Cheers, > Zhe > > On Aug 8, 7:31 pm, mdipierro wrote: > > > > > aha! I think it is a problem with permissions of contect of databases > > folder. Make sure the apache/www-data user has permissions to read and > > write > > > On Aug 8, 6:32 am, Zhe Li wrote: > > > > Hi Massimo, > > > > Yes this time I was running it from a fresh installed ubuntu server so > > > PostgreSQL was using the default port. > > > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > > > it is a configuration problem with my PostgreSQL? > > > > 1. If I run: > > > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > > > I will got an error of "ProgrammingError: relation 'auth_group' > > > already exists". > > > > 2. visit the site runs on WSGI+apache gives me: > > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > > 3. Launch site with the identical web2py code in my folder: > > > > python web2py.py -a 0 -i 0.0.0.0 > > > > it runs without any problems. > > > > Here is part of my pg_hba.conf: > > > > local all postgres ident > > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > > local all web2py ident > > > host all all 192.168.0.0/24 md5 > > > host all all 127.0.0.1/32 md5 > > > host all all ::1/128 md5 > > > > and my postgresql.conf is: > > > > listen_addresses = '*' # what IP address(es) to listen on; > > > port = 5432 # (change requires restart) > > > max_connections = 100 # (change requires restart) > > > > Thank you very much! > > > > Regards, > > > Zhe > > > > On Aug 8, 2:30 am, mdipierro wrote: > > > > > Didn't you say? > > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > > pool_size=10) > > > > > is the DB at port 1216 or 5432? > > > > Can you try with pool_size=0 just to isolate the problem. > > > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > > Hi Massimo, > > > > > > I am using PostgreSQL 8.4. > > > > > > I added print(msg) and got the message when runnning python web2.py -a > > > > > 123, the string looks like > > > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > > > password='test123' > > > > > > I only have this error when using web2py with WSGI. But if I go to the > > > > > shell from the admin page running with WSGI, I could use PostgreSQL > > > > > without any problems. I tried this: > > > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > > > > > port=5432 password='test123'") > > > > > > and it works, I successfully added a table and a test record... > > > > > > Thank you! > > > > > > Cheers, > > > > > Zhe > > > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > > > One more test: > > > > > > > In gluon/sql.py > > > > > > > before line 957, print your connection string: > > > > > > print msg > > > > > > Would that connection string work on the shell? Which postgresql > > > > > > version are you using? > > > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > > > > I have no idea. Can you connect from a pure python shell using > > > > > > > > the > > > > > > > > driver API? > > > > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > > > > thanks! > > > > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 > > > > > > > > > (it's > > > > > > > > > actually ip). but it doesn't work > > > > > > > > > > Cheers, > > > > > > > > > Zhe > > > > > > > > > > On Aug 6, 12:33 pm, mdipierro wrote: > > > > > > > > > > > Try replace > > > > > > > > > > > localhost > > > > > > > > > > with > > > > > > > > > > 127.0.0.1 > > > > > > > > > > and with the actual IP of the machine. It may not be > > > > > > > > > > serving on > > > > > > > > > > localhost > > > > > > > > > > > On Aug 6, 5:25 am, Zhe Li wrote: > > > > > > > > > > > > Hi, > > >
[web2py] Re: JS question
I would do this (on top of the scaffolding app) 1) model/db_rsvp.py db.define_table('event', Field('name',requires=IS_NOT_EMPTY()), Field('start_time','datetime'), Field('location'), Field('posted_by',db.auth_user,default=auth.user_id,writable=False)) db.define_table('rsvp', Field('attendee',db.auth_user), Field('event',db.event)) 2) controllers/srvp.py def events(): """ List future events and allow to create new events if logged- in """ form = auth.user and crud.create(db.event) events = db(db.event.start_time>request.now).select() return dict(events=events,form=form) @auth.requires_login() def show(): """ Show info avout event id==arg(0), list attendees and allow rsvp via load Also allow event owner to edit event """ event = db.event(request.args(0),posted_by=auth.user_id) form = event and crud.update(db.event,event) rsvps = db(db.rsvp.event==event.id).select() attendees = db(db.auth_user.id.belongs(r.attendee for r in rsvps)).select() return dict(event=event,attendees=attendees,form=form) 3) views/rsvp/events.html {{extend 'layout.html'}} {{for event in events:}} {{=event.start_time}} {{=A(event.name,_href=URL('show',args=event.id))}} {{pass}} {{=form or A('login to post a new event',_href=URL('download','user',args='login'))}} 4) views/rsvp/show.html {{extend 'layout.html'}} {{=event.name}} {{=event.location}} @ {{=prettydate(event.start_time)}} {{=LOAD('rsvp','rsvp',args=event.id,ajax=True)}} Registered Attendees {{for attendee in attendees:}} {{='%(first_name)s %(last_name)s' % attendee}} {{pass}} 5) ajax callback that handles RSVP component: def rsvp(): """ self contained component to handle RSVP requests and notificaitons """ component_url = URL(r=request,args=(request.args(0),'yes')) component_id = request.env.http_web2py_component_element rsvp = db.rsvp(event=request.args(0),attendee=auth.user_id) if not rsvp and not auth.user: return A('login to rsvp',_href=URL('default','user',args='login')) elif request.args(1)=='yes' and not rsvp: db.rsvp.insert(event=request.args(0),attendee=auth.user_id) response.headers['web2py-component- command']='alert("Thanks!");' return SPAN('Thanks for RSVPing for this event') elif rsvp: return SPAN('You are registered for this event') else: return SPAN('You are not registered for this event ', A('click here to RSVP', _onclick='web2py_ajax_page("GET","%s",null,"%s");return false' % \ (component_url,component_id))) perhaps can simplify the API a bit.
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Hi, I changed local all web2pyident to local all allmd5 in pg_hba.conf, but it still can't connect to it. but i can connect to the database using: sudo -u www-data psql -h localhost labdb -U web2py Does that mean www-data has the permissions? By the way I was using setup_web2py_ubuntu.sh so if it works on other machines, it should work here too. Maybe I should try to set it manually following the instructions in your book. Cheers, Zhe On Aug 8, 7:31 pm, mdipierro wrote: > aha! I think it is a problem with permissions of contect of databases > folder. Make sure the apache/www-data user has permissions to read and > write > > On Aug 8, 6:32 am, Zhe Li wrote: > > > > > Hi Massimo, > > > Yes this time I was running it from a fresh installed ubuntu server so > > PostgreSQL was using the default port. > > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > > it is a configuration problem with my PostgreSQL? > > > 1. If I run: > > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > > I will got an error of "ProgrammingError: relation 'auth_group' > > already exists". > > > 2. visit the site runs on WSGI+apache gives me: > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > 3. Launch site with the identical web2py code in my folder: > > > python web2py.py -a 0 -i 0.0.0.0 > > > it runs without any problems. > > > Here is part of my pg_hba.conf: > > > local all postgres ident > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > local all web2py ident > > host all all 192.168.0.0/24 md5 > > host all all 127.0.0.1/32 md5 > > host all all ::1/128 md5 > > > and my postgresql.conf is: > > > listen_addresses = '*' # what IP address(es) to listen on; > > port = 5432 # (change requires restart) > > max_connections = 100 # (change requires restart) > > > Thank you very much! > > > Regards, > > Zhe > > > On Aug 8, 2:30 am, mdipierro wrote: > > > > Didn't you say? > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > pool_size=10) > > > > is the DB at port 1216 or 5432? > > > Can you try with pool_size=0 just to isolate the problem. > > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > Hi Massimo, > > > > > I am using PostgreSQL 8.4. > > > > > I added print(msg) and got the message when runnning python web2.py -a > > > > 123, the string looks like > > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > > password='test123' > > > > > I only have this error when using web2py with WSGI. But if I go to the > > > > shell from the admin page running with WSGI, I could use PostgreSQL > > > > without any problems. I tried this: > > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > > > > port=5432 password='test123'") > > > > > and it works, I successfully added a table and a test record... > > > > > Thank you! > > > > > Cheers, > > > > Zhe > > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > > One more test: > > > > > > In gluon/sql.py > > > > > > before line 957, print your connection string: > > > > > print msg > > > > > Would that connection string work on the shell? Which postgresql > > > > > version are you using? > > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > > > I have no idea. Can you connect from a pure python shell using the > > > > > > > driver API? > > > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > > > thanks! > > > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 (it's > > > > > > > > actually ip). but it doesn't work > > > > > > > > > Cheers, > > > > > > > > Zhe > > > > > > > > > On Aug 6, 12:33 pm, mdipierro wrote: > > > > > > > > > > Try replace > > > > > > > > > > localhost > > > > > > > > > with > > > > > > > > > 127.0.0.1 > > > > > > > > > and with the actual IP of the machine. It may not be serving > > > > > > > > > on > > > > > > > > > localhost > > > > > > > > > > On Aug 6, 5:25 am, Zhe Li wrote: > > > > > > > > > > > Hi, > > > > > > > > > > > Thanks! This is the result from trunk. > > > > > > > > > > > Error traceback > > > > > > > > > > Traceback (most recent call last): > > > > > > > > > > File "gluon/restricted.py", line 186, in restricted > > > > > > > > > > exec ccode in environment > > > > > > > > > > File > > > > > > > > > > "/home/www-data/web2py/applications/welcome/models/db.py", > > > > > > > > > > line > > > > > > > > > > 15, in > > > > > > > > > > db = > > > > > > > > > > DAL('postgres://web2py:test...@localhost:1216/labdb') > > > > > > > > > > # > > > > > > > > > > if not, use SQLite or o
[web2py] Re: LOAD... and jquerytools
Please clarify what you mean by does not work. Did you try firebug? is the ajax call executed? Do you get a response? If so, it is a JS problem. On Aug 8, 7:19 am, JmiXIII wrote: > Hello ! > > Here is a view in which I am using LOAD helper > I have put {{=LOAD('default','index.load')}} N°# in several places in > the code below > I am also using jquerytools > :http://cdn.jquerytools.org/1.2.1/jquery.tools.min.js > from my controler > > The only {{=LOAD('default','index.load')}} working is N°#4 outside the > div affected by jquerytools > > Can someone explain me why the other doesn't work ? Does that mean I > can't use LOAD with jquerytools ? > > Thanks a lot > > {{extend 'layout.html'}} > {{=Selection}} > {{=CArt}}{{=ArtOF}} > > > Suivi Prod > Synthèse OF > Non conformités > Suivi de contrôle > > > > > > stuffs > > > stuffs > > > stuffs > > > > > Date/Heure > controle 1 > controle 2 > {{=LOAD('default','index.load')}} N°1 > > > ... > enreg 1 > enreg 2 > > > {{=LOAD('default','index.load')}} N°2 > > {{=LOAD('default','index.load')}} N°3 > > {{=LOAD('default','index.load')}} N°4 > > > $(function() { > // :first selector is optional if you have only one tabs on the page > $(".css-tabs:first").tabs(".css-panes:first > div");}); > >
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
aha! I think it is a problem with permissions of contect of databases folder. Make sure the apache/www-data user has permissions to read and write On Aug 8, 6:32 am, Zhe Li wrote: > Hi Massimo, > > Yes this time I was running it from a fresh installed ubuntu server so > PostgreSQL was using the default port. > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > it is a configuration problem with my PostgreSQL? > > 1. If I run: > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > I will got an error of "ProgrammingError: relation 'auth_group' > already exists". > > 2. visit the site runs on WSGI+apache gives me: > > RuntimeError: Failure to connect to DB. Tried 5 times > > 3. Launch site with the identical web2py code in my folder: > > python web2py.py -a 0 -i 0.0.0.0 > > it runs without any problems. > > Here is part of my pg_hba.conf: > > local all postgres ident > # TYPE DATABASE USER CIDR-ADDRESS METHOD > local all web2py ident > host all all 192.168.0.0/24 md5 > host all all 127.0.0.1/32 md5 > host all all ::1/128 md5 > > and my postgresql.conf is: > > listen_addresses = '*' # what IP address(es) to listen on; > port = 5432 # (change requires restart) > max_connections = 100 # (change requires restart) > > Thank you very much! > > Regards, > Zhe > > On Aug 8, 2:30 am, mdipierro wrote: > > > Didn't you say? > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > pool_size=10) > > > is the DB at port 1216 or 5432? > > Can you try with pool_size=0 just to isolate the problem. > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > Hi Massimo, > > > > I am using PostgreSQL 8.4. > > > > I added print(msg) and got the message when runnning python web2.py -a > > > 123, the string looks like > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > password='test123' > > > > I only have this error when using web2py with WSGI. But if I go to the > > > shell from the admin page running with WSGI, I could use PostgreSQL > > > without any problems. I tried this: > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > > > port=5432 password='test123'") > > > > and it works, I successfully added a table and a test record... > > > > Thank you! > > > > Cheers, > > > Zhe > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > One more test: > > > > > In gluon/sql.py > > > > > before line 957, print your connection string: > > > > print msg > > > > Would that connection string work on the shell? Which postgresql > > > > version are you using? > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > > I have no idea. Can you connect from a pure python shell using the > > > > > > driver API? > > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > > thanks! > > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 (it's > > > > > > > actually ip). but it doesn't work > > > > > > > > Cheers, > > > > > > > Zhe > > > > > > > > On Aug 6, 12:33 pm, mdipierro wrote: > > > > > > > > > Try replace > > > > > > > > > localhost > > > > > > > > with > > > > > > > > 127.0.0.1 > > > > > > > > and with the actual IP of the machine. It may not be serving on > > > > > > > > localhost > > > > > > > > > On Aug 6, 5:25 am, Zhe Li wrote: > > > > > > > > > > Hi, > > > > > > > > > > Thanks! This is the result from trunk. > > > > > > > > > > Error traceback > > > > > > > > > Traceback (most recent call last): > > > > > > > > > File "gluon/restricted.py", line 186, in restricted > > > > > > > > > exec ccode in environment > > > > > > > > > File > > > > > > > > > "/home/www-data/web2py/applications/welcome/models/db.py", > > > > > > > > > line > > > > > > > > > 15, in > > > > > > > > > db = > > > > > > > > > DAL('postgres://web2py:test...@localhost:1216/labdb') # > > > > > > > > > if not, use SQLite or other DB > > > > > > > > > File "gluon/sql.py", line 3911, in DAL > > > > > > > > > raise RuntimeError, "%s (tried 5 times)" % exception > > > > > > > > > RuntimeError: could not connect to server: Connection refused > > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > > could not connect to server: Connection refused > > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > > (tried 5 times) > > > > > > > > > Error snapshot > > > > > > > > > Detailed traceback description > > > > > > > > > Exception: (could not connect > > > > > > > > > to > > > > > > > > > server: Connection refused Is the s
[web2py] Re: one to many relationship but Foreign key as non-id,unique field.
No. But you can enforce the reference at the web2py level with the IS_IN_DB validator. On Aug 8, 2:36 am, Phyo Arkar wrote: > Yes i understand that 1 to Many do not link to Field but Record but i need > to Reference to a Field which is not id . > so with that i can set two primary keys but i want to reference to EmailID > (which is not auto increment Integer but a md5sum , string , Unique) . > > Is that possible? > > On Sun, Aug 8, 2010 at 1:36 PM, qqsaqq wrote: > > as I understand this, the DAL always uses the id field for referencing > > in a one to many relationship. And: you don't link to a certain field > > (EmailID) but to a record of your emails table. > > > see > >http://web2py.com/book/default/chapter/06#Legacy-Databases-and-Keyed-... > > > On Aug 8, 8:00 am, Phyo Arkar wrote: > > > I am Thinking to link two tables , > > > "emails" and "attachments" > > > > emails have a unique key , EmailID , which is a md5sum of the path to > > email > > > file > > > > I am trying to link with another table which is attachment table , it > > will > > > have a field 'attachment_of' which is link to "EmailID" > > > > To Short > > > > How can i link between primary and foreign keys which is a > > > non-id_but_unique field?
[web2py] Re: Web2py book software feature request
This wasn't so much specific to web2py, but rather to the book app itself...especially to make it attractive to use outside of web2py. On Aug 6, 12:37 am, mdipierro wrote: > This is how things are now: > - you can register and you can submit comments > - you can ask me to edit the book and I can make you editor > > Massimo > > On Aug 5, 11:27 pm, b00m_chef wrote: > > > > > I just wanted to request that the book be opened up to editing if you > > register. However, if you register, and make a change, only you can > > see the pages with you changes, until your changes are approved to be > > included in the public view of the page by the editors/moderators. > > This way, if a user is found to be a spammer, all his changes can be > > deleted in one click. Furthermore, it allows for better qualify in the > > book due to more participation from the community. > > > Just had to get that out of my mind...it's been bugging me.
Re: [web2py] testing routes.py patterns
On Aug 8, 2010, at 8:31 AM, Jonathan Lundell wrote: > I've been advocating the use of doctests in routes.py to debug problems. > Here's another doctest you can use (I'll send a patch to Massimo that adds an > example). > compile_re('.*http://otherdomain.com.* (?P.*)', '/app/ctr\g')[0].pattern >'^.*http://otherdomain.com.* (?P.*)$' compile_re('.*http://otherdomain.com.* (?P.*)', '/app/ctr\g')[1] >'/app/ctrg' compile_re('/$c/$f', '/init/$c/$f')[0].pattern >'^.*?:https?://[^:/]+:[a-z]+ /(?P[w_]+)/(?P[w_]+)$' compile_re('/$c/$f', '/init/$c/$f')[1] >'/init/g/g' > > For the trunk version, the import line needs to change to this: > >from gluon.rewrite import select, load, filter_url, filter_out, > filter_err, compile_re > > Notice that the backslash escaping gets a little confusing. I can't figure > out how to use raw strings properly here; so it goes. One more note. All the other doctests in routes.example.py use the patterns defined earlier in the file. The compile_re tests are entirely self-contained, so you can easily add them without any other editing. Just copy routes.example.py to, say, routes.test.py, and add some compile_re tests, and you're in business.
[web2py] testing routes.py patterns
I've been advocating the use of doctests in routes.py to debug problems. Here's another doctest you can use (I'll send a patch to Massimo that adds an example). >>> compile_re('.*http://otherdomain.com.* (?P.*)', '/app/ctr\g')[0].pattern '^.*http://otherdomain.com.* (?P.*)$' >>> compile_re('.*http://otherdomain.com.* (?P.*)', '/app/ctr\g')[1] '/app/ctrg' >>> compile_re('/$c/$f', '/init/$c/$f')[0].pattern '^.*?:https?://[^:/]+:[a-z]+ /(?P[w_]+)/(?P[w_]+)$' >>> compile_re('/$c/$f', '/init/$c/$f')[1] '/init/g/g' For the trunk version, the import line needs to change to this: from gluon.rewrite import select, load, filter_url, filter_out, filter_err, compile_re Notice that the backslash escaping gets a little confusing. I can't figure out how to use raw strings properly here; so it goes.
Re: [web2py] routes problem
On Aug 7, 2010, at 11:16 PM, elffikk wrote: > I use version 1.82.1 (latest) and this seems not to work > > ('(.*):https?://(.*)site\.com:(.*)/(.*)', '/site/$4'), > > > for simple site.com getting error > > site - is another name :) From the manual (chapter 4): [remote address]:[protocol]://[host]:[method] [path] Note the space before [path].
Re: [web2py] routes problem
On Aug 7, 2010, at 11:16 PM, elffikk wrote: > I use version 1.82.1 (latest) and this seems not to work > > ('(.*):https?://(.*)site\.com:(.*)/(.*)', '/site/$4'), > > > for simple site.com getting error > > site - is another name :) I think I see the problem, but I'm not sure what you're trying to do. In the above, what's $3? If you're using the full pattern, the domain (site.com) is followed by GET or POST-- site.com:GET Then a space, and then the path.
[web2py] Position of a row in a query?
Is there a way to determine at what position in a query a row resides? This would be helpful for me to have something similiar to list's index method that I could call on a query.
Re: [web2py] routes problem
On Aug 7, 2010, at 11:16 PM, elffikk wrote: > I use version 1.82.1 (latest) and this seems not to work > > ('(.*):https?://(.*)site\.com:(.*)/(.*)', '/site/$4'), > > > for simple site.com getting error > > site - is another name :) Is this 1.82.1 or the trunk?
Re: [web2py] Re: Is there a way how to specifiy, which controller act as default?
+1 On Sat, Aug 7, 2010 at 12:00 AM, mr.freeze wrote: > Not another config file, just another config option. Why have the > overhead and complexity of a routes regex when you could just set it > explicitly in an existing config file? Just seems more straightforward > and user friendly to me. > > On Aug 6, 12:26 pm, Albert Abril wrote: > > @mr.freeze You can do it with routes.py . Why another config file? > > > > On Fri, Aug 6, 2010 at 6:40 PM, Phyo Arkar > wrote: > > > i voted this too. > > > > > I just dont like the controller named default and i want it different > > > on each apps. > > > > > On 8/6/10, mr.freeze wrote: > > > > Massimo, why not make the default application,controller and function > > > > configurable in an external file like options.py or > > > > parameters_.py? > > > > > > On Aug 6, 9:08 am, mdipierro wrote: > > > >> No. But you can remap into a different controller using routes.py > > > > > >> routes_in = [ > > > >> ('/myapp', '/myapp/non_default/index'), > > > >> ] > > > > > >> On Aug 6, 9:05 am, David Marko wrote: > > > > > >> > Is there a way how to specifiy, which controller act as default? I > > > >> > mean specify different controller than with name 'default', which > name > > > >> > is a bit strange (at least for non-english speaking countries.) > > > > > >> > David >
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Whoops, I was using local all web2pymd5 in pg_hba.conf. /Zhe On Aug 8, 1:32 pm, Zhe Li wrote: > Hi Massimo, > > Yes this time I was running it from a fresh installed ubuntu server so > PostgreSQL was using the default port. > > I changed the pool_size to 0 and tried a couple of combinations. Maybe > it is a configuration problem with my PostgreSQL? > > 1. If I run: > > sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 > > I will got an error of "ProgrammingError: relation 'auth_group' > already exists". > > 2. visit the site runs on WSGI+apache gives me: > > RuntimeError: Failure to connect to DB. Tried 5 times > > 3. Launch site with the identical web2py code in my folder: > > python web2py.py -a 0 -i 0.0.0.0 > > it runs without any problems. > > Here is part of my pg_hba.conf: > > local all postgres ident > # TYPE DATABASE USER CIDR-ADDRESS METHOD > local all web2py ident > host all all 192.168.0.0/24 md5 > host all all 127.0.0.1/32 md5 > host all all ::1/128 md5 > > and my postgresql.conf is: > > listen_addresses = '*' # what IP address(es) to listen on; > port = 5432 # (change requires restart) > max_connections = 100 # (change requires restart) > > Thank you very much! > > Regards, > Zhe > > On Aug 8, 2:30 am, mdipierro wrote: > > > > > Didn't you say? > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > pool_size=10) > > > is the DB at port 1216 or 5432? > > Can you try with pool_size=0 just to isolate the problem. > > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > Hi Massimo, > > > > I am using PostgreSQL 8.4. > > > > I added print(msg) and got the message when runnning python web2.py -a > > > 123, the string looks like > > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > > password='test123' > > > > I only have this error when using web2py with WSGI. But if I go to the > > > shell from the admin page running with WSGI, I could use PostgreSQL > > > without any problems. I tried this: > > > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > > > port=5432 password='test123'") > > > > and it works, I successfully added a table and a test record... > > > > Thank you! > > > > Cheers, > > > Zhe > > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > > One more test: > > > > > In gluon/sql.py > > > > > before line 957, print your connection string: > > > > print msg > > > > Would that connection string work on the shell? Which postgresql > > > > version are you using? > > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > > I have no idea. Can you connect from a pure python shell using the > > > > > > driver API? > > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > > thanks! > > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 (it's > > > > > > > actually ip). but it doesn't work > > > > > > > > Cheers, > > > > > > > Zhe > > > > > > > > On Aug 6, 12:33 pm, mdipierro wrote: > > > > > > > > > Try replace > > > > > > > > > localhost > > > > > > > > with > > > > > > > > 127.0.0.1 > > > > > > > > and with the actual IP of the machine. It may not be serving on > > > > > > > > localhost > > > > > > > > > On Aug 6, 5:25 am, Zhe Li wrote: > > > > > > > > > > Hi, > > > > > > > > > > Thanks! This is the result from trunk. > > > > > > > > > > Error traceback > > > > > > > > > Traceback (most recent call last): > > > > > > > > > File "gluon/restricted.py", line 186, in restricted > > > > > > > > > exec ccode in environment > > > > > > > > > File > > > > > > > > > "/home/www-data/web2py/applications/welcome/models/db.py", > > > > > > > > > line > > > > > > > > > 15, in > > > > > > > > > db = > > > > > > > > > DAL('postgres://web2py:test...@localhost:1216/labdb') # > > > > > > > > > if not, use SQLite or other DB > > > > > > > > > File "gluon/sql.py", line 3911, in DAL > > > > > > > > > raise RuntimeError, "%s (tried 5 times)" % exception > > > > > > > > > RuntimeError: could not connect to server: Connection refused > > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > > could not connect to server: Connection refused > > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > > (tried 5 times) > > > > > > > > > Error snapshot > > > > > > > > > Detailed traceback description > > > > > > > > > Exception: (could not connect > > > > > > > > > to > > > > > > > > > server: Connection refused Is the server running on host > > > > > > > > >
[web2py] Re: Failed to connect to PostgreSQL, deployed with setup_web2py_ubuntu.sh.
Hi Massimo, Yes this time I was running it from a fresh installed ubuntu server so PostgreSQL was using the default port. I changed the pool_size to 0 and tried a couple of combinations. Maybe it is a configuration problem with my PostgreSQL? 1. If I run: sudo -u www-data python www-data/web2py -a 0 -i 0.0.0.0 I will got an error of "ProgrammingError: relation 'auth_group' already exists". 2. visit the site runs on WSGI+apache gives me: RuntimeError: Failure to connect to DB. Tried 5 times 3. Launch site with the identical web2py code in my folder: python web2py.py -a 0 -i 0.0.0.0 it runs without any problems. Here is part of my pg_hba.conf: local all postgres ident # TYPE DATABASEUSERCIDR-ADDRESS METHOD local all web2pyident hostall all 192.168.0.0/24md5 hostall all 127.0.0.1/32 md5 hostall all ::1/128 md5 and my postgresql.conf is: listen_addresses = '*' # what IP address(es) to listen on; port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) Thank you very much! Regards, Zhe On Aug 8, 2:30 am, mdipierro wrote: > Didn't you say? > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > pool_size=10) > > is the DB at port 1216 or 5432? > Can you try with pool_size=0 just to isolate the problem. > > On Aug 7, 6:42 pm, Zhe Li wrote: > > > > > Hi Massimo, > > > I am using PostgreSQL 8.4. > > > I added print(msg) and got the message when runnning python web2.py -a > > 123, the string looks like > > > dbname='labdb' user='web2py' host='localhost' port=5432 > > password='test123' > > > I only have this error when using web2py with WSGI. But if I go to the > > shell from the admin page running with WSGI, I could use PostgreSQL > > without any problems. I tried this: > > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > > port=5432 password='test123'") > > > and it works, I successfully added a table and a test record... > > > Thank you! > > > Cheers, > > Zhe > > > On Aug 7, 5:30 pm, mdipierro wrote: > > > > One more test: > > > > In gluon/sql.py > > > > before line 957, print your connection string: > > > print msg > > > Would that connection string work on the shell? Which postgresql > > > version are you using? > > > > On Aug 6, 6:48 am, Zhe Li wrote: > > > > > Yeah, that works fine. It's so odd and frustrating... > > > > > On Aug 6, 1:25 pm, mdipierro wrote: > > > > > > I have no idea. Can you connect from a pure python shell using the > > > > > driver API? > > > > > > On Aug 6, 5:55 am, Zhe Li wrote: > > > > > > > thanks! > > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 (it's > > > > > > actually ip). but it doesn't work > > > > > > > Cheers, > > > > > > Zhe > > > > > > > On Aug 6, 12:33 pm, mdipierro wrote: > > > > > > > > Try replace > > > > > > > > localhost > > > > > > > with > > > > > > > 127.0.0.1 > > > > > > > and with the actual IP of the machine. It may not be serving on > > > > > > > localhost > > > > > > > > On Aug 6, 5:25 am, Zhe Li wrote: > > > > > > > > > Hi, > > > > > > > > > Thanks! This is the result from trunk. > > > > > > > > > Error traceback > > > > > > > > Traceback (most recent call last): > > > > > > > > File "gluon/restricted.py", line 186, in restricted > > > > > > > > exec ccode in environment > > > > > > > > File > > > > > > > > "/home/www-data/web2py/applications/welcome/models/db.py", line > > > > > > > > 15, in > > > > > > > > db = DAL('postgres://web2py:test...@localhost:1216/labdb') > > > > > > > > # > > > > > > > > if not, use SQLite or other DB > > > > > > > > File "gluon/sql.py", line 3911, in DAL > > > > > > > > raise RuntimeError, "%s (tried 5 times)" % exception > > > > > > > > RuntimeError: could not connect to server: Connection refused > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > could not connect to server: Connection refused > > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > > TCP/IP connections on port 1216? > > > > > > > > (tried 5 times) > > > > > > > > Error snapshot > > > > > > > > Detailed traceback description > > > > > > > > Exception: (could not connect to > > > > > > > > server: Connection refused Is the server running on host > > > > > > > > "localhost" > > > > > > > > and accepting TCP/IP connections on port 1216? could not > > > > > > > > connect to > > > > > > > > server: Connection refused Is the server running on host > > > > > > > > "localhost" > > > > > > > > and accepting TCP/IP connections on port 1216? (tried 5 times)) > > > > > > > > Python 2.6.5: /usr/bin/python > > > > > > > > > This is odd since I can connect to it
[web2py] Help with Paypal Mass Payment, API
Someone has experience with Paypal Mass Payment API? I want a working implementation to web2py and want pay to develop it. -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
[web2py] Re: generate CSV file with multiple sheets
Hello Kenneth, sorry i have just seen your message now. you can follow the following link it is a great one, i followed it: http://scienceoss.com/write-excel-files-with-python-using-xlwt/ Thanks Neveen
[web2py] Re: generate CSV file with multiple sheets
Hello, am using xlwt module to create xls file with multiple sheets and i want to display Content disposition with the created file. wbk = xlwt.Workbook(encoding='utf-8') sheet = workbook.add_sheet('sheet1') and then response.headers['Content-Type'] = \ gluon.contenttype.contenttype('.xls') response.headers['Content-disposition'] = 'attachment; filename=projects.xls' how can i make the content of wbk inside projects.xls? Thanks in Advance Neveen Adel
[web2py] Re: generate CSV file with multiple sheets
Hello, am using xlwt module to create xls file with multiple sheets and i want to display Content disposition with the created file. wbk = xlwt.Workbook(encoding='utf-8') sheet = workbook.add_sheet('sheet1') and then response.headers['Content-Type'] = \ gluon.contenttype.contenttype('.xls') response.headers['Content-disposition'] = 'attachment; filename=projects.xls' how can i make the content of wbk inside projects.xls? Thanks in Advance Neveen Adel
Re: [web2py] Re: one to many relationship but Foreign key as non-id,unique field.
Yes i understand that 1 to Many do not link to Field but Record but i need to Reference to a Field which is not id . so with that i can set two primary keys but i want to reference to EmailID (which is not auto increment Integer but a md5sum , string , Unique) . Is that possible? On Sun, Aug 8, 2010 at 1:36 PM, qqsaqq wrote: > as I understand this, the DAL always uses the id field for referencing > in a one to many relationship. And: you don't link to a certain field > (EmailID) but to a record of your emails table. > > see > http://web2py.com/book/default/chapter/06#Legacy-Databases-and-Keyed-Tables > > On Aug 8, 8:00 am, Phyo Arkar wrote: > > I am Thinking to link two tables , > > "emails" and "attachments" > > > > emails have a unique key , EmailID , which is a md5sum of the path to > email > > file > > > > I am trying to link with another table which is attachment table , it > will > > have a field 'attachment_of' which is link to "EmailID" > > > > To Short > > > > How can i link between primary and foreign keys which is a > > non-id_but_unique field? >
[web2py] Re: one to many relationship but Foreign key as non-id,unique field.
as I understand this, the DAL always uses the id field for referencing in a one to many relationship. And: you don't link to a certain field (EmailID) but to a record of your emails table. see http://web2py.com/book/default/chapter/06#Legacy-Databases-and-Keyed-Tables On Aug 8, 8:00 am, Phyo Arkar wrote: > I am Thinking to link two tables , > "emails" and "attachments" > > emails have a unique key , EmailID , which is a md5sum of the path to email > file > > I am trying to link with another table which is attachment table , it will > have a field 'attachment_of' which is link to "EmailID" > > To Short > > How can i link between primary and foreign keys which is a > non-id_but_unique field?