[web2py] mongrel2 + uwsgi + web2py
I had some difficulty getting the mongrel2 + uwsgi + web2py to work because uwsgi was not setting all of the environment variables that web2py was expecting. With uWSGI 1.1 some improvements will be made, but e.g. web2py logging is depending on REMOTE_ADDRESS and this is not set by uWSGI and web2py fails silently. The attached diff should make things work with older versions of uWSGI as well ( I tested 1.0.2.1, 1.0.4 and 1.1-dev-1996) diff -r 7f492ab789a9 gluon/main.py --- a/gluon/main.py Thu Feb 16 10:31:35 2012 +0100 +++ b/gluon/main.py Thu Feb 16 10:36:42 2012 +0100 @@ -355,6 +355,7 @@ try: try: # ## +# handle uWSGI incorrect/missing environ vars # handle fcgi missing path_info and query_string # select rewrite parameters # rewrite incoming URL @@ -362,6 +363,21 @@ # parse rewritten URL # serve file if static # ## + uwsgi = environ.get('uwsgi.version') + if uwsgi: + uwsgi_version = [] + for x in uwsgi.split('.'): + for y in x.split('-'): + if y == 'dev': +y = -1 + uwsgi_version.append(int(y)) + if uwsgi and uwsgi_version [1, 1, -1, 1996]: + # handles uWSGI broken path_info AND missing QUERY_STRING + environ['PATH_INFO'] = '' + if uwsgi and not environ.get('REMOTE_ADDR'): +# REMOTE_ADDR is used for logging, which silently fails + environ['REMOTE_ADDR'] = environ.get('HTTP_X_FORWARDED_FOR', + 'address.unknown') if not environ.get('PATH_INFO',None) and \ environ.get('REQUEST_URI',None):
[web2py] sub url
Hi Massimo, I did once more try to setup web2py using mod_wsgi in something different than /, in my case /ruamel To be sure I temporarily deactivated the WSGIScriptAlias for / Although the welcome page on http://localhost/ruamel tells me it works it doesn't look like that since the page has no CSS. Looking in the apache log I saw that web2py still is trying to get the stylesheets and other stuff from / and not /ruamel so I googled and searched through the newsgroup once more only to your exchange with Graham Dumpleton on sub url usage and that I had to setup a path in router.py. I appreciate your concern with backwards compatibility but this is something that has come up under various names in the past. The router change works for the welcome app, but errors are not covered by that. for that you need to adapt the error_message_ticket in routes.py as well. It should not take knowledge of the term sub url to find out about this, for me that meant several hours searching and trying. I would assume that if the welcome app cannot find its stylesheets it should give a useful message. This could easily be achieved in a backwards compatible way by the following change: diff -r 1e70764ec03a applications/welcome/views/default/index.html --- a/applications/welcome/views/default/index.html Fri Mar 18 09:18:59 2011 +0100 +++ b/applications/welcome/views/default/index.html Fri Mar 18 14:38:17 2011 +0100 @@ -9,6 +9,25 @@ h2Readme/h2 ul li{{=T('You are successfully running web2py')}}/li +p class=hidden +font style='color: red' + +Style sheets were not found. + +{{if request.env.get('script_name'):}} +br +You probably want to add something like:br +pre + routes_out=(('(?Plt;anything.*)','/{{=request.env.script_name}} \glt;anything'),) + error_message_ticket = 'htmlbodyh1Internal error/h1Ticket issued: a href=/{{=request.env.script_name}}/admin/default/ticket/% (ticket)s target=_blank%(ticket)s/a/body/html' +/pre +to the file in {{=request.env.web2py_path}}/routes.py and check +a href=http://groups.google.com/group/web2py;http:// groups.google.com/group/web2py/a for 'sub url' +{{pass}} + +/font +/p + li{{=T('This is a copy of the scaffolding application')}}/li li{{=T('You can modify this application and adapt it to your needs')}}/li I am not sure there are more issues. Is this the proper direction to proceed? Regards Anthon PS I like backwards compatibility. I went from an application on some December 2009 version to version 1.89 in November without any major problems.
[web2py] web2py ajax based forms
I have for some time been working with the ajax based forms so I don't have a full redrawn on submitting a form. I also tend to have multiple buttons on my forms, as well as multiple TABs that might have submit buttons with the same value. (In a FORM submitted in the normal way, one would add a name=submit to the submit button to have the value of the button posted) The default form.serialize() does not include the submit buttons value, nor the name of the submit button, so I changed this a bit to get the both the name as well as the value of the submit button: function web2py_trap_form(action,target) { jQuery('#'+target+' form').each(function(i){ var form=jQuery(this); jQuery(':submit,.submit',this).click(function(){ var button = jQuery(this); if (button.hasClass(deletebutton)) { var objstr = button.attr(alt); var delstr1 = Are you ; var delstr2 = sure you want to delete + objstr; var delextra = really ; if(!confirm(delstr1 + delstr2)) return false; if(!confirm(delstr1 + delextra + delstr2)) return false; }; jQuery('.flash').hide().html(''); var name = button.attr('name'); if (name === '') name = 'submit'; if (name !== '') name = '' + name + '=' + button.attr('value').replace(' ', '%20'); /* append submit information */ var serial = form.serialize() + name; form.html('loading ...'); web2py_ajax_page('post',action,serial,target); return false; }); }); } The ' if (button.hasClass(deletebutton)) ' works on submit buttons that have the class deletebutton assigned to them. It prompts Are you sure you want to delete XXX, with XXX taken from that alt= value of the deletebutton. Then it prompts once more with 'Are you really...' As the retrieval from the server might take a few moments the form value is first replaced by the word 'loading...' I always add the submit button even if it has no name= defined. If that is not what you want remove the if (name === '') name = 'submit'; line. It took a while to get this figured out and working correctly so maybe this is of help to someone.
[web2py] pyrtf musings
The latest version of pyrtf on sourceforge (as indicated in the apendix of the web2py book: http://pyrtf.sourceforge.net) is 0.45, however the one included in gluon/contrib is indicated as 0.46 (according to the README). Did this come from some other place, or is that version update because of the differences made for web2py? I fixed a problem with RTF files switching to landscape mode and also implemented rendering of Unicode strings ( by splitting the non-ascii characters out into RawCode elements ). Of course only after doing so I found out that similar solutions have been implemented in pyrtfng which is hosted on Launchpad ( https://launchpad.net/pyrtf ) That project also replaced the image reading code (for PNG and JPG ) with Python Image Library. What I would like to know is what the changes by Grant Edwards were so I can check that these are in pyrtfng as well. -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: Ladies and Gentelmen... the web2py book is online
Very nice. I already got the PDF, but with the online version you can actually cut and paste the code sections without getting the line-numbers in between. For me that means: rm ~/bin/strip_web2py_linenumbers ;-) On Feb 12, 2:30 am, mdipierro mdipie...@cs.depaul.edu wrote: http://web2py.com/book This is only for testing purposes. Please try get an account and send me some feedback. You can try post and edit comments/wiki pages. I will reset the database in the next couple of days so do not be surprised if you loose your account and changes. I will also try port over AlterEgo data and merge with appliances. Massimo -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] non minified version of calendar.js
I am looking for a non minified version of calendar.js. The old version from Dynarch.com doesn't seem to have all of the time related extensions and I could not get it to work. I am get a stack overflow in IE7, when using calendars in a pane loaded using web2py_ajax_page() from menu entries. and with all code on one line -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: downloading to IE over https
I tried adding: response.headers['Cache-Control']=private return response.stream(pdfContents,chunk_size=4096) based on this thread: http://groups.google.com/group/web2py/browse_thread/thread/8da2043ec17debd6/4ae69758b19ba426 That solves the issue as well, without the need for patching main.py. I am still in the dark about why web2py seems to be streaming an HTML reply first... -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] downloading to IE over https
I have some problems downloadin a PDF file over https. The setup is mod_wsgi + apache (python 2.6). Downloading via https to Firefox works without a problem as does downloading over HTTP (both IE7 and Firefox). I tried to download a .csv file from the appadmin database administration pages and that doesn't work either so it doesn't seem to involve my particular use of response.headers and response.stream. (FWIW I tried both direct streaming as well as first writing a file). I could not manage to setup running web2py from the commandline using SSL to check if this is a mod_wsgi problem: on my local machine I get a connection but have no valid certificates and on my server I have valid certificates but cannot get ssl to run yet ( WARNING:root:OpenSSL libraries unavailable. SSL is OFF ) I tried to see if the web2py demo pages have the .csv downloading enabled since those work over https as well (https://web2py.com/ demo_app/appadmin/select/db/event) but downloading has been disabled there (because it is demo I can understand that uploading is disabled...). I am next going to try and see if this is a IE7 issue (by installing IE8) but I am not sure if I can convince my clients to switch if that solves the issue (as I might as well ask them to use Firefox in that case). Any help or insights would be appreciated. Anthon -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py:31515] Re: Versioning using Mercurial
I updated the patch: - the commit field is now above the revision information/committed file list - if you commit and there are no changes, you get a flash message --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:31453] Versioning using Mercurial
Is anyone using the versioning feature? It seems currently broken out of the box on my mod_wsgi/apache system. The main problem exists because mercurial writes to sys.stdout if some warning/error occurs. On my fresh system I get those writes because of two issues: - non existence of a username in ~/.hgrc for the user running apache - readding already added files The one thing you can do is to capture sys.stdout in mercurial.py: commit, but that hides all messages/error writing from mercurial. The two issues can be resolved differently: - by checking for the .hgrc and setting HGUSER if it is not available - by using a .hgignore file and not adding an explicit list in mercurial.py but using hg addremove option (that is also much nicer when doing mercurial commands in the application directory from the commandline as it hides all the non-tracked data) I can provide a patch if there is interest in this way of solving this issue Anthon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:31508] Re: Versioning using Mercurial
I use mod_wsgi 2.5, mercurial 1.3.1 and Python 2.6.2 on Ubuntu 8.04 After some experimenting with the Mercurial API I was able to get things to write without any output to sys.stdout (without redirecting). First of all I check if the username is provided before creating the repository, providing a dummy one if not. The web2py code readded the list of files it thought interesting before every commit. That caused a warning about files already being in the repository. Instead I know create a .hgignore file if it does not already exists (excluding some file types and errors, cache and databases directories). After that I addremove all files and commit. The list of files committed is now taken from the last changeset, and the commit.html was updated to take info from that one as well. The change to the .hgignore file and using addremove has the advantage that going to the repository from the commandline gives you far less junk. So no need to redirect sys.stdout, but thanks for the feedback on that anyway (I did read the docs, but it was more than 2 years ago). The patch is available here: http://www.ruamel.eu/download/19820330/web2py/mercurial01.patch Anthon On Sep 22, 2:05 pm, Graham Dumpleton graham.dumple...@gmail.com wrote: On Sep 22, 7:12 pm, Anthon anthon.van.der.n...@googlemail.com wrote: Is anyone using the versioning feature? It seems currently broken out of the box on my mod_wsgi/apache system. The main problem exists because mercurial writes to sys.stdout if some warning/error occurs. On my fresh system I get those writes because of two issues: - non existence of a username in ~/.hgrc for the user running apache - readding already added files The one thing you can do is to capture sys.stdout in mercurial.py: commit, but that hides all messages/error writing from mercurial. The two issues can be resolved differently: - by checking for the .hgrc and setting HGUSER if it is not available - by using a .hgignore file and not adding an explicit list in mercurial.py but using hg addremove option (that is also much nicer when doing mercurial commands in the application directory from the commandline as it hides all the non-tracked data) I can provide a patch if there is interest in this way of solving this issue Read the documentation: http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Writing_To_St... and my blog posts about it: http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output... Make sure you also aren't using an old mod_wsgi version. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:31097] Error in 2nd edition manual? Formatting improvement request.
I hope this is the right (or at least an acceptable) place to post a note on the manual (2nd edition PDF). On page 70 the top example line 4 works on db.image, I think you want it to work on db.comment instead. I also have a layout improvement request for the manual code layout (I am not sure what tools are used to write it though and if this kind of control is possible). In trying to cut and paste code text from the PDF file, you end up with the line numbers included in the text to copy. If line numbers and the actual code were different single elements then that would not be the case. Anthon BTW releasing the 2nd edition was a good move, I was considering buying the manual and that decided the issue for me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:20613] Re: URL structure for multilanguage site
Oops, and the second line has a problem as well: if session.force_language: T.force(force_language) if session.force_language: T.force(session.force_language) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py Web Framework group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:20614] Re: URL structure for multilanguage site
On Apr 18, 5:41 pm, mdipierro mdipie...@cs.depaul.edu wrote: Personally I do not user routes much and I like to do I thinks the following line: if request.vars.force_language: session.force_language Should be: if request.vars.force_language: session.language = request.vars.force_language if session.force_language: T.force(force_language) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups web2py Web Framework group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---