(1/2 OT) Bug in production? [nginx + uwsgi]

69 views
Skip to first unread message

Jose

unread,
May 9, 2013, 6:52:47 PM5/9/13
to web...@googlegroups.com
Hello,

The normal behavior is: The user presses the Test button, then <div id="sql"></div> show "ABCD". (The code is shown below)

In development mode running rocket, works well, but in production ajax call is not executed.


Environment:

Web2py 2.4.6 (Version 2.4.6-stable+timestamp.2013.05.08.16.52.12)
FreeBSD 9.1
Nginx-1.4.0
Uwsgi-1.4.9

uwsgi.conf:

<uwsgi>
  <socket>127.0.0.1:9001</socket>
  <pythonpath>/home/web2py/</pythonpath>
  <module>wsgihandler</module>
  <processes>4</processes>
  <buffer-size>8192</buffer-size>
</uwsgi>

nginx.conf
...
location ~ /myapp{
            uwsgi_pass  127.0.0.1:9001;
            include     uwsgi_params;
}

...


default.py:

def index():  
   
return dict()


def bg_test():
    id
= request.vars.id
   
return id




default/index.html:



{{extend 'layout.html'}}

<script type="text/javascript">


function test(){
    $
('#id').val('ABCD');    
    ajax
('bg_test', ['id'], 'sql');
}
</script>
<form>
    <input type="hidden" name="id" id="id" value="" /
>
</form>


<button type="button" onclick="test()">Test</
button>


<div id="sql"></div>


I think the problem is not web2py, I tested with version 1.99.4 and also works bad.

Something that can be changed or added in nginx.conf or uwsgi.conf?
Any idea?

Best Regards
Jose

Jose

unread,
May 9, 2013, 7:28:09 PM5/9/13
to web...@googlegroups.com
I think the problem is the url of the call

ajax('bg_test', ['id'], 'sql');

must be well:

url = "{{=URL('default', 'bg_test')}}"
ajax
(url, ['id'], 'sql');

José

Michele Comitini

unread,
May 13, 2013, 5:13:38 AM5/13/13
to web...@googlegroups.com
Hi José,

Please open an issue about this on https://code.google.com/p/web2py/
tnx
mic



2013/5/10 Jose <jja...@gmail.com>

--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jose

unread,
May 13, 2013, 8:16:48 AM5/13/13
to web...@googlegroups.com


El lunes, 13 de mayo de 2013 06:13:38 UTC-3, Michele Comitini escribió:
Hi José,

Please open an issue about this on https://code.google.com/p/web2py/
tnx
mic


Hi Michele

This is a problem of web2py or documentation [1] or deployment? 

ajax(url, [name1, name2, ...], target)

Url is mentioned as an argument, but no examples.

{{extend 'layout.html'}}
<form>
   <input name="name" onkeyup="ajax('echo', ['name'], 'target')" />
</form>
<div id="target"></div>

Before I had it running on Cherokee and worked fine when I switched to nginx, and that failed.

José

Michele Comitini

unread,
May 13, 2013, 8:36:45 AM5/13/13
to web...@googlegroups.com
the url argument of the ajax function is a uri.  If one uses partial form, then following rules apply:


The complete URI is generated by the browser own logic before doing any call to web2py.

mic



2013/5/13 Jose <jja...@gmail.com>

--

Niphlod

unread,
May 13, 2013, 8:42:34 AM5/13/13
to web...@googlegroups.com
url needs to be a valid url. 
Documentation is ok, but if you "hardcode" fixed values you need to be sure that the routes are always exactly as in your development server.

If you're not messing with default applications and/or redirection, the same code that ran on lighttpd needs to run on nginx.....

To be sure your app will work no matter what redirection you use, use always urls generated with URL() ....

ajax('{{=URL('echo')}}', etc etc etc)

Jose

unread,
May 13, 2013, 8:57:42 AM5/13/13
to web...@googlegroups.com


El lunes, 13 de mayo de 2013 09:42:34 UTC-3, Niphlod escribió:
url needs to be a valid url. 
Documentation is ok, but if you "hardcode" fixed values you need to be sure that the routes are always exactly as in your development server.

If you're not messing with default applications and/or redirection, the same code that ran on lighttpd needs to run on nginx.....

To be sure your app will work no matter what redirection you use, use always urls generated with URL() ....

ajax('{{=URL('echo')}}', etc etc etc)


This is how I did it

José 

Jose

unread,
May 14, 2013, 8:10:00 AM5/14/13
to web...@googlegroups.com
I got an email about this issue.

Putting the url with URL, it works fine

José
 
Reply all
Reply to author
Forward
0 new messages