[web2py] Re: Web2Py without Bootstrap

2014-03-18 Thread Pedro Pisandelli
Thanks Massimo!
I was searching, trying and finaly get the point. My problem was that I was 
working exactly in SQLFORM and navbar, that´s why I was seeing things so 
tied to Bootstrap.
I made my own navbar, instead of using response.menu.. for now is pretty 
fine. Later will discover how to build a helper to create a menu using div 
 a or ul  li.

Now I´m struggling to customize the smartgrid. =)

Thanks again for your help!

Em sábado, 15 de março de 2014 22h05min21s UTC-3, Massimo Di Pierro 
escreveu:

 The only parts of web2py that generate bootstrap specific class are the 
 auth.navbar() and the FORMs(SQLFORM, SQLFORM.grid). 

 The navbar can be customized to not use bootstrap classes but the HTML of 
 navbar is also very specific of bootstrap. If you do not want bootstrap, 
 you should make your own navbar bit expliticely building links to 
 login/logout/register/etc.

 FORM does not acually use format by default. You can style with 
 SQLFORM(formstyle=...) Some of the options are:

 SQLFORM.formstyles = Storage(dict(
 table3cols=formstyle_table3cols,
 table2cols=formstyle_table2cols,
 divs=formstyle_divs,
 ul=formstyle_ul,
 bootstrap=formstyle_bootstrap,
 bootstrap3=formstyle_bootstrap3,
 inline=formstyle_inline,
 ))

 You can also make your own formstyles. Look into sqlhtml.py

 The GRID can also be passed a formstyle and will use it for FORMs. Other 
 css classes can be customized using other arguments. Try help(SQLFORM.grid)




 On Friday, 14 March 2014 13:17:42 UTC-5, Pedro Pisandelli wrote:

 Hey guys!
 I love Python, and I´m getting fascinated about web2py. Nevertheless, I 
 really don´t like the way it works (so tied) with Bootstrap.
 It´s fine get some help from Bootstrap and Build some prototype screens. 
 But I like to use other (sometimes better) frameworks, like 
 semantic-ui.com
 At this moment I´d like to generate a simple menu like this

 div class=some_class
 a href=# class=active itemLink1/a
 a href=# class=itemLink2/a
 a href=# class=itemLink3/a
 /div

 But as far as I know, web2py keeps stubbornly the Bootstrap´s tags and 
 structure.
 Is there a way to get rid of Twitter Bootstrap and generate a clean HTML 
 code? Is so annoying this tied structure. I guess is better give the 
 front-end devs (where I came from) decide what to put around the 
 information.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Python Performance Issue

2014-03-18 Thread Massimo Di Pierro
People have found lots of variability in performance with apache+mod_wsgi. 
Performance is very sensitive to memeory/etc.

This is because Apache is not async (like nginx) and it either uses threads 
or processes. Both have issues with Python. Threads slow you down because 
of the GIL. Parallel processes may consume lots of memory which may also 
cause performance issues. Things get worse and worse if processes hand 
(think of clients sending requests but not loading because of slow 
connections).

Apache is fine for static files. gunicorn and nginx are known to have much 
better performance with Pyhton web apps.

Massimo


On Monday, 17 March 2014 21:19:11 UTC-5, horridohobbyist wrote:

 I'm disturbed by the fact that the defaults are sensible. That suggests 
 there is no way to improve the performance. A 2x-10x performance hit is 
 very serious.

 I was considering dropping Apache and going with nginx/gunicorn in my 
 Linux server, but I'm not sure that's a good idea. Apache is a nearly 
 universal web server and one cannot simply ignore it.

 Also, I'm not sure I can duplicate the functionality in my current Apache 
 setup in nginx/gunicorn.


 On Monday, 17 March 2014 21:15:12 UTC-4, Tim Richardson wrote:


 (I am the furthest thing from being an Apache expert as you can find.)


 Well, whereever that puts you, I'll be in shouting distance. 

 I guess this means you are using defaults. The defaults are sensible for 
 small loads, so I don't think you would get better performance from 
 tweaking. These default settings should set you up with 15 threads running 
 under one process which for a small load should be optimal that is, it's as 
 good as it's going to get. You get these sensible defaults if you used the 
 deployment script mentioned in the web2py book (the settings are in the 
 /etc/apache2/sites-available/default file)
  
 threads are faster than processes, but gunicorn and nginx don't even use 
 threads. They manage their workloads inside a single thread which makes 
 them fast as long as nothing CPU intensive is happening. 













 \


 Thanks.


 On Monday, 17 March 2014 20:20:00 UTC-4, Tim Richardson wrote:



 There is no question that the fault lies with Apache.


 Perhaps it is fairer to say the fault lies with mod_wsgi ?

 What are the mod_wsgi settings in your apache config? 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Bootstrap3 package - help to test

2014-03-18 Thread Dmitry Rodetsky
Actually there is still a problem. Although the index out of range fault 
went away and
reCaptcha displays now - it does not test and simply continues with 
submission.

I've been trying to find where the problem is for a few hours so far, but 
no luck for now.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] pysimplesoap help

2014-03-18 Thread Mariano Reingart
Hi piero:

The first choice to connect to a webservice that requires username 
password (add_credentials), you will httplib2 installed:

https://code.google.com/p/httplib2

Then you could do:

client = SoapClient(location = location_wsdl,sessions=True,username='admin',
password='xx')

Also, assuming your webservice supports basic auth, you could pass the
Authentication http header directly (it shouldn't need to install external
library):

import base64
auth = base64.b64encode('%s:%s' % (username, password)).replace('\n', '')

client = SoapClient(location = location_wsdl, sessions=True, http_headers={'
Authorization': Basic %s % auth})

Let me know if this solves your issue,

Best regards


Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Mon, Mar 17, 2014 at 6:02 PM, piero crisci piero.cri...@gmail.comwrote:

 Hello i am trying to connect to this wsdl:
 http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl
 It requires http basic authentication  and i am using pysimplesoap 1.10
 and i tried this configuration:

 from pysimplesoap.client import SoapClient
 location_wsdl = http://docway.demo.3di.it/3diws/services;
 wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl;
 client = SoapClient(location =
 location_wsdl,sessions=True,http_headers={'username': 'admin', 'password':
 ''},username='admin',password='xx')

 I got this error
 Traceback (most recent call last):
   File stdin, line 1, in module
   File build\bdist.win32\egg\pysimplesoap\client.py, line 133, in
 __init__
   File build\bdist.win32\egg\pysimplesoap\client.py, line 469, in
 wsdl_parse
   File build\bdist.win32\egg\pysimplesoap\helpers.py, line 71, in fetch
   File build\bdist.win32\egg\pysimplesoap\transport.py, line 121, in
 request
   File C:\python27\lib\urllib2.py, line 406, in open
 response = meth(req, response)
   File C:\python27\lib\urllib2.py, line 519, in http_response
 'http', request, response, code, msg, hdrs)
   File C:\python27\lib\urllib2.py, line 444, in error
 return self._call_chain(*args)
   File C:\python27\lib\urllib2.py, line 378, in _call_chain
 result = func(*args)
   File C:\python27\lib\urllib2.py, line 527, in http_error_default
 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
 urllib2.HTTPError: HTTP Error 401: Unauthorized

 It seems like the basic authenitcation is not supported. am I wrong?
 How i need to change the wsdl call? And how i can use a session to send
 different call?
 Thx for help!

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] .json in url does not like contruções

2014-03-18 Thread António Ramos
hello, i have a controller function

if i call it just by http://app.xx.pt/default/myfunc

if shows the resulting array from myfunc

but if i call it like
http://app.xx.pt/default/myfunc.json
i get the error

utf8' codec can't decode byte 0xc3

I think its because the text  contruções in the resulting  array


How can i tweek it to not give the error?


thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] .json in url does not like contruções

2014-03-18 Thread Manuele Pesenti
Il 18/03/14 11:07, António Ramos ha scritto:
 hello, i have a controller function

 if i call it just by http://app.xx.pt/default/myfunc

 if shows the resulting array from myfunc

 but if i call it like 
 http://app.xx.pt/default/myfunc.json
 i get the error
 utf8' codec can't decode byte 0xc3 
 I think its because the text  contruções in the resulting  array



 How can i tweek it to not give the error?
Hi António,
consider that json string it's a unicode string.
Can this help you?

M.

 thank you
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com
 mailto:web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Anthony


  - How can I verify when the html was actually retrieved from the cache? I 
 tried coding a print request.now in the view, but that sentence is 
 executed everytime I hit the site's homepage, so I deduce that the code 
 that generates the html is executed everytime I hit the home instead of 
 retrieving from the cache. However, I'm not sure if that print 
 request.now is a correct indicator.


The cache decorator just caches the output of the controller function, not 
the final HTML output. If you want to do the latter, then you should have 
the function itself directly call response.render() and return that (this 
technique is mentioned in the book).
 

  - Is it possible to use server-side cache of the view but **not** browser 
 side? I'm specially interested in caching the view server-side, but not 
 browser-side.


According to the documentation, this should be possible, but looking at the 
code, I'm not sure it actually is. Anyway, as long as you're caching on the 
server, why not also let the browser cache the page?
 

  - Users can login in my site, but homepage isn't different for logged in 
 users, only thing that's different is topbar showing the name of logged in 
 user. Is it still possible to use @cache.action?


Yes, but you'd want to set session=True to make sure each user gets a 
different page. In that case, though, you probably would not want to do 
server side caching, as you will be continually adding to the cache with no 
benefit over client-only caching. Also, keep in mind that values are not 
automatically deleted from the cache (even after they expire), so you don't 
want to accumulate an potentially unlimited number of cache items (you'll 
at least need to do some periodic cleanup).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: .json in url does not like contruções

2014-03-18 Thread Leonel Câmara
Olá António,

Is your controller .py file saved in utf-8 (make sure the text editor is 
doing it, use the save with encoding option if you have it) and has this 
as the first line?

# -*- coding: utf-8 -*-

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Tornado DISCONNECT from mygroup after 1 min

2014-03-18 Thread António Ramos
Hello, i moved my app from windows to linux

my websockets only stays up for a minute or less.

What could be the problem?

In windows it was working perfectly.

I´m using port  inside a virtualenv, because i´m no root at
action.ioand had to use virtualenv to install tornado.
(In case this could be important)


Help needed

Thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: .json in url does not like contruções

2014-03-18 Thread António Ramos
yes i have it in my controller.py file

# -*- coding: utf-8 -*-



2014-03-18 14:48 GMT+00:00 Leonel Câmara leonelcam...@gmail.com:

 Olá António,

 Is your controller .py file saved in utf-8 (make sure the text editor is
 doing it, use the save with encoding option if you have it) and has this
 as the first line?

 # -*- coding: utf-8 -*-

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Lisandro
El martes, 18 de marzo de 2014 09:30:34 UTC-3, Anthony escribió:

  - How can I verify when the html was actually retrieved from the cache? I 
 tried coding a print request.now in the view, but that sentence is 
 executed everytime I hit the site's homepage, so I deduce that the code 
 that generates the html is executed everytime I hit the home instead of 
 retrieving from the cache. However, I'm not sure if that print 
 request.now is a correct indicator.


 The cache decorator just caches the output of the controller function, not 
 the final HTML output. If you want to do the latter, then you should have 
 the function itself directly call response.render() and return that (this 
 technique is mentioned in the book).


Oh I see, I guess I missed that part, my bad. Now I'm getting the expected 
behaviour. 

  

  - Is it possible to use server-side cache of the view but **not** 
 browser side? I'm specially interested in caching the view server-side, but 
 not browser-side.


 According to the documentation, this should be possible, but looking at 
 the code, I'm not sure it actually is. Anyway, as long as you're caching on 
 the server, why not also let the browser cache the page?


True. I just had the doubt because I also read in the docs that it could be 
possible, but not shure how. However I'm not interested in browser-side 
cache for now.

  

  - Users can login in my site, but homepage isn't different for logged in 
 users, only thing that's different is topbar showing the name of logged in 
 user. Is it still possible to use @cache.action?


 Yes, but you'd want to set session=True to make sure each user gets a 
 different page. In that case, though, you probably would not want to do 
 server side caching, as you will be continually adding to the cache with no 
 benefit over client-only caching. Also, keep in mind that values are not 
 automatically deleted from the cache (even after they expire), so you don't 
 want to accumulate an potentially unlimited number of cache items (you'll 
 at least need to do some periodic cleanup).


Yes, actually I was thinking setting session=True for every user, but using 
cache_model=cache.ram just when the user isn't logged in. 

After your tips and a few tests, now I understand better. Now my goal is 
this: I want to cache server-side the rendered view **excluding the 
extended layout**, that is, I have a layout.html and index.html extends the 
layout. The layout has things that I don't want to be cached (for example, 
user's navbar).  I think in this case @cache.action is not going to work 
(because it will cache the complete rendered view).

However, I managed to achieve what I want, doing this:

 - A layout.html containing user's navbar and site's header and footer. 
 - An index.html that extends layout.html
 - An content.html that **doesn't** extends layout.html
 - An index() controller function that **doesn't** use @cache.action 
decorator. Instead, the function uses response.render() specifying 
content.html as the view file to be rendered, and stores the results of 
the rendering in the cache. That result is passed as a variable to 
index.html view.

In this way, I'm getting the behaviour I want, which is: caching just a 
portion of the site's homepage. If you see that something is wrong with 
this approach, please let me know. Until now tests have been ok. Thanks for 
your help!


 Anthony



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] redis pub/sub instead of tornado ?!

2014-03-18 Thread António Ramos
hello , can i use redis pub/sub functionality  instead of tornado ?

any examples?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Anthony


  - A layout.html containing user's navbar and site's header and footer. 
  - An index.html that extends layout.html
  - An content.html that **doesn't** extends layout.html
  - An index() controller function that **doesn't** use @cache.action 
 decorator. Instead, the function uses response.render() specifying 
 content.html as the view file to be rendered, and stores the results of 
 the rendering in the cache. That result is passed as a variable to 
 index.html view.


Seems like a reasonable approach. If you don't want to cache within the 
index function, you could instead use the @cache() decorator (rather than 
@cache.action).

Feel free to open a Google Code issue about not being able to turn off 
client side caching with @cache.action. That should be allowed, and this is 
a good use case for it (i.e., the need to cache only the output of the 
function, but not the entire rendered HTML due to user-specific data on 
each page).

Anthony
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Lisandro

El martes, 18 de marzo de 2014 12:16:45 UTC-3, Anthony escribió:

  - A layout.html containing user's navbar and site's header and footer. 
  - An index.html that extends layout.html
  - An content.html that **doesn't** extends layout.html
  - An index() controller function that **doesn't** use @cache.action 
 decorator. Instead, the function uses response.render() specifying 
 content.html as the view file to be rendered, and stores the results of 
 the rendering in the cache. That result is passed as a variable to 
 index.html view.


 Seems like a reasonable approach. If you don't want to cache within the 
 index function, you could instead use the @cache() decorator (rather than 
 @cache.action).


I will give it a try. I haven't tried that because the book suggested using 
@cache.action, but I will give it a try.
 


 Feel free to open a Google Code issue about not being able to turn off 
 client side caching with @cache.action. That should be allowed, and this is 
 a good use case for it (i.e., the need to cache only the output of the 
 function, but not the entire rendered HTML due to user-specific data on 
 each page).


I'll do it today, thanks again for the help! Regards, Lisandro.


 Anthony
  


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py on Koding.com

2014-03-18 Thread wuelfhis asuaje
Thas the code i'm using, is the main view /default/index.html

{{extend 'layout.html'}}


  div class=img 
{{=A(IMG(_src=URL('static/images','config2.jpeg'), 
_alt=Empresa, usuarios y parametros,  _width=80, _height=80, 
_class=none),   
   callback=URL('default','config'), target=modulos ) }}

pcenterstrongConfigurar empresa/strong/center
/div
...
...

Some more divs with same structure

Watching page code from right button see source code:

Bad code:

div class=img a data-w2p_disable_with=default data-w2p_method=POST 
data-w2p_target=modulos href=/PyRest/default/config 
view-source:http://vm-0.wasuaje.koding.kd.io/PyRest/default/config 
id=f56a3901-d32b-4eaa-a089-21de71450aa8img alt=Empresa, usuarios y 
parametros class=none height=80 src=/PyRest/static/images/config2.jpeg 
view-source:http://vm-0.wasuaje.koding.kd.io/PyRest/static/images/config2.jpeg
 width=80 //a   pcenterstrongConfigurar 
empresa/strong/center/div

good Code (from my machine)

div class=img a href=#null 
view-source:http://localhost:8000/PyRest/#null 
onclick=ajax('/PyRest/default/config',[],'modulos');return falseimg 
alt=Empresa, usuarios y parametros class=none height=80 
src=/PyRest/static/images/config2.jpeg 
view-source:http://localhost:8000/PyRest/static/images/config2.jpeg 
width=80 //a   pcenterstrongConfigurar 
empresa/strong/center/div


Seems like web2py is not interpreting or updating dom of the page or something 
like that








-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Anthony


 Seems like a reasonable approach. If you don't want to cache within the 
 index function, you could instead use the @cache() decorator (rather than 
 @cache.action).


 I will give it a try. I haven't tried that because the book suggested 
 using @cache.action, but I will give it a try.


Well, you're already using cache() within the index function itself -- it 
will be no different to use the decorator instead. The main issue is to 
make sure the key is unique to the specific content being cached (e.g., if 
there is a query string in the URL that affects the returned response, make 
sure that is part of the key).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py on Koding.com

2014-03-18 Thread wuelfhis asuaje
Update

I've created this app with web2py 2.3.2 But i'd like to use latest version 
2.9.5

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py on Koding.com

2014-03-18 Thread wuelfhis asuaje
Ok people

The problem is the difference on versions from 2.3.2 to 2.9.5, now

Can somebody tell me how to fix it ! How to make it run ?

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Change 'working...' message in ajax links

2014-03-18 Thread Ian W. Scott
I want to change the default 'working...' message presented in an ajax link 
while it is waiting for the callback to return. I couldn't find anything 
about this in the web2py manual, but looking in web2py.js it looks like the 
message can be overridden by setting the data-disable-with value on the 
link, e.g.:

myargs = {'data-disable-with': IMG(_src='coolspinner.gif')}
A('mylink', _href=URL('some', 'view'), **myargs)

(I believe the indirect insertion of the data-disable-with property is 
necessary because of the hyphens in the property name.)

But how would I change the default for all of my ajax links? Obviously I 
can just change line 474 of web2py.js, but that's a bit fragile because 
when I update my app with new versions of that file there's the risk of 
regression. So is there any way of setting this default value, say in 
db.py, for the whole app? If not, is this something we could add to the 
api? I suspect it's something that many will want to tweak to fit their own 
themes.

On a similar note, is there a way to set a custom default value for the 
'content' property of the LOAD helper? (Again, I'd like to set the new 
default in one place for the whole app.) I suppose I could subclass the 
LOAD helper, but that seems a bit heavy-handed. 

Thanks,

Ian

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: SmartGrid Add make a Fld Readonly

2014-03-18 Thread Dan Kozlowski
I found the problem after hours of testing different things. It was my 
mistake. I was using *writeable* when it should have been *writable*. 
Works perfect now.


Thanks for your help


On 03/17/2014 06:39 PM, 黄祥 wrote:

had you already try to simplify or minimalist your app first?
e.g.
def clients():
write_in_form_new = 'new' in request.args
if write_in_form_new:
db.clients.add_date.writeable = False
grid = SQLFORM.smartgrid(db.clients)
return locals()

best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the 
Google Groups web2py-users group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/UDGny-3tKq4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com 
mailto:web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Bootstrap3 package - help to test

2014-03-18 Thread Ian W. Scott
Although I'm replying late, I just want to say a huge thanks for tackling 
this. It's something I've wanted to get to for a few months, and it's great 
to see that I don't have to start from scratch. If there was an initial 
lack of response I suspect it's just that many people like me happened to 
miss the thread.

Kudos.

On Wednesday, January 15, 2014 6:10:25 PM UTC-5, LightDot wrote:

 Hm. I expected a flurry of responses by now. I haven't been able to work 
 on this since Christmas, but... come on, anyone?? :) I would think a 
 possibility of Bootstrap 3 and Zorb Foundation 5 welcome apps would draw 
 crowds...

 Anyway, layout.html:
 - web2py.css needs minor adjustments as there are no .main, .footer, 
 .footer-content and .header in layout anymore (btw, .push is also obsolete, 
 it disappeared almost 2 years ago, when skeleton.css was replaced by 
 bootstrap)
 - I did not test this part, but changes in regards to modernizr.custom.js 
 and respond.js seem appropriate. I would suggest a free CDN instead of 
 maxcdn.com, though. How about 
 cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js ? We could 
 suggest the same for Modernizr (
 cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.1/modernizr.min.js) and 
 remove it from static/js

 web2py-bootstrap3.css, web2py-bootstrap3.js, bootstrap3.py:
 - I see no issues so far, admittedly my tests were in no way extensive

 licenses:
 - IANAL, so this being my personal and layman opinion, chosen licenses 
 seem correct for all intended purposes.

 I'll try and do more tests soon.

 Regards


 On Monday, December 23, 2013 9:20:48 PM UTC+1, Paolo Caruccio wrote:

 I just completed a package that applies the bootstrap3 style to some 
 web2py elements - the current version covers the navigation menus, the auth 
 navbar and SQLFORMs (via formstyle) - but I need your help for testing it.

 The package includes the following files:

  - bootstrap3.py
  - web2py-bootstrap3.css
  - web2py-bootstrap3.js
  - example of layout.html
  - a readme file containing the istallation and usage instructions
  - license (please report if the license is right for a future inclusion 
 in web2py)

 Here attached some screenshots and a web2py app with examples. 

 Thank you in advance for your feedbacks, suggestions for optimizing the 
 code and any additions and everything else useful to improve the package.

 Marry Christmas. 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Password feild type seems to save in plain text for me.

2014-03-18 Thread Encompass solutions
I am trying to create a model with an encrypted key so it's harder for 
someone to maliciously screw over my customers.
I have the following snippet.
Field('public_gram', 'boolean', default=False),
Field('tag_name', 'list:string'),
Field('deletion_key', 'password')
)
You can see there the deletion_key is a feild type password which I 
understand is hashed out so you can't get the original code.  However, when 
I try to print it I get this...
test
CRYPT()(gram_details.deletion_key)
(gluon.validators.LazyCrypt object at 0x7f56b8305c10, None)
CRYPT()(gram_details.deletion_key) == gram_details.deletion_key
False
Where test is print gram_details.deletion_key
If this is the case then my password is not very cryptic.
Am I doing something wrong?
BR,
Jason Brower

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Password feild type seems to save in plain text for me.

2014-03-18 Thread Marin Pranjić
How did you insert test into database?

If you use db.tablename.insert(..., deletion_key='test') it will store it
plain text because you are bypassing validators.


You should:

1. use .validate_and_insert(...) instead
or
2. use .insert(deletion_key=db.tablename.deletion_key.validate('test'))

If you use SQLFORM(db.tablename...) it will automatically validate (=hash
the password)


Marin


On Tue, Mar 18, 2014 at 6:04 PM, Encompass solutions encomp...@gmail.comwrote:

 I am trying to create a model with an encrypted key so it's harder for
 someone to maliciously screw over my customers.
 I have the following snippet.
 Field('public_gram', 'boolean', default=False),
 Field('tag_name', 'list:string'),
 Field('deletion_key', 'password')
 )
 You can see there the deletion_key is a feild type password which I
 understand is hashed out so you can't get the original code.  However, when
 I try to print it I get this...
 test
 CRYPT()(gram_details.deletion_key)
 (gluon.validators.LazyCrypt object at 0x7f56b8305c10, None)
 CRYPT()(gram_details.deletion_key) == gram_details.deletion_key
 False
 Where test is print gram_details.deletion_key
 If this is the case then my password is not very cryptic.
 Am I doing something wrong?
 BR,
 Jason Brower

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py on Koding.com

2014-03-18 Thread wuelfhis asuaje
Ok People i solved !

I just copied web2py.js and (as i have a newer version of jquery 1.8.3) 
jquery.js to app/static folder

End of the story !

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: record versioning and standalone DAL

2014-03-18 Thread Alexandre Andrade
To record versiong works, you should set


db._common_fields.append(auth.signature)

after you db.define_tables() but
before defining any other table

and 

db.enable_record_versioning(db)

after you define all tables





Em segunda-feira, 30 de setembro de 2013 17h28min12s UTC-3, JaapP escreveu:

 Hi,

 i've build a (very small) standalone side project (so, running without 
 Web2Py) that uses the Web2Py DAL, and all goes well.

 Now i'm trying to enable record versioning. but this seems not to be 
 working  (thread._local object has no attribute 'request')

 Has anybody succeeded in using record versioning in a standalone project?

 Any hints greatly appreciated!

 Jaap



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] pysimplesoap help

2014-03-18 Thread piero crisci
Hi Mariano and thanks for the help.
I did what you said.
I downloaded the httplib2 and the pysimplesoap 1.10
I wrote the following code:

from pysimplesoap.client import SoapClient
location_wsdl = http://docway.demo.3di.it/3diws/services;
wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl;
import base64
username='admin'
password='3diadmin'
namespace_wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay;
auth = base64.b64encode('%s:%s' % (username, password))
client = SoapClient(location = location_wsdl, wsdl=wsdl,sessions=True, 
namespace=namespace_wsdl,http_headers={'Authorization': Basic %s % auth})


But i got the following error:
  File stdin, line 1, in module
  File build\bdist.win32\egg\pysimplesoap\client.py, line 133, in __init__
  File build\bdist.win32\egg\pysimplesoap\client.py, line 471, in 
wsdl_parse
  File build\bdist.win32\egg\pysimplesoap\simplexml.py, line 196, in 
__init__
  File C:\python27\lib\xml\dom\minidom.py, line 1930, in parseString
return expatbuilder.parseString(string)
  File C:\python27\lib\xml\dom\expatbuilder.py, line 940, in parseString
return builder.parseString(string)
  File C:\python27\lib\xml\dom\expatbuilder.py, line 223, in parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: mismatched tag: line 1, column 939



Il giorno martedì 18 marzo 2014 07:26:35 UTC+1, Mariano Reingart ha scritto:

 Hi piero:

 The first choice to connect to a webservice that requires username  
 password (add_credentials), you will httplib2 installed:

 https://code.google.com/p/httplib2

 Then you could do:

 client = SoapClient(location = location_wsdl,sessions=True,
 username='admin',password='xx')

 Also, assuming your webservice supports basic auth, you could pass the 
 Authentication http header directly (it shouldn't need to install external 
 library):

 import base64
 auth = base64.b64encode('%s:%s' % (username, password)).replace('\n', '')

 client = SoapClient(location = location_wsdl, sessions=True, 
 http_headers={'Authorization': Basic %s % auth})

 Let me know if this solves your issue,

 Best regards


 Mariano Reingart
 http://www.sistemasagiles.com.ar
 http://reingart.blogspot.com


 On Mon, Mar 17, 2014 at 6:02 PM, piero crisci 
 piero@gmail.comjavascript:
  wrote:

 Hello i am trying to connect to this wsdl: 
 http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl 
 It requires http basic authentication  and i am using pysimplesoap 1.10 
 and i tried this configuration:

 from pysimplesoap.client import SoapClient
 location_wsdl = http://docway.demo.3di.it/3diws/services;
 wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl;
 client = SoapClient(location = 
 location_wsdl,sessions=True,http_headers={'username': 'admin', 'password': 
 ''},username='admin',password='xx')

 I got this error
 Traceback (most recent call last):
   File stdin, line 1, in module
   File build\bdist.win32\egg\pysimplesoap\client.py, line 133, in 
 __init__
   File build\bdist.win32\egg\pysimplesoap\client.py, line 469, in 
 wsdl_parse
   File build\bdist.win32\egg\pysimplesoap\helpers.py, line 71, in fetch
   File build\bdist.win32\egg\pysimplesoap\transport.py, line 121, in 
 request
   File C:\python27\lib\urllib2.py, line 406, in open
 response = meth(req, response)
   File C:\python27\lib\urllib2.py, line 519, in http_response
 'http', request, response, code, msg, hdrs)
   File C:\python27\lib\urllib2.py, line 444, in error
 return self._call_chain(*args)
   File C:\python27\lib\urllib2.py, line 378, in _call_chain
 result = func(*args)
   File C:\python27\lib\urllib2.py, line 527, in http_error_default
 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
 urllib2.HTTPError: HTTP Error 401: Unauthorized

 It seems like the basic authenitcation is not supported. am I wrong?
 How i need to change the wsdl call? And how i can use a session to send 
 different call?
 Thx for help!
  
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Python Performance Issue, Part 2

2014-03-18 Thread horridohobbyist
I took the shipping code that I ran in Flask (without Apache) and adapted 
it to run under Apache as a Flask app. That way, I'm comparing apples to 
apples. I'm comparing the performance of the shipping code between Flask 
and web2py.

Below, I've included the 'default' file from Apache2/sites-available for 
Flask.

Basically, the code in Flask executes 10x faster than the same code in 
web2py. So my question is:  if Apache is at fault for the web2py app's slow 
performance, why doesn't Apache hurt the Flask app's performance? (This 
doesn't seem to be related to GIL or WSGI.)


VirtualHost *:80
  ServerName 10.211.55.7
  WSGIDaemonProcess hello user=www-data group=www-data threads=5
  WSGIScriptAlias / /home/richard/welcome/hello.wsgi

  Directory /home/richard/welcome
Order Allow,Deny
Allow from all
  /Directory
/VirtualHost

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
430x300x200 430x300x200 400x370x330 390x285x140 585x285x200
430x300x200 400x370x330 553x261x152 290x210x160 390x285x140


debug.out
Description: Binary data
from flask import Flask
app = Flask(__name__)

import time
import sys
import os
debug_path = '/home/richard/welcome/debug.out'
def debug(str):
f = open(debug_path,'a')
f.write(str+'\n')
f.close()
return

#
# pyShipping 1.8a
#
import time
import random
from shippackage import Package

def packstrip(bin, p):
Creates a Strip which fits into bin.

Returns the Packages to be used in the strip, the dimensions of the strip as a 3-tuple
and a list of left over packages.

# This code is somewhat optimized and somewhat unreadable
s = []# strip
r = []# rest
ss = sw = sl = 0  # stripsize
bs = bin.heigth   # binsize
sapp = s.append   # speedup
rapp = r.append   # speedup
ppop = p.pop  # speedup
while p and (ss = bs):
n = ppop(0)
nh, nw, nl = n.size
if ss + nh = bs:
ss += nh
sapp(n)
if nw  sw:
sw = nw
if nl  sl:
sl = nl
else:
rapp(n)
return s, (ss, sw, sl), r + p


def packlayer(bin, packages):
strips = []
layersize = 0
layerx = 0
layery = 0
binsize = bin.width
while packages:
strip, (sizex, stripsize, sizez), rest = packstrip(bin, packages)
if layersize + stripsize = binsize:
if not strip:
# we were not able to pack anything
break
layersize += stripsize
layerx = max([sizex, layerx])
layery = max([sizez, layery])
strips.extend(strip)
packages = rest
else:
# Next Layer please
packages = strip + rest
break
return strips, (layerx, layersize, layery), packages


def packbin(bin, packages):
packages.sort()
layers = []
contentheigth = 0
contentx = 0
contenty = 0
binsize = bin.length
while packages:
layer, (sizex, sizey, layersize), rest = packlayer(bin, packages)
if contentheigth + layersize = binsize:
if not layer:
# we were not able to pack anything
break
contentheigth += layersize
contentx = max([contentx, sizex])
contenty = max([contenty, sizey])
layers.extend(layer)
packages = rest
else:
# Next Bin please
packages = layer + rest
break
return layers, (contentx, contenty, contentheigth), packages


def packit(bin, originalpackages):
packedbins = []
packages = sorted(originalpackages)
while packages:
packagesinbin, (binx, biny, binz), rest = packbin(bin, packages)
if not packagesinbin:
# we were not able to pack anything
break
packedbins.append(packagesinbin)
packages = rest
# we now have a result, try to get a better result by rotating some bins

return packedbins, rest


# In newer Python versions these van be imported:
# from itertools import permutations
def product(*args, **kwds):
# product('ABCD', 'xy') -- Ax Ay Bx By Cx Cy Dx Dy
# product(range(2), repeat=3) -- 000 001 010 011 100 101 110 111
pools = map(tuple, args) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
result = [x + [y] for x in result for y in pool]
for prod in result:
yield tuple(prod)


def permutations(iterable, r=None):
pool = tuple(iterable)
n = 

Re: [web2py] Python Performance Issue, Part 2

2014-03-18 Thread Michele Comitini
 WSGIDaemonProcess hello user=www-data group=www-data threads=5

with web2py try the following instead:
WSGIDaemonProcess hello user=www-data group=www-data processes=number
of cores + 1 threads=(0 or 1)

If it's faster, then the GIL must be the cause.  flask by default has
much less features active (session for instance)



2014-03-18 21:04 GMT+01:00 horridohobbyist horrido.hobb...@gmail.com:
 I took the shipping code that I ran in Flask (without Apache) and adapted it
 to run under Apache as a Flask app. That way, I'm comparing apples to
 apples. I'm comparing the performance of the shipping code between Flask and
 web2py.

 Below, I've included the 'default' file from Apache2/sites-available for
 Flask.

 Basically, the code in Flask executes 10x faster than the same code in
 web2py. So my question is:  if Apache is at fault for the web2py app's slow
 performance, why doesn't Apache hurt the Flask app's performance? (This
 doesn't seem to be related to GIL or WSGI.)


 VirtualHost *:80
   ServerName 10.211.55.7
   WSGIDaemonProcess hello user=www-data group=www-data threads=5
   WSGIScriptAlias / /home/richard/welcome/hello.wsgi

   Directory /home/richard/welcome
 Order Allow,Deny
 Allow from all
   /Directory
 /VirtualHost

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: .json in url does not like contruções

2014-03-18 Thread Michele Comitini
@Antonio,

please create a simple example action that causes the error in your
setup and post it here.
something like

# -*- coding: utf-8 -*-

def myfunc():
   return dict(mykey='contruções')




2014-03-18 15:57 GMT+01:00 António Ramos ramstei...@gmail.com:
 yes i have it in my controller.py file

 # -*- coding: utf-8 -*-



 2014-03-18 14:48 GMT+00:00 Leonel Câmara leonelcam...@gmail.com:

 Olá António,

 Is your controller .py file saved in utf-8 (make sure the text editor is
 doing it, use the save with encoding option if you have it) and has this
 as the first line?

 # -*- coding: utf-8 -*-

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What's the correct implementation of cache.action?

2014-03-18 Thread Niphlod
@cache.action(public=False)
will cache the content server-side and send along in the past cache 
headers, marking also the content as private, so browsers are forced to 
reissue the request for that page. 

On Tuesday, March 18, 2014 5:16:24 PM UTC+1, Anthony wrote:

 Seems like a reasonable approach. If you don't want to cache within the 
 index function, you could instead use the @cache() decorator (rather than 
 @cache.action).


 I will give it a try. I haven't tried that because the book suggested 
 using @cache.action, but I will give it a try.


 Well, you're already using cache() within the index function itself -- it 
 will be no different to use the decorator instead. The main issue is to 
 make sure the key is unique to the specific content being cached (e.g., if 
 there is a query string in the URL that affects the returned response, make 
 sure that is part of the key).

 Anthony


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] pysimplesoap help

2014-03-18 Thread piero crisci
Well i made it with pysimplesoad 1.12
Thanks!

Il giorno martedì 18 marzo 2014 20:44:54 UTC+1, piero crisci ha scritto:

 Hi Mariano and thanks for the help.
 I did what you said.
 I downloaded the httplib2 and the pysimplesoap 1.10
 In the pysimplesoad 1.10 the params username and password are not 
 present anymore
 I wrote the following code:

 from pysimplesoap.client import SoapClient
 location_wsdl = http://docway.demo.3di.it/3diws/services;
 wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl;
 import base64
 username='admin'
 password='X'
 namespace_wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay;
 auth = base64.b64encode('%s:%s' % (username, password))
 client = SoapClient(location = location_wsdl, wsdl=wsdl,sessions=True, 
 namespace=namespace_wsdl,http_headers={'Authorization': Basic %s % auth})


 But i got the following error:
   File stdin, line 1, in module
   File build\bdist.win32\egg\pysimplesoap\client.py, line 133, in 
 __init__
   File build\bdist.win32\egg\pysimplesoap\client.py, line 471, in 
 wsdl_parse
   File build\bdist.win32\egg\pysimplesoap\simplexml.py, line 196, in 
 __init__
   File C:\python27\lib\xml\dom\minidom.py, line 1930, in parseString
 return expatbuilder.parseString(string)
   File C:\python27\lib\xml\dom\expatbuilder.py, line 940, in parseString
 return builder.parseString(string)
   File C:\python27\lib\xml\dom\expatbuilder.py, line 223, in parseString
 parser.Parse(string, True)
 xml.parsers.expat.ExpatError: mismatched tag: line 1, column 939



 Il giorno martedì 18 marzo 2014 07:26:35 UTC+1, Mariano Reingart ha 
 scritto:

 Hi piero:

 The first choice to connect to a webservice that requires username  
 password (add_credentials), you will httplib2 installed:

 https://code.google.com/p/httplib2

 Then you could do:

 client = SoapClient(location = location_wsdl,sessions=True,
 username='admin',password='xx')

 Also, assuming your webservice supports basic auth, you could pass the 
 Authentication http header directly (it shouldn't need to install external 
 library):

 import base64
 auth = base64.b64encode('%s:%s' % (username, password)).replace('\n', '')

 client = SoapClient(location = location_wsdl, sessions=True, 
 http_headers={'Authorization': Basic %s % auth})

 Let me know if this solves your issue,

 Best regards


 Mariano Reingart
 http://www.sistemasagiles.com.ar
 http://reingart.blogspot.com


 On Mon, Mar 17, 2014 at 6:02 PM, piero crisci piero@gmail.comwrote:

 Hello i am trying to connect to this wsdl: 
 http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl 
 It requires http basic authentication  and i am using pysimplesoap 1.10 
 and i tried this configuration:

 from pysimplesoap.client import SoapClient
 location_wsdl = http://docway.demo.3di.it/3diws/services;
 wsdl = http://docway.demo.3di.it/3diws/services/eXtraWay?wsdl;
 client = SoapClient(location = 
 location_wsdl,sessions=True,http_headers={'username': 'admin', 'password': 
 ''},username='admin',password='xx')

 I got this error
 Traceback (most recent call last):
   File stdin, line 1, in module
   File build\bdist.win32\egg\pysimplesoap\client.py, line 133, in 
 __init__
   File build\bdist.win32\egg\pysimplesoap\client.py, line 469, in 
 wsdl_parse
   File build\bdist.win32\egg\pysimplesoap\helpers.py, line 71, in fetch
   File build\bdist.win32\egg\pysimplesoap\transport.py, line 121, in 
 request
   File C:\python27\lib\urllib2.py, line 406, in open
 response = meth(req, response)
   File C:\python27\lib\urllib2.py, line 519, in http_response
 'http', request, response, code, msg, hdrs)
   File C:\python27\lib\urllib2.py, line 444, in error
 return self._call_chain(*args)
   File C:\python27\lib\urllib2.py, line 378, in _call_chain
 result = func(*args)
   File C:\python27\lib\urllib2.py, line 527, in http_error_default
 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
 urllib2.HTTPError: HTTP Error 401: Unauthorized

 It seems like the basic authenitcation is not supported. am I wrong?
 How i need to change the wsdl call? And how i can use a session to send 
 different call?
 Thx for help!
  
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 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/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving 

Re: [web2py] Re: Python Performance Issue

2014-03-18 Thread Niphlod
apache isn't fine for static files either. 
The move to evented-like webservers of practically all tech-savvy peoples 
in the need is a good estimate on how much the uber-standard apache lacks 
in easy-to-debug scenario (I won't even start with the know-how of the 
syntax to make it work as you'd like).
It grew big with cgi, php and java and practically every shared hosting out 
there back in the days where no alternatives were available. It shows all 
of its age ^__^

BTW: nginx doesn't run python as apache does. Usually you have something to 
manage python processes (gunicorn or uwsgi) and nginx just buffers in/out 
requests (and being evented-like is a perfect candidate).

On Tuesday, March 18, 2014 7:21:29 AM UTC+1, Massimo Di Pierro wrote:

 People have found lots of variability in performance with apache+mod_wsgi. 
 Performance is very sensitive to memeory/etc.

 This is because Apache is not async (like nginx) and it either uses 
 threads or processes. Both have issues with Python. Threads slow you down 
 because of the GIL. Parallel processes may consume lots of memory which may 
 also cause performance issues. Things get worse and worse if processes hand 
 (think of clients sending requests but not loading because of slow 
 connections).

 Apache is fine for static files. gunicorn and nginx are known to have much 
 better performance with Pyhton web apps.

 Massimo



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Python Performance Issue

2014-03-18 Thread Niphlod
BTW: apache still suffers the SLOWLORIS attack if not carefully configured. 
ATM only workarounds to mitigate the issue are there, but not a definitive 
solution.

On Tuesday, March 18, 2014 9:46:38 PM UTC+1, Niphlod wrote:

 apache isn't fine for static files either. 
 The move to evented-like webservers of practically all tech-savvy 
 peoples in the need is a good estimate on how much the uber-standard apache 
 lacks in easy-to-debug scenario (I won't even start with the know-how of 
 the syntax to make it work as you'd like).
 It grew big with cgi, php and java and practically every shared hosting 
 out there back in the days where no alternatives were available. It shows 
 all of its age ^__^

 BTW: nginx doesn't run python as apache does. Usually you have something 
 to manage python processes (gunicorn or uwsgi) and nginx just buffers 
 in/out requests (and being evented-like is a perfect candidate).

 On Tuesday, March 18, 2014 7:21:29 AM UTC+1, Massimo Di Pierro wrote:

 People have found lots of variability in performance with 
 apache+mod_wsgi. Performance is very sensitive to memeory/etc.

 This is because Apache is not async (like nginx) and it either uses 
 threads or processes. Both have issues with Python. Threads slow you down 
 because of the GIL. Parallel processes may consume lots of memory which may 
 also cause performance issues. Things get worse and worse if processes hand 
 (think of clients sending requests but not loading because of slow 
 connections).

 Apache is fine for static files. gunicorn and nginx are known to have 
 much better performance with Pyhton web apps.

 Massimo



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] calling download function page by ajax

2014-03-18 Thread Richard
Hello,

I want to call 2 functions that return a file to be upload/download into 
client computer... I have been able to make the first call page to upload 
file correctly, but I can't figure out how to make upload both files, I 
thought I could solve the issue with ajax call, no lock.

# controller

def form_func_that_call_my_download_funcs():
...
if form.process().accpet:
...
redirect(URL(c='label', f='download_func1', extension=False,
   vars=dict(var1=var1, **other_vars_dict)), 
client_side=True) # This work for one file as it should...
...


def shell_func():
return dict(a='')


# view
# shell_func()
div id=batch_div
{{=LOAD('lotns', 'other_func_that_just_return_so_var_input', 
extension='load', ajax=True, target='batch_div')}}
!-- On submit of this view form_func_that_call_my_download_funcs() is 
loaded below with web2py_component() --
/div

div id=form_func_that_call_my_download_funcs_div
!-- form_func_that_call_my_download_funcs() loaded here with 
web2py_component() --
/div


I try to change form_func_that_call_my_download_funcs() like this :

def form_func_that_call_my_download_funcs():
...
if form.process().accpet:
...
response.js = 
$.get(url='http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678');
response.js += 
$.get(url='http://127.0.0.1:8000/sgddms/label/download_func2?var1=2676var1=2673var1=2678');
 
# I see the call passing in chrome dev tool both the files are not 
download??? Try with $.post() too...
...


# Here what look my download function, both are the same so I just show the 
important thing in one of them...
def download_func1():
...
final = StringIO(final_wordml)
response.headers['Content-Type'] = 'xml'
response.headers['Content-Disposition'] = \
'attachment;filename=filename123_%s.xml;' % 
request.now.strftime('%Y-%m-%d_%H-%M-%S-%f')
response.write(final.getvalue(), escape=False)
raise HTTP(200, str(final.getvalue()), **response.headers)


Thanks for any pointer!

Richard

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] calling download function page by ajax

2014-03-18 Thread Niphlod
content-disposition on ajax requests is not allowed, therefore browser 
refuse to show the usual download as file dialog, plain and simple :D

You need to come up with an alternative plan (such as, opening a new window 
pointing to the url, open a hidden iframe, using 3rd party libraries that 
do the previous, etc)

On Tuesday, March 18, 2014 9:59:40 PM UTC+1, Richard wrote:

 Hello,

 I want to call 2 functions that return a file to be upload/download into 
 client computer... I have been able to make the first call page to upload 
 file correctly, but I can't figure out how to make upload both files, I 
 thought I could solve the issue with ajax call, no lock.

 # controller

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 redirect(URL(c='label', f='download_func1', extension=False,
vars=dict(var1=var1, **other_vars_dict)), 
 client_side=True) # This work for one file as it should...
 ...


 def shell_func():
 return dict(a='')


 # view
 # shell_func()
 div id=batch_div
 {{=LOAD('lotns', 'other_func_that_just_return_so_var_input', 
 extension='load', ajax=True, target='batch_div')}}
 !-- On submit of this view form_func_that_call_my_download_funcs() is 
 loaded below with web2py_component() --
 /div

 div id=form_func_that_call_my_download_funcs_div
 !-- form_func_that_call_my_download_funcs() loaded here with 
 web2py_component() --
 /div


 I try to change form_func_that_call_my_download_funcs() like this :

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 response.js = $.get(url='
 http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678')
 ;
 response.js += $.get(url='
 http://127.0.0.1:8000/sgddms/label/download_func2?var1=2676var1=2673var1=2678');
  
 # I see the call passing in chrome dev tool both the files are not 
 download??? Try with $.post() too...
 ...


 # Here what look my download function, both are the same so I just show 
 the important thing in one of them...
 def download_func1():
 ...
 final = StringIO(final_wordml)
 response.headers['Content-Type'] = 'xml'
 response.headers['Content-Disposition'] = \
 'attachment;filename=filename123_%s.xml;' % 
 request.now.strftime('%Y-%m-%d_%H-%M-%S-%f')
 response.write(final.getvalue(), escape=False)
 raise HTTP(200, str(final.getvalue()), **response.headers)


 Thanks for any pointer!

 Richard


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] 504 Gateway Time-out

2014-03-18 Thread António Ramos
i have this error on linux with sqlite as my database sometimes when i save
a record

504 Gateway Time-out

--
nginx


Did anyone had this error before?


Thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] calling download function page by ajax

2014-03-18 Thread Richard Vézina
:(

I already have a workaround where I show buttons for starting download for
each files that are appended on submit, but I hate that from user
experience point of view... I thought about an other solution, where I
could get vars values from javascritp once form is submit trought
session.var but I am not sure it will work.

Do you know such a library?

Thanks

Richard


On Tue, Mar 18, 2014 at 6:05 PM, Niphlod niph...@gmail.com wrote:

 content-disposition on ajax requests is not allowed, therefore browser
 refuse to show the usual download as file dialog, plain and simple :D

 You need to come up with an alternative plan (such as, opening a new
 window pointing to the url, open a hidden iframe, using 3rd party libraries
 that do the previous, etc)


 On Tuesday, March 18, 2014 9:59:40 PM UTC+1, Richard wrote:

 Hello,

 I want to call 2 functions that return a file to be upload/download into
 client computer... I have been able to make the first call page to upload
 file correctly, but I can't figure out how to make upload both files, I
 thought I could solve the issue with ajax call, no lock.

 # controller

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 redirect(URL(c='label', f='download_func1', extension=False,
vars=dict(var1=var1, **other_vars_dict)),
 client_side=True) # This work for one file as it should...
 ...


 def shell_func():
 return dict(a='')


 # view
 # shell_func()
 div id=batch_div
 {{=LOAD('lotns', 'other_func_that_just_return_so_var_input',
 extension='load', ajax=True, target='batch_div')}}
 !-- On submit of this view form_func_that_call_my_download_funcs() is
 loaded below with web2py_component() --
 /div

 div id=form_func_that_call_my_download_funcs_div
 !-- form_func_that_call_my_download_funcs() loaded here with
 web2py_component() --
 /div


 I try to change form_func_that_call_my_download_funcs() like this :

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 response.js = $.get(url='http://127.0.0.1:
 8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678');
 response.js += $.get(url='http://127.0.0.1:
 8000/sgddms/label/download_func2?var1=2676var1=2673var1=2678'); # I
 see the call passing in chrome dev tool both the files are not download???
 Try with $.post() too...
 ...


 # Here what look my download function, both are the same so I just show
 the important thing in one of them...
 def download_func1():
 ...
 final = StringIO(final_wordml)
 response.headers['Content-Type'] = 'xml'
 response.headers['Content-Disposition'] = \
 'attachment;filename=filename123_%s.xml;' %
 request.now.strftime('%Y-%m-%d_%H-%M-%S-%f')
 response.write(final.getvalue(), escape=False)
 raise HTTP(200, str(final.getvalue()), **response.headers)


 Thanks for any pointer!

 Richard

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Python Performance Issue, Part 2

2014-03-18 Thread horridohobbyist
Done. With processes=3, the 10x discrepancy is eliminated! (And this is in 
a Linux VM configured for 1 CPU.)


On Tuesday, 18 March 2014 16:26:24 UTC-4, Michele Comitini wrote:

  WSGIDaemonProcess hello user=www-data group=www-data threads=5 

 with web2py try the following instead: 
 WSGIDaemonProcess hello user=www-data group=www-data processes=number 
 of cores + 1 threads=(0 or 1) 

 If it's faster, then the GIL must be the cause.  flask by default has 
 much less features active (session for instance) 



 2014-03-18 21:04 GMT+01:00 horridohobbyist 
 horrido...@gmail.comjavascript:: 

  I took the shipping code that I ran in Flask (without Apache) and 
 adapted it 
  to run under Apache as a Flask app. That way, I'm comparing apples to 
  apples. I'm comparing the performance of the shipping code between Flask 
 and 
  web2py. 
  
  Below, I've included the 'default' file from Apache2/sites-available for 
  Flask. 
  
  Basically, the code in Flask executes 10x faster than the same code in 
  web2py. So my question is:  if Apache is at fault for the web2py app's 
 slow 
  performance, why doesn't Apache hurt the Flask app's performance? (This 
  doesn't seem to be related to GIL or WSGI.) 
  
  
  VirtualHost *:80 
ServerName 10.211.55.7 
WSGIDaemonProcess hello user=www-data group=www-data threads=5 
WSGIScriptAlias / /home/richard/welcome/hello.wsgi 
  
Directory /home/richard/welcome 
  Order Allow,Deny 
  Allow from all 
/Directory 
  /VirtualHost 
  
  -- 
  Resources: 
  - http://web2py.com 
  - http://web2py.com/book (Documentation) 
  - http://github.com/web2py/web2py (Source code) 
  - https://code.google.com/p/web2py/issues/list (Report Issues) 
  --- 
  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 javascript:. 
  For more options, visit https://groups.google.com/d/optout. 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Python Performance Issue, Part 2

2014-03-18 Thread Massimo Di Pierro
Thank you for all your tests. You should write a summary of your results 
with recommendations for Apache users.

On Tuesday, 18 March 2014 19:44:29 UTC-5, horridohobbyist wrote:

 Done. With processes=3, the 10x discrepancy is eliminated! (And this is in 
 a Linux VM configured for 1 CPU.)


 On Tuesday, 18 March 2014 16:26:24 UTC-4, Michele Comitini wrote:

  WSGIDaemonProcess hello user=www-data group=www-data threads=5 

 with web2py try the following instead: 
 WSGIDaemonProcess hello user=www-data group=www-data processes=number 
 of cores + 1 threads=(0 or 1) 

 If it's faster, then the GIL must be the cause.  flask by default has 
 much less features active (session for instance) 



 2014-03-18 21:04 GMT+01:00 horridohobbyist horrido...@gmail.com: 
  I took the shipping code that I ran in Flask (without Apache) and 
 adapted it 
  to run under Apache as a Flask app. That way, I'm comparing apples to 
  apples. I'm comparing the performance of the shipping code between 
 Flask and 
  web2py. 
  
  Below, I've included the 'default' file from Apache2/sites-available 
 for 
  Flask. 
  
  Basically, the code in Flask executes 10x faster than the same code in 
  web2py. So my question is:  if Apache is at fault for the web2py app's 
 slow 
  performance, why doesn't Apache hurt the Flask app's performance? (This 
  doesn't seem to be related to GIL or WSGI.) 
  
  
  VirtualHost *:80 
ServerName 10.211.55.7 
WSGIDaemonProcess hello user=www-data group=www-data threads=5 
WSGIScriptAlias / /home/richard/welcome/hello.wsgi 
  
Directory /home/richard/welcome 
  Order Allow,Deny 
  Allow from all 
/Directory 
  /VirtualHost 
  
  -- 
  Resources: 
  - http://web2py.com 
  - http://web2py.com/book (Documentation) 
  - http://github.com/web2py/web2py (Source code) 
  - https://code.google.com/p/web2py/issues/list (Report Issues) 
  --- 
  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/d/optout. 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2pyslices

2014-03-18 Thread Frank
Hi,

I don’t see any “bug/issue report” on web2pyslices. Is there one?

I’ve posted a recipe comment but I don’t see (also) the comment anywhere or any 
flash message saying it will be checked for approval or so.

my 2 cents,

Cheers, 
-- 
Frank

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] MicroData and Uploaded Images problem

2014-03-18 Thread openworldofbusiness
Hello I am implementing some pretty basic micro data information (For 
Google Searches) and I am having a problem displaying an image uploaded to 
SQLITE in the Structured Data Testing tool. 

Here is a screenshot what the information contains

http://imagehost.suck-o.com/images/2014/03/19/image.png

The logo field is the problem in question. 

This is the output displayed in the listing

http://imagehost.suck-o.com/images/2014/03/19/image2.png

I checked the link which is a direct link to download the image in my 
browser (Normally an image selected in my browser will display in the 
browser). Is there a way to directly link to the images that are uploaded 
in to the uploads folder. So that hopefully based on my assumption Google 
will understand how to handle the image?

Thank you for any advice :D


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Python Performance Issue, Part 2

2014-03-18 Thread horridohobbyist
I shall do that. Thanks.

With the knowledge about processes=, I've tuned my actual Linux server to 
eliminate the 10x slowdown. As it turns out, for my 2.4GHz quad-core Xeon 
with 4GB RAM, processes=2 works best. I found that any other value (3, 4, 
5) gave very inconsistent results–sometimes I would get 1x (the ideal) and 
sometimes I would get 10x. Very bizarre.

processes=2 is counter-intuitive. After all, I have 4 cores. Why 
shouldn't processes=4 be good?

Anyway, not only is the shipping code fast, but I find that my overall 
web2py app feels a lot snappier. Is it just my imagination?

If processes=2 is boosting the speed of Python in general, then you would 
expect all of web2py to benefit. So maybe it's not my imagination.

Anyway, the takeaway, I think, is that you must tune the Apache 
configuration for the particular server hardware that you have. The default 
processes=1 is not good enough.


On Tuesday, 18 March 2014 22:37:58 UTC-4, Massimo Di Pierro wrote:

 Thank you for all your tests. You should write a summary of your results 
 with recommendations for Apache users.

 On Tuesday, 18 March 2014 19:44:29 UTC-5, horridohobbyist wrote:

 Done. With processes=3, the 10x discrepancy is eliminated! (And this is 
 in a Linux VM configured for 1 CPU.)


 On Tuesday, 18 March 2014 16:26:24 UTC-4, Michele Comitini wrote:

  WSGIDaemonProcess hello user=www-data group=www-data threads=5 

 with web2py try the following instead: 
 WSGIDaemonProcess hello user=www-data group=www-data processes=number 
 of cores + 1 threads=(0 or 1) 

 If it's faster, then the GIL must be the cause.  flask by default has 
 much less features active (session for instance) 



 2014-03-18 21:04 GMT+01:00 horridohobbyist horrido...@gmail.com: 
  I took the shipping code that I ran in Flask (without Apache) and 
 adapted it 
  to run under Apache as a Flask app. That way, I'm comparing apples to 
  apples. I'm comparing the performance of the shipping code between 
 Flask and 
  web2py. 
  
  Below, I've included the 'default' file from Apache2/sites-available 
 for 
  Flask. 
  
  Basically, the code in Flask executes 10x faster than the same code in 
  web2py. So my question is:  if Apache is at fault for the web2py app's 
 slow 
  performance, why doesn't Apache hurt the Flask app's performance? 
 (This 
  doesn't seem to be related to GIL or WSGI.) 
  
  
  VirtualHost *:80 
ServerName 10.211.55.7 
WSGIDaemonProcess hello user=www-data group=www-data threads=5 
WSGIScriptAlias / /home/richard/welcome/hello.wsgi 
  
Directory /home/richard/welcome 
  Order Allow,Deny 
  Allow from all 
/Directory 
  /VirtualHost 
  
  -- 
  Resources: 
  - http://web2py.com 
  - http://web2py.com/book (Documentation) 
  - http://github.com/web2py/web2py (Source code) 
  - https://code.google.com/p/web2py/issues/list (Report Issues) 
  --- 
  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/d/optout. 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Python Performance Issue, Part 2

2014-03-18 Thread horridohobbyist
threads=0 is no good–Apache restart upchucks on this.

BTW, I haven't experimented with the threads value. Might this also improve 
performance (with respect to GIL)?

Also, I was wondering. Is the processes= solution related to whether you 
are using the prefork MPM or the worker MPM? I know that Apache is 
normally compiled to use the prefork MPM.


On Tuesday, 18 March 2014 16:26:24 UTC-4, Michele Comitini wrote:

  WSGIDaemonProcess hello user=www-data group=www-data threads=5 

 with web2py try the following instead: 
 WSGIDaemonProcess hello user=www-data group=www-data processes=number 
 of cores + 1 threads=(0 or 1) 

 If it's faster, then the GIL must be the cause.  flask by default has 
 much less features active (session for instance) 



 2014-03-18 21:04 GMT+01:00 horridohobbyist 
 horrido...@gmail.comjavascript:: 

  I took the shipping code that I ran in Flask (without Apache) and 
 adapted it 
  to run under Apache as a Flask app. That way, I'm comparing apples to 
  apples. I'm comparing the performance of the shipping code between Flask 
 and 
  web2py. 
  
  Below, I've included the 'default' file from Apache2/sites-available for 
  Flask. 
  
  Basically, the code in Flask executes 10x faster than the same code in 
  web2py. So my question is:  if Apache is at fault for the web2py app's 
 slow 
  performance, why doesn't Apache hurt the Flask app's performance? (This 
  doesn't seem to be related to GIL or WSGI.) 
  
  
  VirtualHost *:80 
ServerName 10.211.55.7 
WSGIDaemonProcess hello user=www-data group=www-data threads=5 
WSGIScriptAlias / /home/richard/welcome/hello.wsgi 
  
Directory /home/richard/welcome 
  Order Allow,Deny 
  Allow from all 
/Directory 
  /VirtualHost 
  
  -- 
  Resources: 
  - http://web2py.com 
  - http://web2py.com/book (Documentation) 
  - http://github.com/web2py/web2py (Source code) 
  - https://code.google.com/p/web2py/issues/list (Report Issues) 
  --- 
  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 javascript:. 
  For more options, visit https://groups.google.com/d/optout. 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Customisable error messages for a form determined by device type.

2014-03-18 Thread chris_g
I am happily using the web2py FORM and custom validator's for form 
validation using JSON messaging.

The problem I have is a customer wants verbose messages for webpages, but 
succinct messages for everything else.
For eg,
On the webpage You must enter an email address, A password is required, 
 is an invalid post code while on an iPhone app or Mobile Webpage, 
email required, password required, invalid postcode.

Device type is easy enough to determine by data from request.user_agent(), 
so that isn't a big issue.

I'm just curious to see how others approach this kind of situation. 
Obviously, I'd like to keep my registration method and FORM object function 
common so I don't have to maintain the same code in multiple places.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: MicroData and Uploaded Images problem

2014-03-18 Thread Leonel Câmara
You can use attachments=False in your response.download call on your 
download controller function if you don't want it to download 
automatically.  
  
Although I don't think that's what's causing the google trouble.  
  
You can also try adding:

response.headers['Content-Type'] = 'image/png'

Again, I don't see anything wrong with your original solution. Is it 
possible the thumbnail generation is the problem or that the logo just 
isn't supposed to show or something?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Newby - what is (**dict(form.vars))

2014-03-18 Thread Chops
I am just learning Web2py

I have an understanding of dict but now I find it used with two asterisks 
before it and I can't seem to find an explanation!!

Can it be used with anything other than a form? ((**dict(form.vars))?

Can I use the two asterisks on other bits of code to server a common 
purpose?

Thanks in advance

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] calling download function page by ajax

2014-03-18 Thread Limedrop
You might want to look at 
http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/

The only fiddly bit is to make sure you set the cookies correctly (see the 
documentation for details).

For example:

  {{view}}
  
response.files.append(URL('static','js/jquery.fileDownload/jquery.fileDownload.js'))
  
  
  {{controller}}
  response.js = 
'$.fileDownload(http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678;);'
  response.js += 
'$.fileDownload(http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678;);'
  # these cookies are required by jQuery.fileDownload.js
  # to enable download via ajax
  response.cookies['fileDownload'] = 'true'
  response.cookies['fileDownload']['path'] = /





On Wednesday, March 19, 2014 1:38:43 PM UTC+13, Richard wrote:

 :(

 I already have a workaround where I show buttons for starting download for 
 each files that are appended on submit, but I hate that from user 
 experience point of view... I thought about an other solution, where I 
 could get vars values from javascritp once form is submit trought 
 session.var but I am not sure it will work.

 Do you know such a library?

 Thanks

 Richard


 On Tue, Mar 18, 2014 at 6:05 PM, Niphlod nip...@gmail.com 
 javascript:wrote:

 content-disposition on ajax requests is not allowed, therefore browser 
 refuse to show the usual download as file dialog, plain and simple :D

 You need to come up with an alternative plan (such as, opening a new 
 window pointing to the url, open a hidden iframe, using 3rd party libraries 
 that do the previous, etc)


 On Tuesday, March 18, 2014 9:59:40 PM UTC+1, Richard wrote:

 Hello,

 I want to call 2 functions that return a file to be upload/download into 
 client computer... I have been able to make the first call page to upload 
 file correctly, but I can't figure out how to make upload both files, I 
 thought I could solve the issue with ajax call, no lock.

 # controller

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 redirect(URL(c='label', f='download_func1', extension=False,
vars=dict(var1=var1, **other_vars_dict)), 
 client_side=True) # This work for one file as it should...
 ...


 def shell_func():
 return dict(a='')


 # view
 # shell_func()
 div id=batch_div
 {{=LOAD('lotns', 'other_func_that_just_return_so_var_input', 
 extension='load', ajax=True, target='batch_div')}}
 !-- On submit of this view form_func_that_call_my_download_funcs() is 
 loaded below with web2py_component() --
 /div

 div id=form_func_that_call_my_download_funcs_div
 !-- form_func_that_call_my_download_funcs() loaded here with 
 web2py_component() --
 /div


 I try to change form_func_that_call_my_download_funcs() like this :

 def form_func_that_call_my_download_funcs():
 ...
 if form.process().accpet:
 ...
 response.js = $.get(url='http://127.0.0.1:
 8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678');
 response.js += $.get(url='http://127.0.0.1:
 8000/sgddms/label/download_func2?var1=2676var1=2673var1=2678'); # I 
 see the call passing in chrome dev tool both the files are not download??? 
 Try with $.post() too...
 ...


 # Here what look my download function, both are the same so I just show 
 the important thing in one of them...
 def download_func1():
 ...
 final = StringIO(final_wordml)
 response.headers['Content-Type'] = 'xml'
 response.headers['Content-Disposition'] = \
 'attachment;filename=filename123_%s.xml;' % 
 request.now.strftime('%Y-%m-%d_%H-%M-%S-%f')
 response.write(final.getvalue(), escape=False)
 raise HTTP(200, str(final.getvalue()), **response.headers)


 Thanks for any pointer!

 Richard

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py wikipedia article update translation

2014-03-18 Thread shapovalovdenis
Hi!

just stumbled across wikipedia article about web2py 
https://en.wikipedia.org/wiki/Web2py and besides it's a bit outdated, I've 
found that there is no russian version of web2py on wikipedia, so I've 
created new article and already translated about 70% of original english 
article.

If there are some other russian speakers in this group I welcome them to 
help and finish that article: https://ru.wikipedia.org/wiki/Web2py

Best,
DS

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] calling download function page by ajax

2014-03-18 Thread Limedrop
Posted to soon.  To clarify, the cookies need to be set in your download 
function:

  {{view}}
  
response.files.append(URL('static','jquery.fileDownload/jquery.fileDownload.js'))
  
  
  {{controller}}
  response.js = 
'$.fileDownload(http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678;);'
  response.js += 
'$.fileDownload(http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678;);'
  
  
  {{download_func1}}
  # these cookies are required by jQuery.fileDownload.js
  # to enable download via ajax
  response.cookies['fileDownload'] = 'true'
  response.cookies['fileDownload']['path'] = /



On Wednesday, March 19, 2014 6:18:11 PM UTC+13, Limedrop wrote:

 You might want to look at 
 http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/

 The only fiddly bit is to make sure you set the cookies correctly (see the 
 documentation for details).

 For example:

   {{view}}
   
 response.files.append(URL('static','js/jquery.fileDownload/jquery.fileDownload.js'))
   
   
   {{controller}}
   response.js = '$.fileDownload(
 http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678
 );'
   response.js += '$.fileDownload(
 http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676var1=2673var1=2678
 );'
   # these cookies are required by jQuery.fileDownload.js
   # to enable download via ajax
   response.cookies['fileDownload'] = 'true'
   response.cookies['fileDownload']['path'] = /








-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newby - what is (**dict(form.vars))

2014-03-18 Thread shapovalovdenis
hi! 
Don't worry it's pretty common question for newcomers :)

This is called Function Argument Packaging and Function Argument 
Unpackaging.

arguments could be packaged into list or dictionary:
* - position based arguments
** - name based arguments

 def f(*a, **b):
return a, b
 x, y = f(3, 'hello', c=4, test='world')
 print x
(3, 'hello')
 print y
{'c':4, 'test':'world'}

and vice versa, arguments could be extracted for functions


 def f(a, b):
return a + b
 c = (1, 2)
 print f(*c)
3

 def f(a, b):
return a + b
 c = {'a':1, 'b':2}
 print f(**c)
3






On Wednesday, March 19, 2014 7:06:31 AM UTC+2, Chops wrote:

 I am just learning Web2py

 I have an understanding of dict but now I find it used with two asterisks 
 before it and I can't seem to find an explanation!!

 Can it be used with anything other than a form? ((**dict(form.vars))?

 Can I use the two asterisks on other bits of code to server a common 
 purpose?

 Thanks in advance


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Newby - what is (**dict(form.vars))

2014-03-18 Thread Bruce Lamb
Wow!! this is a bit mind bending - it will take some processing time!!

Really appreciate your VERY useful and quick response.



On 19 March 2014 16:27, shapovalovde...@gmail.com wrote:

 hi!
 Don't worry it's pretty common question for newcomers :)

 This is called Function Argument Packaging and Function Argument
 Unpackaging.

 arguments could be packaged into list or dictionary:
 * - position based arguments
 ** - name based arguments

  def f(*a, **b):
 return a, b
  x, y = f(3, 'hello', c=4, test='world')
  print x
 (3, 'hello')
  print y
 {'c':4, 'test':'world'}

 and vice versa, arguments could be extracted for functions


  def f(a, b):
 return a + b
  c = (1, 2)
  print f(*c)
 3

  def f(a, b):
 return a + b
  c = {'a':1, 'b':2}
  print f(**c)
 3






 On Wednesday, March 19, 2014 7:06:31 AM UTC+2, Chops wrote:

 I am just learning Web2py

 I have an understanding of dict but now I find it used with two asterisks
 before it and I can't seem to find an explanation!!

 Can it be used with anything other than a form? ((**dict(form.vars))?

 Can I use the two asterisks on other bits of code to server a common
 purpose?

 Thanks in advance

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/VyouPnp0rPU/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.