Re: [web2py] pysimplesoap help

2014-03-17 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 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 "", line 1, in 
>   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] Re: Bootstrap3 package - help to test

2014-03-17 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.


[web2py] Re: Web2Py without Bootstrap

2014-03-17 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
>>
>> 
>> Link1
>> Link2
>> Link3
>> 
>>
>> 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-17 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.


Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread Tim Richardson
I use apache. I think while your results are precise and interesting, real 
world experience of site visitors is very different. nginx met the "10K" 
challenge: i.e., 1 simultaneous requests. That's the kind of load that 
gives Apache problems. But under lower loads, there are many other factors 
which influence performance from your visitor's point of view.


On Tuesday, 18 March 2014 13:19:11 UTC+11, 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.


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

2014-03-17 Thread Dan Kozlowski
I am getting the same result with a minimalist controller. The field 
still takes a date and updates. Do you think that is a bug or something 
that can not be done ?




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 
.

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: Python Performance Issue

2014-03-17 Thread horridohobbyist
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.


Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread horridohobbyist
I don't know if this is relevant, but in apache2.conf, there is a 
MaxClients parameter for the "prefork" MPM and it's set to 150. This is the 
default.

I changed it to 15, but it made no difference in the test.


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] What's the correct implementation of cache.action?

2014-03-17 Thread Lisandro
I've a news site on production running web2py (Version 
2.8.2-stable+timestamp.2013.11.28.13.54.07). The site is getting a lot of 
visits; major part of those visits go to the homepage. 
In order to optimize the site's homepage, my first step was to cache "the 
data". So I used selects with cacheable=True in conjunction with cache.ram. 
 This has helped to reduce considerably my server swap and disk I/O 
(because I'm running on VPS, shared resources).

However, my server is still using "too much" CPU for rendering the 
homepage. I think is the expected behaviour, as the data is retrieved from 
the cache, but actually web2py still has to render all that data into the 
html. So I was wondering if I could use @cache.action with 
cache_model=cache.ram, so that the html is rendered once every X 
seconds/minutes. Note that I want the html to be cached server-side, 
regardless browser-side caching.

I tried adding @cache.action(time_expire=300, 
cache_model=cache.ram, session=False, vars=True, public=True) to the 
controller function. However, I'm not sure the behaviour is the one I 
expect, so I have a couple of questions:

 - 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.

 - 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.

 - 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? 

Thanks in advance. Regards, Lisandro.

-- 
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-17 Thread Tim Richardson

(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.


Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread horridohobbyist
How or where do I locate the mod_wsgi settings? (I am the furthest thing 
from being an Apache expert as you can find.)

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.


Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread Tim Richardson


>
> 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: pysimplesoap help

2014-03-17 Thread Tim Richardson
you need to activate basic authentication.

auth.settings.allow_basic_login = True

usually do this in models/db.py

see 
https://do.growthpath.com.au/book/default/search/29?search=basic+authentication



On Tuesday, 18 March 2014 08:02:37 UTC+11, piero crisci 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 "", line 1, in 
>   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.


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

2014-03-17 Thread 黄祥
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 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: LDAP auth and user_groups

2014-03-17 Thread Massimo Di Pierro
I think it should create groups.

On Monday, 17 March 2014 11:34:30 UTC-5, Thomas Bellembois wrote:
>
> Hello, 
>
> Is there any way to use LDAP authentication for users and create user 
> groups ? 
>
> Apparently the get_or_create_user() method does not create them when the 
> user comes from LDAP. 
>
> Thanks, 
>
> Thomas 
>
>

-- 
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: Go to most recent topic post

2014-03-17 Thread Ruud Schroen
Nevermind, already did it. Was just some simple math ;)

On Saturday, March 15, 2014 2:49:50 PM UTC+1, Ruud Schroen wrote:
>
> I'm building a small forum for my website.
>
> In a topic, you will see 10 posts per page. Outside the topic, in the 
> forum overview, each topic will have a shortcut to the most recent post.
>
> How do i find out which page to redirect to (the page where the most 
> recent post is)?
>
>
> (there is another topic of mine, but please ignore it, something went 
> wrong)
>

-- 
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] SQLFORM to json

2014-03-17 Thread David Simmons
Hi 

I have a SQLFORM which I embed in my web page using LOAD. If I successfully 
save the data in the database I want to pass the saved data back as part 
response.js. The idea is that a user enters data via the SQLFORM, it is s 
saved to the db and the data returned to the client where I add it to a 
dynamically generated table.

In my controller I have:

def entry():
form = SQLFORM(db.timeline)

if form.process().accepted:
data = ??
response.js = "console.log(" + data + ")"

return dict(form=form)
 
Any idea how I get request.vars and convert them to json?

cheers

Dave

-- 
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-17 Thread Dan Kozlowski
I see what you are doing but still does not work. My code is below. Could I
have my code in the wrong location ?


def clients():
write_in_form = 'new' in request.args or 'edit' in request.args
if write_in_form:
 db.clients.add_date.writeable=False
##db.clients.add_date.readable=True
##db.clients.add_date.writeable=False
##db.history.editable = False,
##db.history.editable=False,

grid=SQLFORM.smartgrid(db.clients,
onupdate=updateclient,oncreate=createclient, user_signature=False, editable
= dict(clients=True, history=False), deletable = dict(clients=True,
history=False), create = dict(clients=True,
history=False),fields=[db.clients.client_name,db.clients.line_of_business,db.contacts.id_contact_type,db.contacts.contact_name,
db.history.client_id_dc,db.history.add_date,
db.history.encryption_type,db.history.out_filename])
return locals()


On Mon, Mar 17, 2014 at 4:16 PM, 黄祥  wrote:

> i'm sorry, my bad :
> # check if new or edit is in args (url)
> write_in_form = '*new*' in request.args or '*edit*' in request.args
>
> db.table_name.date_field_1.writeable = not write_in_form
> db.table_name.date_field_2.writeable = not write_in_form
>
> or another way around
> # check if new or edit is in args (url)
> write_in_form = '*new*' in request.args or '*edit*' in request.args
>
> if write_in_form :
> db.table_name.date_field_1.writeable = False
> db.table_name.date_field_2.writeable = False
>
> 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.
> 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: database callback return an error when using bulk_insert

2014-03-17 Thread 黄祥
any idea why this happens? or there is a limitation on bulk_insert and the 
database callback.

thanks and 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 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: Go to most recent topic post

2014-03-17 Thread 黄祥
hm, it's hard to tell without seeing your code. perhaps just some query and 
orderby id or date on table topic post will cover it up.

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 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-17 Thread 黄祥
i'm sorry, my bad :
# check if new or edit is in args (url)
write_in_form = '*new*' in request.args or '*edit*' in request.args

db.table_name.date_field_1.writeable = not write_in_form 
db.table_name.date_field_2.writeable = not write_in_form 

or another way around
# check if new or edit is in args (url)
write_in_form = '*new*' in request.args or '*edit*' in request.args

if write_in_form :
db.table_name.date_field_1.writeable = False 
db.table_name.date_field_2.writeable = False

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 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: How to use AJAX within a SQLFORM.grid 'add' form

2014-03-17 Thread backseat
Thanks Derek, but I don't think that's it. The example in the book doesn't 
define a view for 'echo', and even I do define one that explicitly calls 
the grid view, the problem persists (is there a view for just the Add 
form?).

-- 
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] pysimplesoap help

2014-03-17 Thread piero crisci
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 "", line 1, in 
  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.


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

2014-03-17 Thread Dan Kozlowski
This does not seem to work. Maybe I am asking wrong. I have 2 date 
fields that get updated from a batch process so I need to restrict them 
from input on the create and edit form.


Thanks


On 03/14/2014 10:11 PM, 黄祥 wrote:

i think you can achieve it using conditional for that.
e.g.
write_in_form = 'add' in request.args or 'edit' in request.args

db.clients.writeable = not write_in_form

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 
.

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: How to use AJAX within a SQLFORM.grid 'add' form

2014-03-17 Thread Derek
Chances are you didn't define a view for 'echo' so it's using a default. 

On Sunday, March 16, 2014 1:09:53 PM UTC-7, backseat wrote:
>
> Is it expected that AJAX can be used within the Add form of a 
> SQLFORM.grid? If so, what am I doing wrong (or is it a bug)?
>
> Thanks,
> Keith
>

-- 
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: Appadmin on 2.9.4

2014-03-17 Thread Niphlod
the core chapter is long, but full of gems :

http://web2py.com/books/default/chapter/29/04/the-core#Static-asset-management

On Saturday, March 15, 2014 9:58:10 PM UTC+1, SimonD wrote:
>
> Hi LightDot,
> Thanks for the info. I have a well thumbed printed 5th edition book and to 
> be honest, this is not too well documented in there. A quick look at the 
> 6th edition didn't help. But I will probe the 5th edition again.
> The reference I did find appears related to nginx, rather than Apache (I 
> did try to get nginx running but that's another tale...).
>
> To answer your questions. I took the lead from Massimo who proposed that 
> Chrome might highlight the non-found JS and CSS. I simply saw the missing 
> directories as referred to in the Chrome diags and populated those that 
> appeared missing.
> You rightly say that I maybe could have come to a different conclusion 
> about the actual cause of the issue. Sorry, I didn't - oops. I simply 
> thought the folders were missing. 
> response.static_version never came into my mind because I simply didn't 
> know about it (and I have been using web2py for quite a time, although I 
> confess to being more towards the noob end of the expertise spectrum).
>
> I had installed web2py using the script supplied. It worked right out of 
> the box, and so I thought that maybe the script had not created those 
> directories for some reason (like permissions).
> Now that I know of response.static_version, I will endeavour to learn 
> about it and deploy it properly.
>
> In summary, I really appreciate your, and all, information and hope that I 
> can find out about response.static_version. If there are specific pointer, 
> links or additional information you can supply, I will be, as always, very 
> grateful.
> Simon
>
>
> On Saturday, March 15, 2014 7:35:29 PM UTC, LightDot wrote:
>>
>> Btw, this seems to be one of the more elusive features of web2py, when it 
>> comes to finding information about it... @simonD, can I ask what did you 
>> first think when you saw _2.9.4 in the path, but no corresponding folder?
>>
>> Did you assume anything else besides a missing folder? Did you search the 
>> group for answers and if so, what keywords did you use?
>>
>> I'm trying to figure out how should web2py & it's documentation convey 
>> the information about this feature better...
>>
>> Regards
>>
>> On Saturday, March 15, 2014 8:12:22 PM UTC+1, LightDot wrote:
>>>
>>> Er... creating folders is NOT the solution. You don't have any folders 
>>> missing.
>>>
>>> The _2.9.4 comes from *virtual* static asset management. This number 
>>> will change now and then, as static files get updated, so please don't go 
>>> creating actual folders for this.
>>>
>>> Search the book and this group for response.static_version, it's been 
>>> explained several times.
>>>
>>> Regards
>>>
>>> On Saturday, March 15, 2014 7:12:18 PM UTC+1, SimonD wrote:

 Thanks to all other contributors. 
 Massimo nailed it, I think, with the proposal to use Chromes 
 diagnostics. I must get properly acquainted with Chrome...

 The core problem was: a folder missing under admin/static (called 
 _2.9.4). Although I think the other Apache config solution may have 
 worked, 
 creating the missing folder seemed the best course of action.

 For interest, this is the content of the missing folder.
 _2.9.4:
 css
 js
 plugin_multiselect
 plugin_statebutton

   _2.9.4/css:
   bootstrap_essentials.css
   bootstrap.min.css
   bootstrap-responsive.min.css
   calendar.css

   _2.9.4/js:
   calendar.js
   jquery.js
   web2py.js

   _2.9.4/plugin_multiselect:
   jquery.multi-select.js
   multi-select.css
   start.js

 _2.9.4/plugin_statebutton/css:
 bootstrap-switch.css

 _2.9.4/plugin_statebutton/js:
 bootstrap-switch.js

 Again, thanks to all.



 On Friday, March 14, 2014 4:28:51 PM UTC, Massimo Di Pierro wrote:
>
> Can you open the page with chrome? In the javascript console (under 
> network activity) it will tell you which files return a 404 error (if 
> any). 
> Then you can check if the files are there or not.
>
> On Friday, 14 March 2014 11:06:09 UTC-5, SimonD wrote:
>>
>> Thanks,
>> The vhost configs (I assuming that we are talking about 
>> sites-available/default ?), is as per the setup script as kindly 
>> included 
>> in web2py. It is unchanged apart from the installation directory (i.e. 
>> other than www-data). I have changed all references of www-data to a new 
>> directory name. I guess these all resolve OK, because the server works 
>> as 
>> expected in every other respect. I am pretty sure it is not a permission 
>> issue as they are the same across the whole directory.
>> It just looks like there is a missing CSS or JS or similar. The only 
>

[web2py] Re: Table design question - displaying descriptive text for integer field

2014-03-17 Thread Derek
Create a table for priority definitions, give them ids and labels... use 
represent on the priority field of the task table.

On Friday, March 14, 2014 4:53:27 PM UTC-7, Dan Why wrote:
>
>
> I am building a TODO-list type application while studying web2py. For each 
> task, I would like to set a priority. Having integer values for priority 
> makes it easier to query something like db(db.task.priority > 1).select(). 
> Because there will be only a few of them, I would just create some 
> constants for them (rather than creating a priority table). Also I would 
> like to show descriptive text rather than numbers on drop-down list. 
>
> My model looks something like this. 
>
> class Priority:
> LOW, MEDIUM, HIGH, URGENT = range(1, 5)
> set = {LOW: 'Low', MEDIUM: 'Medium', HIGH: 'High', URGENT: 'Urgent'} 
>
> db.define_table('task', Field('name'), Field('priority', 
> requires=IS_IN_SET(Priority.set, zero='Select on')))
>
> Everything works well, except that on the view it is kind of ugly to 
> display the priority text instead of numbers. The way I am doing is
>
> Priority:  {{= Priority.set[ int( task.priority ) ] }} 
>
> I envision that it would become uglier and harder to understand, where I 
> start adding more fields. I wonder if there's a better way to do this? I am 
> also open to go about other ways than doing a constant based approach. 
>
> Thanks a lot for your help! - Dan
>

-- 
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] Can the DAL produce pivot table query (for use with Google Charts Plugin)?

2014-03-17 Thread Michael Beller
I'm trying to create a query that produces a pivot table.  I have a Project 
and Project Status table.  Each Project has a Status reference field to a 
Project Status and a Manager reference field to an Auth User.

db.define_table('t_project_status',
Field('f_name', requires=IS_NOT_EMPTY(), label=T('Name')),
auth.signature)

db.define_table('t_project',
Field('f_name', requires=IS_NOT_EMPTY(), label=T('Name')),
Field('f_description', 'text', readable=False, label=T('Description')),
Field('f_manager', 'reference auth_user', label=T('Manager')),
Field('f_status', 'reference t_project_status', label=T('Status')),
auth.signature)

I would like a table that produces a row for every Manager and a column for 
every Status (which I can then display as a Bar Chart using Google Charts).

This query comes close to at least producing a normalized list, i.e., one 
row for each combination of Manager/Status in the Project table (but not an 
entry for a Status that doesn't exist for a particular Manager, I can't 
figure out how to add a 2nd constraint to the 'left' clause):

joinquery = ((db.t_project.f_status == db.t_project_status.id) &
(db.t_project.f_manager == db.auth_user.id))

data = db(joinquery).select(
db.auth_user.last_name,
db.t_project.f_status,
db.t_project_status.f_name,
db.t_project_status.id.count(),
groupby=(db.auth_user.id|db.t_project_status.id),
orderby=(db.auth_user.last_name|db.t_project_status.id),
left=db.auth_user.on(db.t_project.f_manager == db.auth_user.id),
)

I've started to look at itertools.groupby but was trying to find a DAL 
solution to create the pivot table.

I'm then using this code to create a table for Google Charts using the 
Google Charts Plugin but will need to modify once I get the pivot table 
working:

datalist = []
datalist.append(['Manager','Status','Count'])
for row in data:
datalist.append([row.auth_user.last_name or 'None', 
row.t_project.f_status or 'None', int(row[db.t_project_status.id.count()])])

-- 
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-17 Thread horridohobbyist
I don't know if bumping up the number of processors from 1 to 4 makes 
sense. I have a dual-core Mac mini. The VM may be doing something funny.

I changed to 2 processors and we're back to the 10x performance 
discrepancy. So whether it's 1 or 2 processors makes very little difference.

Apache:Elapsed time: 2.27643203735
Apache:Elapsed time: 6.1853530407
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.270731925964
Apache:Elapsed time: 0.80504989624
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.292776823044
Apache:Elapsed time: 0.856013059616
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.28355884552
Apache:Elapsed time: 0.832424879074
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.310907125473
Apache:Elapsed time: 0.810643911362
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.282160043716
Apache:Elapsed time: 0.809345960617
Apache:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0269491672516
Gunicorn:Elapsed time: 0.0727801322937
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0269680023193
Gunicorn:Elapsed time: 0.0745708942413
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0281398296356
Gunicorn:Elapsed time: 0.0747048854828
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0501861572266
Gunicorn:Elapsed time: 0.0854380130768
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0284719467163
Gunicorn:Elapsed time: 0.0778048038483
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.026153087616
Gunicorn:Elapsed time: 0.0714471340179
Gunicorn:Percentage fill: 60.0


On Monday, 17 March 2014 12:21:33 UTC-4, horridohobbyist wrote:
>
> I bumped up the number of processors from 1 to 4. Here are the results:
>
> Apache:Begin...
> Apache:Elapsed time: 2.31899785995
> Apache:Elapsed time: 6.31404495239
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.274327039719
> Apache:Elapsed time: 0.832695960999
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.277992010117
> Apache:Elapsed time: 0.875190019608
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.284713983536
> Apache:Elapsed time: 0.82108092308
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.289800882339
> Apache:Elapsed time: 0.850221157074
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.287453889847
> Apache:Elapsed time: 0.822550058365
> Apache:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 1.9300968647
> Gunicorn:Elapsed time: 5.28614592552
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.315547943115
> Gunicorn:Elapsed time: 0.944733142853
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.321009159088
> Gunicorn:Elapsed time: 0.95100903511
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.310179948807
> Gunicorn:Elapsed time: 0.930527925491
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.311529874802
> Gunicorn:Elapsed time: 0.939922809601
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.308799028397
> Gunicorn:Elapsed time: 0.932448863983
> Gunicorn:Percentage fill: 60.0
>
> WTF. Now, both Apache and Gunicorn are slow. *Equally slow!*
>
> I am befuddled. I think I'll go get stinking drunk...
>
>
> On Monday, 17 March 2014 11:58:07 UTC-4, Cliff Kachinske wrote:
>>
>> Apparently the number of cores is adjustable. Try this link.
>>
>>
>> http://download.parallels.com/desktop/v5/docs/en/Parallels_Desktop_Users_Guide/23076.htm
>>
>> On Monday, March 17, 2014 10:02:13 AM UTC-4, horridohobbyist wrote:
>>>
>>> Parallels VM running on a 2.5GHz dual-core Mac mini. I really don't know 
>>> what Parallels uses.
>>>
>>>
>>> On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:

 What kind of VM is this? What is the host platform? How many CPU cores? 
 Is VM using all the cores? The only thing I can think of is the GIL and 
 the 
 fact that multithreaded code in python gets slower and slower the more 
 cores I have. On my laptop, with two cores, I do not see any slow down. 
 Rocket preallocate a thread pool. The rationale is that it decreases the 
 latency time. Perhaps you can also try rocket in this way:

 web2py.py --minthreads=1 --maxthreads=1

 This will reduce the number of worker threads to 1. Rocket also runs a 
 background non-worker thread that monitors worker threads and kills them 
 if 
 they get stuck.

 On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:
>
> Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:
>
> Welcome: elapsed time: 0.0511929988861
> Welcome: elapsed time: 0.0024790763855
>

Re: [web2py] Python Performance Issue

2014-03-17 Thread Jonathan Lundell
On 17 Mar 2014, at 9:21 AM, horridohobbyist  wrote:
> WTF. Now, both Apache and Gunicorn are slow. Equally slow!
> 

I really think it'd simplify matters to reproduce this outside the context of a 
web server. If the problem is really the GIL, then all these environment are 
doing is using a web server to create some idle threads, which seems like 
overkill to me.

-- 
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

2014-03-17 Thread Ricardo Pedroso
On Thu, Mar 13, 2014 at 7:48 PM, horridohobbyist
wrote:

I have a rather peculiar Python performance issue with web2py. I'm using
> pyShipping 1.8a (from http://pydoc.net/Python/pyShipping/1.8a/). The
> standalone program from the command line works quickly. However, after I've
> incorporated the code into my web2py application, the same pyShipping code
> takes orders of magnitude longer to execute!!! How can this be?!
>
> I presume in both instances that "pre-compiled" code is being run.
>
>

I don't know if you already did (this thread is already too long to
follow), but can you pack a simple app that shows the problem?

-- 
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] LDAP auth and user_groups

2014-03-17 Thread Thomas Bellembois
I wanted to be sure that it is not an expected behavior.

gluon/tools.py (line 1958)

if user:
...
elif checks:
...

if self.user_group(user_id=user.id) is None:
user_id = user.id
if self.settings.create_user_groups:
group_id = self.add_group(
self.settings.create_user_groups % user)
self.add_membership(group_id, user_id)
if self.settings.everybody_group_id:
self.add_membership(self.settings.everybody_group_id, user_id)

This works for me, but may be it is now the best way to do it.

Thomas

Le lundi 17 mars 2014 à 12:58 -0400, Richard Vézina a écrit :
> You can fix it and propose a patch!!
> 
> 
> Richard
> 
> 
> On Mon, Mar 17, 2014 at 12:34 PM, Thomas Bellembois
>  wrote:
> Hello,
> 
> Is there any way to use LDAP authentication for users and
> create user
> groups ?
> 
> Apparently the get_or_create_user() method does not create
> them when the
> user comes from LDAP.
> 
> Thanks,
> 
> Thomas
> 
> --
> 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.


Re: [web2py] LDAP auth and user_groups

2014-03-17 Thread Richard Vézina
You can fix it and propose a patch!!

Richard


On Mon, Mar 17, 2014 at 12:34 PM, Thomas Bellembois <
thomas.bellemb...@gmail.com> wrote:

> Hello,
>
> Is there any way to use LDAP authentication for users and create user
> groups ?
>
> Apparently the get_or_create_user() method does not create them when the
> user comes from LDAP.
>
> Thanks,
>
> Thomas
>
> --
> 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] LDAP auth and user_groups

2014-03-17 Thread Thomas Bellembois
Hello,

Is there any way to use LDAP authentication for users and create user
groups ?

Apparently the get_or_create_user() method does not create them when the
user comes from LDAP.

Thanks,

Thomas

-- 
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-17 Thread horridohobbyist
I bumped up the number of processors from 1 to 4. Here are the results:

Apache:Begin...
Apache:Elapsed time: 2.31899785995
Apache:Elapsed time: 6.31404495239
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.274327039719
Apache:Elapsed time: 0.832695960999
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.277992010117
Apache:Elapsed time: 0.875190019608
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.284713983536
Apache:Elapsed time: 0.82108092308
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.289800882339
Apache:Elapsed time: 0.850221157074
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.287453889847
Apache:Elapsed time: 0.822550058365
Apache:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 1.9300968647
Gunicorn:Elapsed time: 5.28614592552
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.315547943115
Gunicorn:Elapsed time: 0.944733142853
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.321009159088
Gunicorn:Elapsed time: 0.95100903511
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.310179948807
Gunicorn:Elapsed time: 0.930527925491
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.311529874802
Gunicorn:Elapsed time: 0.939922809601
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.308799028397
Gunicorn:Elapsed time: 0.932448863983
Gunicorn:Percentage fill: 60.0

WTF. Now, both Apache and Gunicorn are slow. *Equally slow!*

I am befuddled. I think I'll go get stinking drunk...


On Monday, 17 March 2014 11:58:07 UTC-4, Cliff Kachinske wrote:
>
> Apparently the number of cores is adjustable. Try this link.
>
>
> http://download.parallels.com/desktop/v5/docs/en/Parallels_Desktop_Users_Guide/23076.htm
>
> On Monday, March 17, 2014 10:02:13 AM UTC-4, horridohobbyist wrote:
>>
>> Parallels VM running on a 2.5GHz dual-core Mac mini. I really don't know 
>> what Parallels uses.
>>
>>
>> On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:
>>>
>>> What kind of VM is this? What is the host platform? How many CPU cores? 
>>> Is VM using all the cores? The only thing I can think of is the GIL and the 
>>> fact that multithreaded code in python gets slower and slower the more 
>>> cores I have. On my laptop, with two cores, I do not see any slow down. 
>>> Rocket preallocate a thread pool. The rationale is that it decreases the 
>>> latency time. Perhaps you can also try rocket in this way:
>>>
>>> web2py.py --minthreads=1 --maxthreads=1
>>>
>>> This will reduce the number of worker threads to 1. Rocket also runs a 
>>> background non-worker thread that monitors worker threads and kills them if 
>>> they get stuck.
>>>
>>> On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:

 Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:

 Welcome: elapsed time: 0.0511929988861
 Welcome: elapsed time: 0.0024790763855
 Welcome: elapsed time: 0.00262713432312
 Welcome: elapsed time: 0.00224614143372
 Welcome: elapsed time: 0.00218415260315
 Welcome: elapsed time: 0.00213503837585

 Oddly enough, it's slightly faster! But still 37% slower than the 
 command line execution.

 I'd really, really, **really** like to know why the shipping code is 
 10x slower...


 On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote:
>
> Okay, I did the calculations test in my Linux VM using command line 
> (fred0), Flask (hello0), and web2py (Welcome).
>
> fred0: elapsed time: 0.00159001350403
>
> fred0: elapsed time: 0.0015709400177
>
> fred0: elapsed time: 0.00156021118164
>
> fred0: elapsed time: 0.0015971660614
>
> fred0: elapsed time: 0.0031584741
>
> hello0: elapsed time: 0.00271105766296
>
> hello0: elapsed time: 0.00213503837585
>
> hello0: elapsed time: 0.00195693969727
>
> hello0: elapsed time: 0.00224900245667
>
> hello0: elapsed time: 0.00205492973328
> Welcome: elapsed time: 0.0484869480133
>
> Welcome: elapsed time: 0.00296783447266
>
> Welcome: elapsed time: 0.00293898582458
>
> Welcome: elapsed time: 0.00300216674805
>
> Welcome: elapsed time: 0.00312614440918
>
> The Welcome discrepancy is just under 2x, not nearly as bad as 10x in 
> my shipping code.
>
>
> On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote:
>>
>> In order to isolate the problem one must take it in steps. This is a 
>> good test but you must first perform this test with the code you 
>> proposed 
>> before:
>>
>> def test():
>> t = time.time
>> start = t()
>> x = 0.0
>> for i in range(1,5000):
>> x += (float(i+10)*(i+25)+175.0)/3.14
>> debug("elapsed time: "+str(t()-s

Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread Massimo Di Pierro
very interesting. What is code being benchmarked here?
could you post your apache configuration?

On Monday, 17 March 2014 11:08:53 UTC-5, horridohobbyist wrote:
>
> Anyway, I ran the shipping code Welcome test with both Apache2 and 
> Gunicorn. Here are the results:
>
> Apache:Begin...
> Apache:Elapsed time: 0.28248500824
> Apache:Elapsed time: 0.805250167847
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.284092903137
> Apache:Elapsed time: 0.797535896301
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.266696929932
> Apache:Elapsed time: 0.793596029282
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.271706104279
> Apache:Elapsed time: 0.770045042038
> Apache:Percentage fill: 60.0
> Apache:Begin...
> Apache:Elapsed time: 0.26541185379
> Apache:Elapsed time: 0.798058986664
> Apache:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.0273849964142
> Gunicorn:Elapsed time: 0.0717470645905
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.0259709358215
> Gunicorn:Elapsed time: 0.0712919235229
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.0273978710175
> Gunicorn:Elapsed time: 0.0727338790894
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.0260291099548
> Gunicorn:Elapsed time: 0.0724799633026
> Gunicorn:Percentage fill: 60.0
> Gunicorn:Begin...
> Gunicorn:Elapsed time: 0.0249080657959
> Gunicorn:Elapsed time: 0.0711901187897
> Gunicorn:Percentage fill: 60.0
>
> There is no question that the fault lies with Apache.
>
>
> On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:
>>
>> What kind of VM is this? What is the host platform? How many CPU cores? 
>> Is VM using all the cores? The only thing I can think of is the GIL and the 
>> fact that multithreaded code in python gets slower and slower the more 
>> cores I have. On my laptop, with two cores, I do not see any slow down. 
>> Rocket preallocate a thread pool. The rationale is that it decreases the 
>> latency time. Perhaps you can also try rocket in this way:
>>
>> web2py.py --minthreads=1 --maxthreads=1
>>
>> This will reduce the number of worker threads to 1. Rocket also runs a 
>> background non-worker thread that monitors worker threads and kills them if 
>> they get stuck.
>>
>> On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:
>>>
>>> Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:
>>>
>>> Welcome: elapsed time: 0.0511929988861
>>> Welcome: elapsed time: 0.0024790763855
>>> Welcome: elapsed time: 0.00262713432312
>>> Welcome: elapsed time: 0.00224614143372
>>> Welcome: elapsed time: 0.00218415260315
>>> Welcome: elapsed time: 0.00213503837585
>>>
>>> Oddly enough, it's slightly faster! But still 37% slower than the 
>>> command line execution.
>>>
>>> I'd really, really, **really** like to know why the shipping code is 10x 
>>> slower...
>>>
>>>
>>> On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote:

 Okay, I did the calculations test in my Linux VM using command line 
 (fred0), Flask (hello0), and web2py (Welcome).

 fred0: elapsed time: 0.00159001350403

 fred0: elapsed time: 0.0015709400177

 fred0: elapsed time: 0.00156021118164

 fred0: elapsed time: 0.0015971660614

 fred0: elapsed time: 0.0031584741

 hello0: elapsed time: 0.00271105766296

 hello0: elapsed time: 0.00213503837585

 hello0: elapsed time: 0.00195693969727

 hello0: elapsed time: 0.00224900245667

 hello0: elapsed time: 0.00205492973328
 Welcome: elapsed time: 0.0484869480133

 Welcome: elapsed time: 0.00296783447266

 Welcome: elapsed time: 0.00293898582458

 Welcome: elapsed time: 0.00300216674805

 Welcome: elapsed time: 0.00312614440918

 The Welcome discrepancy is just under 2x, not nearly as bad as 10x in 
 my shipping code.


 On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote:
>
> In order to isolate the problem one must take it in steps. This is a 
> good test but you must first perform this test with the code you proposed 
> before:
>
> def test():
> t = time.time
> start = t()
> x = 0.0
> for i in range(1,5000):
> x += (float(i+10)*(i+25)+175.0)/3.14
> debug("elapsed time: "+str(t()-start))
> return
>
> I would like to know the results about this test code first.
>
> The other code you are using performs an import:
>
> from shippackage import Package
>
>
> Now that is something that is very different in web2py and flask for 
> example. In web2py the import is executed at every request (although it 
> should be cached by Python) while in flask it is executed only once.  
> This 
> should also not cause a performance d

[web2py] Re: Collpase folders view section

2014-03-17 Thread Massimo Di Pierro
Yes. simply you need to specify in controllers:

def index():
response.view = 'path-to-my-view/index.html'

where path is relative to the views folder.

On Monday, 17 March 2014 10:49:32 UTC-5, Annet wrote:
>
> I am working on templates for my application. I have a folder 'templates' 
> which contains
> a folder for every template, these folders contain 12 views per template. 
> With 5
> templates ready the view section of my application is cluttered by 60 
> views.
>
> To solve this problem I wonder whether it is possible to collapse the view 
> folders
> like the css, images and js folders in the static section are collapsed.
>
>
> Kind regards,
>
> Annet
>

-- 
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-17 Thread horridohobbyist
Anyway, I ran the shipping code Welcome test with both Apache2 and 
Gunicorn. Here are the results:

Apache:Begin...
Apache:Elapsed time: 0.28248500824
Apache:Elapsed time: 0.805250167847
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.284092903137
Apache:Elapsed time: 0.797535896301
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.266696929932
Apache:Elapsed time: 0.793596029282
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.271706104279
Apache:Elapsed time: 0.770045042038
Apache:Percentage fill: 60.0
Apache:Begin...
Apache:Elapsed time: 0.26541185379
Apache:Elapsed time: 0.798058986664
Apache:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0273849964142
Gunicorn:Elapsed time: 0.0717470645905
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0259709358215
Gunicorn:Elapsed time: 0.0712919235229
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0273978710175
Gunicorn:Elapsed time: 0.0727338790894
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0260291099548
Gunicorn:Elapsed time: 0.0724799633026
Gunicorn:Percentage fill: 60.0
Gunicorn:Begin...
Gunicorn:Elapsed time: 0.0249080657959
Gunicorn:Elapsed time: 0.0711901187897
Gunicorn:Percentage fill: 60.0

There is no question that the fault lies with Apache.


On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:
>
> What kind of VM is this? What is the host platform? How many CPU cores? Is 
> VM using all the cores? The only thing I can think of is the GIL and the 
> fact that multithreaded code in python gets slower and slower the more 
> cores I have. On my laptop, with two cores, I do not see any slow down. 
> Rocket preallocate a thread pool. The rationale is that it decreases the 
> latency time. Perhaps you can also try rocket in this way:
>
> web2py.py --minthreads=1 --maxthreads=1
>
> This will reduce the number of worker threads to 1. Rocket also runs a 
> background non-worker thread that monitors worker threads and kills them if 
> they get stuck.
>
> On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:
>>
>> Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:
>>
>> Welcome: elapsed time: 0.0511929988861
>> Welcome: elapsed time: 0.0024790763855
>> Welcome: elapsed time: 0.00262713432312
>> Welcome: elapsed time: 0.00224614143372
>> Welcome: elapsed time: 0.00218415260315
>> Welcome: elapsed time: 0.00213503837585
>>
>> Oddly enough, it's slightly faster! But still 37% slower than the command 
>> line execution.
>>
>> I'd really, really, **really** like to know why the shipping code is 10x 
>> slower...
>>
>>
>> On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote:
>>>
>>> Okay, I did the calculations test in my Linux VM using command line 
>>> (fred0), Flask (hello0), and web2py (Welcome).
>>>
>>> fred0: elapsed time: 0.00159001350403
>>>
>>> fred0: elapsed time: 0.0015709400177
>>>
>>> fred0: elapsed time: 0.00156021118164
>>>
>>> fred0: elapsed time: 0.0015971660614
>>>
>>> fred0: elapsed time: 0.0031584741
>>>
>>> hello0: elapsed time: 0.00271105766296
>>>
>>> hello0: elapsed time: 0.00213503837585
>>>
>>> hello0: elapsed time: 0.00195693969727
>>>
>>> hello0: elapsed time: 0.00224900245667
>>>
>>> hello0: elapsed time: 0.00205492973328
>>> Welcome: elapsed time: 0.0484869480133
>>>
>>> Welcome: elapsed time: 0.00296783447266
>>>
>>> Welcome: elapsed time: 0.00293898582458
>>>
>>> Welcome: elapsed time: 0.00300216674805
>>>
>>> Welcome: elapsed time: 0.00312614440918
>>>
>>> The Welcome discrepancy is just under 2x, not nearly as bad as 10x in my 
>>> shipping code.
>>>
>>>
>>> On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote:

 In order to isolate the problem one must take it in steps. This is a 
 good test but you must first perform this test with the code you proposed 
 before:

 def test():
 t = time.time
 start = t()
 x = 0.0
 for i in range(1,5000):
 x += (float(i+10)*(i+25)+175.0)/3.14
 debug("elapsed time: "+str(t()-start))
 return

 I would like to know the results about this test code first.

 The other code you are using performs an import:

 from shippackage import Package


 Now that is something that is very different in web2py and flask for 
 example. In web2py the import is executed at every request (although it 
 should be cached by Python) while in flask it is executed only once.  This 
 should also not cause a performance difference but it is a different test 
 than the one above.

 TLTR: we should test separately python code execution (which may be 
 affected by threading) and import statements (which may be affected by 
 web2py custom_import and/or module weird behavior).



 On Sunday, 16 March 2014 08:47:13 UTC-5, horridohobbyist wrote:

Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread Cliff Kachinske
Apparently the number of cores is adjustable. Try this link.

http://download.parallels.com/desktop/v5/docs/en/Parallels_Desktop_Users_Guide/23076.htm

On Monday, March 17, 2014 10:02:13 AM UTC-4, horridohobbyist wrote:
>
> Parallels VM running on a 2.5GHz dual-core Mac mini. I really don't know 
> what Parallels uses.
>
>
> On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:
>>
>> What kind of VM is this? What is the host platform? How many CPU cores? 
>> Is VM using all the cores? The only thing I can think of is the GIL and the 
>> fact that multithreaded code in python gets slower and slower the more 
>> cores I have. On my laptop, with two cores, I do not see any slow down. 
>> Rocket preallocate a thread pool. The rationale is that it decreases the 
>> latency time. Perhaps you can also try rocket in this way:
>>
>> web2py.py --minthreads=1 --maxthreads=1
>>
>> This will reduce the number of worker threads to 1. Rocket also runs a 
>> background non-worker thread that monitors worker threads and kills them if 
>> they get stuck.
>>
>> On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:
>>>
>>> Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:
>>>
>>> Welcome: elapsed time: 0.0511929988861
>>> Welcome: elapsed time: 0.0024790763855
>>> Welcome: elapsed time: 0.00262713432312
>>> Welcome: elapsed time: 0.00224614143372
>>> Welcome: elapsed time: 0.00218415260315
>>> Welcome: elapsed time: 0.00213503837585
>>>
>>> Oddly enough, it's slightly faster! But still 37% slower than the 
>>> command line execution.
>>>
>>> I'd really, really, **really** like to know why the shipping code is 10x 
>>> slower...
>>>
>>>
>>> On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote:

 Okay, I did the calculations test in my Linux VM using command line 
 (fred0), Flask (hello0), and web2py (Welcome).

 fred0: elapsed time: 0.00159001350403

 fred0: elapsed time: 0.0015709400177

 fred0: elapsed time: 0.00156021118164

 fred0: elapsed time: 0.0015971660614

 fred0: elapsed time: 0.0031584741

 hello0: elapsed time: 0.00271105766296

 hello0: elapsed time: 0.00213503837585

 hello0: elapsed time: 0.00195693969727

 hello0: elapsed time: 0.00224900245667

 hello0: elapsed time: 0.00205492973328
 Welcome: elapsed time: 0.0484869480133

 Welcome: elapsed time: 0.00296783447266

 Welcome: elapsed time: 0.00293898582458

 Welcome: elapsed time: 0.00300216674805

 Welcome: elapsed time: 0.00312614440918

 The Welcome discrepancy is just under 2x, not nearly as bad as 10x in 
 my shipping code.


 On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote:
>
> In order to isolate the problem one must take it in steps. This is a 
> good test but you must first perform this test with the code you proposed 
> before:
>
> def test():
> t = time.time
> start = t()
> x = 0.0
> for i in range(1,5000):
> x += (float(i+10)*(i+25)+175.0)/3.14
> debug("elapsed time: "+str(t()-start))
> return
>
> I would like to know the results about this test code first.
>
> The other code you are using performs an import:
>
> from shippackage import Package
>
>
> Now that is something that is very different in web2py and flask for 
> example. In web2py the import is executed at every request (although it 
> should be cached by Python) while in flask it is executed only once.  
> This 
> should also not cause a performance difference but it is a different test 
> than the one above.
>
> TLTR: we should test separately python code execution (which may be 
> affected by threading) and import statements (which may be affected by 
> web2py custom_import and/or module weird behavior).
>
>
>
> On Sunday, 16 March 2014 08:47:13 UTC-5, horridohobbyist wrote:
>>
>> I've conducted a test with Flask.
>>
>> fred.py is the command line program.
>> hello.py is the Flask program.
>> default.py is the Welcome controller.
>> testdata.txt is the test data.
>> shippackage.py is a required module.
>>
>> fred.py:
>> 0.024 second
>> 0.067 second
>>
>> hello.py:
>> 0.029 second
>> 0.073 second
>>
>> default.py:
>> 0.27 second
>> 0.78 second
>>
>> The Flask program is slightly slower than the command line. However, 
>> the Welcome app is about 10x slower!
>>
>> *Web2py is much, much slower than Flask.*
>>
>> I conducted the test in a Parallels VM running Ubuntu Server 12.04 
>> (1GB memory allocated). I have a 2.5GHz dual-core Mac mini with 8GB.
>>
>>
>> I can't quite figure out how to use gunicom.
>>
>>
>> On Saturday, 15 March 2014 23:41:49 UTC-4, horridoho

[web2py] Collpase folders view section

2014-03-17 Thread Annet
I am working on templates for my application. I have a folder 'templates' 
which contains
a folder for every template, these folders contain 12 views per template. 
With 5
templates ready the view section of my application is cluttered by 60 views.

To solve this problem I wonder whether it is possible to collapse the view 
folders
like the css, images and js folders in the static section are collapsed.


Kind regards,

Annet

-- 
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] How to automatically add referenced row during insert with SQLFORM.grid

2014-03-17 Thread Saifuddin Rangwala
I have 2 tables:

db.define_table('category',
Field('name', 'string'),
...
format='%(name)s'
)

db.define_table('idata',
Field('description', 'string'),
...
Field('category', db.category)
)

I using auto-complete widget like below to auto-complete category name:

db.idata.category.widget = SQLFORM.widgets.autocomplete(
 request, db.category.name, id_field=db.category.id, limitby=(0,10),
min_length=0)

I am using SQLFORM.grid on idata to get user input.

The category in the grid is free text with auto-complete and if the
category doesn't already exists, I would like to insert category before
idata in a single form submission that comes from grid.

Currently it will say "value not in database", until user added category
via separate form.

Tried to search around but didn't anything in this context.

Is there anyway I can achieve this?


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.


Re: [web2py] Re: Python Performance Issue

2014-03-17 Thread horridohobbyist
Parallels VM running on a 2.5GHz dual-core Mac mini. I really don't know 
what Parallels uses.


On Monday, 17 March 2014 00:05:58 UTC-4, Massimo Di Pierro wrote:
>
> What kind of VM is this? What is the host platform? How many CPU cores? Is 
> VM using all the cores? The only thing I can think of is the GIL and the 
> fact that multithreaded code in python gets slower and slower the more 
> cores I have. On my laptop, with two cores, I do not see any slow down. 
> Rocket preallocate a thread pool. The rationale is that it decreases the 
> latency time. Perhaps you can also try rocket in this way:
>
> web2py.py --minthreads=1 --maxthreads=1
>
> This will reduce the number of worker threads to 1. Rocket also runs a 
> background non-worker thread that monitors worker threads and kills them if 
> they get stuck.
>
> On Sunday, 16 March 2014 20:22:45 UTC-5, horridohobbyist wrote:
>>
>> Using gunicorn (Thanks, Massimo), I ran the full web2py Welcome code:
>>
>> Welcome: elapsed time: 0.0511929988861
>> Welcome: elapsed time: 0.0024790763855
>> Welcome: elapsed time: 0.00262713432312
>> Welcome: elapsed time: 0.00224614143372
>> Welcome: elapsed time: 0.00218415260315
>> Welcome: elapsed time: 0.00213503837585
>>
>> Oddly enough, it's slightly faster! But still 37% slower than the command 
>> line execution.
>>
>> I'd really, really, **really** like to know why the shipping code is 10x 
>> slower...
>>
>>
>> On Sunday, 16 March 2014 21:13:56 UTC-4, horridohobbyist wrote:
>>>
>>> Okay, I did the calculations test in my Linux VM using command line 
>>> (fred0), Flask (hello0), and web2py (Welcome).
>>>
>>> fred0: elapsed time: 0.00159001350403
>>>
>>> fred0: elapsed time: 0.0015709400177
>>>
>>> fred0: elapsed time: 0.00156021118164
>>>
>>> fred0: elapsed time: 0.0015971660614
>>>
>>> fred0: elapsed time: 0.0031584741
>>>
>>> hello0: elapsed time: 0.00271105766296
>>>
>>> hello0: elapsed time: 0.00213503837585
>>>
>>> hello0: elapsed time: 0.00195693969727
>>>
>>> hello0: elapsed time: 0.00224900245667
>>>
>>> hello0: elapsed time: 0.00205492973328
>>> Welcome: elapsed time: 0.0484869480133
>>>
>>> Welcome: elapsed time: 0.00296783447266
>>>
>>> Welcome: elapsed time: 0.00293898582458
>>>
>>> Welcome: elapsed time: 0.00300216674805
>>>
>>> Welcome: elapsed time: 0.00312614440918
>>>
>>> The Welcome discrepancy is just under 2x, not nearly as bad as 10x in my 
>>> shipping code.
>>>
>>>
>>> On Sunday, 16 March 2014 17:52:00 UTC-4, Massimo Di Pierro wrote:

 In order to isolate the problem one must take it in steps. This is a 
 good test but you must first perform this test with the code you proposed 
 before:

 def test():
 t = time.time
 start = t()
 x = 0.0
 for i in range(1,5000):
 x += (float(i+10)*(i+25)+175.0)/3.14
 debug("elapsed time: "+str(t()-start))
 return

 I would like to know the results about this test code first.

 The other code you are using performs an import:

 from shippackage import Package


 Now that is something that is very different in web2py and flask for 
 example. In web2py the import is executed at every request (although it 
 should be cached by Python) while in flask it is executed only once.  This 
 should also not cause a performance difference but it is a different test 
 than the one above.

 TLTR: we should test separately python code execution (which may be 
 affected by threading) and import statements (which may be affected by 
 web2py custom_import and/or module weird behavior).



 On Sunday, 16 March 2014 08:47:13 UTC-5, horridohobbyist wrote:
>
> I've conducted a test with Flask.
>
> fred.py is the command line program.
> hello.py is the Flask program.
> default.py is the Welcome controller.
> testdata.txt is the test data.
> shippackage.py is a required module.
>
> fred.py:
> 0.024 second
> 0.067 second
>
> hello.py:
> 0.029 second
> 0.073 second
>
> default.py:
> 0.27 second
> 0.78 second
>
> The Flask program is slightly slower than the command line. However, 
> the Welcome app is about 10x slower!
>
> *Web2py is much, much slower than Flask.*
>
> I conducted the test in a Parallels VM running Ubuntu Server 12.04 
> (1GB memory allocated). I have a 2.5GHz dual-core Mac mini with 8GB.
>
>
> I can't quite figure out how to use gunicom.
>
>
> On Saturday, 15 March 2014 23:41:49 UTC-4, horridohobbyist wrote:
>>
>> I'll see what I can do. It will take time for me to learn how to use 
>> another framework.
>>
>> As for trying a different web server, my (production) Linux server is 
>> intimately reliant on Apache. I'd have to learn how to use another web 
>> server, and then try it in my Linux VM.
>>
>>
>> On Saturday, 15 Marc

Re: [web2py] Pulling data every 30s for a ticker with web2py

2014-03-17 Thread António Ramos
does this help?

http://vimeo.com/27478796


2014-03-16 17:48 GMT+00:00 Martin :

> Hi all,
> Please could anyone help me out, I need to pull some data from some API
> (ex: https//xxx/aaa/ etc.) every 30s and then display the result in a ti
> cker
> How do I do this with Web2py + JavaScript ? I am new to web2py.
>
> 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.
>

-- 
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-17 Thread Michele Comitini
@Massiom, @hb

> python anyserver.py -s gunicorn -i 127.0.0.1 -p 8000

with the above just one worker is started, hence requests are serialized.



2014-03-17 1:03 GMT+01:00 Massimo Di Pierro :
> easy_install gunicorn
> cd web2py
> python anyserver.py -s gunicorn -i 127.0.0.1 -p 8000
>
> Anyway, you need to run a test that does not include "import Package first"
> Because definitively treats imports differently. That must be tested
> separately.
>
> Massimo
>
>
>
> On Sunday, 16 March 2014 15:31:17 UTC-5, horridohobbyist wrote:
>>
>> Well, I managed to get gunicorn working in a roundabout way. Here are my
>> findings for the fred.py/hello.py test:
>>
>> Elapsed time: 0.028
>> Elapsed time: 0.068
>>
>> Basically, it's as fast as the command line test!
>>
>> I'm not sure this tells us much. Is it Apache's fault? Is it web2py's
>> fault? The test is run without the full web2py scaffolding. I don't know how
>> to run web2py on gunicorn, unless someone can tell me.
>>
>>
>> On Sunday, 16 March 2014 16:21:00 UTC-4, Michele Comitini wrote:
>>>
>>> gunicorn instructions:
>>>
>>> $ pip install gunicorn
>>> $ cd 
>>> $ gunicorn -w 4 gluon.main:wsgibase
>>>
>>>
>>>
>>> 2014-03-16 14:47 GMT+01:00 horridohobbyist :
>>> > I've conducted a test with Flask.
>>> >
>>> > fred.py is the command line program.
>>> > hello.py is the Flask program.
>>> > default.py is the Welcome controller.
>>> > testdata.txt is the test data.
>>> > shippackage.py is a required module.
>>> >
>>> > fred.py:
>>> > 0.024 second
>>> > 0.067 second
>>> >
>>> > hello.py:
>>> > 0.029 second
>>> > 0.073 second
>>> >
>>> > default.py:
>>> > 0.27 second
>>> > 0.78 second
>>> >
>>> > The Flask program is slightly slower than the command line. However,
>>> > the
>>> > Welcome app is about 10x slower!
>>> >
>>> > Web2py is much, much slower than Flask.
>>> >
>>> > I conducted the test in a Parallels VM running Ubuntu Server 12.04 (1GB
>>> > memory allocated). I have a 2.5GHz dual-core Mac mini with 8GB.
>>> >
>>> >
>>> > I can't quite figure out how to use gunicom.
>>> >
>>> >
>>> > On Saturday, 15 March 2014 23:41:49 UTC-4, horridohobbyist wrote:
>>> >>
>>> >> I'll see what I can do. It will take time for me to learn how to use
>>> >> another framework.
>>> >>
>>> >> As for trying a different web server, my (production) Linux server is
>>> >> intimately reliant on Apache. I'd have to learn how to use another web
>>> >> server, and then try it in my Linux VM.
>>> >>
>>> >>
>>> >> On Saturday, 15 March 2014 22:45:27 UTC-4, Anthony wrote:
>>> >>>
>>> >>> Are you able to replicate the exact task in another web framework,
>>> >>> such
>>> >>> as Flask (with the same server setup)?
>>> >>>
>>> >>> On Saturday, March 15, 2014 10:34:56 PM UTC-4, horridohobbyist wrote:
>>> 
>>>  Well, putting back all my apps hasn't widened the discrepancy. So I
>>>  don't know why my previous web2py installation was so slow.
>>> 
>>>  While the Welcome app with the calculations test shows a 2x
>>>  discrepancy,
>>>  the original app that initiated this thread now shows a 13x
>>>  discrepancy
>>>  instead of 100x. That's certainly an improvement, but it's still too
>>>  slow.
>>> 
>>>  The size of the discrepancy depends on the code that is executed.
>>>  Clearly, what I'm doing in the original app (performing
>>>  permutations) is
>>>  more demanding than mere arithmetical operations. Hence, 13x vs 2x.
>>> 
>>>  I anxiously await any resolution to this performance issue, whether
>>>  it
>>>  be in WSGI or in web2py. I'll check in on this thread
>>>  periodically...
>>> 
>>> 
>>>  On Saturday, 15 March 2014 16:19:12 UTC-4, horridohobbyist wrote:
>>> >
>>> > Interestingly, now that I've got a fresh install of web2py with
>>> > only
>>> > the Welcome app, my Welcome vs command line test shows a consistent
>>> > 2x
>>> > discrepancy, just as you had observed.
>>> >
>>> > My next step is to gradually add back all the other apps I had in
>>> > web2py (I had 8 of them!) and see whether the discrepancy grows
>>> > with the
>>> > number of apps. That's the theory I'm working on.
>>> >
>>> > Yes, yes, I know, according to the Book, I shouldn't have so many
>>> > apps
>>> > installed in web2py. This apparently affects performance. But the
>>> > truth is,
>>> > most of those apps are hardly ever executed, so their existence
>>> > merely
>>> > represents a static overhead in web2py. In my mind, this shouldn't
>>> > widen the
>>> > discrepancy, but you never know.
>>> >
>>> >
>>> > On Saturday, 15 March 2014 11:19:06 UTC-4, Niphlod wrote:
>>> >>
>>> >> @mcm: you got me worried. Your test function was clocking a hell
>>> >> lower
>>> >> than the original script. But then I found out why; one order of
>>> >> magnitude
>>> >> less (5000 vs 5). Once that was corrected, you got the exact