[web2py] Re: Script for nginx/uWSGI/web2py install on Webfaction

2012-12-18 Thread HittingSmoke
So I've been thinking more and more about this over the past few days and 
I'm 99% sure that would just serve the static content in the same exact way 
it would otherwise (through uwsgi) just from the folder of the other app... 
Can you confirm that nginx is actually serving the static 
content separately?

On Monday, December 17, 2012 11:34:51 AM UTC-8, Neil wrote:
>
> What I've done for that is set up another webfaction application of type 
> "static" to server all the css, images, audio, videos, etc. That creates a 
> new folder, for example:
>
> /home/[USER]/webapps/static_web2py_myapp
>
> Then, in my web2py/applications/[my_app]/ folder, I put a symbolic link 
> called "static" to the above folder. Seems to do the trick.
>
> On Monday, December 17, 2012 7:17:35 PM UTC, HittingSmoke wrote:
>>
>> Bah, I actually asked a Webfaction staff member if this were possible and 
>> I was told no, that the frontend Nginx server could only be used on 
>> static/PHP sites.
>>
>> Now that I'm looking into it I'm seeing one major issue that without 
>> proper configuration of Nginx for web2py, it would be serving static files 
>> through uwsgi instead of directly though Nginx. That requires a special 
>> entry in nginx.conf. Would that not mean reduced performance and higher RAM 
>> usage from uwsgi?
>>
>> On Monday, December 17, 2012 4:32:21 AM UTC-8, Neil wrote:
>>>
>>> I'm also not a sysadmin, but I did go through the process of setting up 
>>> web2py on webfaction recently as well. I also found that script but it 
>>> seemed to be overly complicated. In particular, there is no need to 
>>> download, build & run nginx, as you can use webfaction's instance. If there 
>>> is an advantage to running your own I'd be curious to hear about it. 
>>> Simplified steps I followed:
>>>
>>> 1. download & build latest uwsgi
>>> 2. download & unpack latest web2py
>>> 3. set up a "custom app" using webfaction's control panel, taking note 
>>> of the port
>>> 4. run the uwsgi binary, specifying parameters in the command line. For 
>>> the socket parameter use 127.0.0.1 and the port webfaction assigned for 
>>> your custom app. There are a few other posts in this group about selecting 
>>> good uwsgi parameters so that you don't run out of memory (seems to be a 
>>> common pitfall on webfaction)
>>>
>>> Hope that's useful.
>>>
>>> Neil
>>>
>>>
>>> On Monday, December 17, 2012 6:53:31 AM UTC, HittingSmoke wrote:

 I've been learning web2py on Webfaction off and on for a while now. The 
 web2py install script on the Webfaction wiki is quite outdated and runs on 
 an Apache instance that can barely stay within the default memory limits 
 without serious tweaking. Responsiveness with web2py/apache out of the box 
 with the default install script is unimpressive as well.

 A while back I tried a lighttpd setup with web2py on Webfaction. The 
 memory usage went way down and responsiveness was better but the web 
 server 
 was quite unstable. I found myself having to restart it constantly and I 
 couldn't track down the cause of the breakages. After the host upped the 
 default RAM limit on CentOS6 systems to 256MB things got better as it made 
 Apache more manageable on custom installs but it still sucked overall.

 So I found an install script for nginx/uWSGI on the WF community 
 support 
 forumbut
  it was horribly outdated and had multiple issues pointed out in the 
 comments that went unfixed. I spent a couple hours today fixing the 
 ignored 
 errors, updating it to the latest nginx and uwsgi versions and fixing the 
 errors which that brought on. After getting it working my RAM usage has 
 decreased and responsiveness of my web2py apps has noticeably increased. I 
 figured I'd share the script for anyone interested.

 I'm not a sysadmin, more of a hobbyist so any critique of my server 
 configs here are greatly welcome. Please note that the comments are not 
 mine. I merely updated the parts of the script that were required for it 
 to 
 work. All else was left as-is.

 Also, if anyone with knowledge of XML-RPC want's to make an actual 
 Webfaction install 
 script for 
 nginx/uwsgi/web2py that would be awesome. It could be added to the script 
 wiki.

 #!/bin/sh


 # TODO's:
 # * find free port for communication for nginx and uwsgi
 # * test conjob creation properly


 echo 'Install script for nginx (1.2.6), uwsgi (1.4.3) and web2py 
 (latest stable)'
 echo 'If you wish to create cronjobs comment out the last lines of 
 this script'


 # port betweet nginx and uwsgi
 nginx_uwsgi_port=9001


 # Get web2py admin password
 echo "Web2py admin password:"
 read  web2p

[web2py] Re: web2py interactive shell in windows does not start the browser

2012-12-18 Thread Massimo Di Pierro
You cannot do what you ask because it not logically possible. There is no 
web2py global state. There is only a state per request for the duration of 
an http request.

When you open shell you are in a "simulated" http request which does not 
require the server to be on. It is mostly used to programmatically interact 
with the db.

Imagine your web server being hit by many requests at the same time. How 
would you select from the shell which one to interact with? Moreover each 
request lasts ~5ms.

Massimo



On Tuesday, 18 December 2012 22:16:33 UTC-6, Bhaskar Ramachandran wrote:
>
> Thanks for the reply. But then how do i do interactive debug of the web2py 
> objects from the shell...?
> If I can either have the shell or the webserver running, but not both, 
> then what if i want to run my application and then access the web2py 
> objects in real time from the shell to know its state. ?
> By the way, what makes it more interesting to learn web2py is this support 
> from others  Thanks a lot.
>
> Regards,
> Bhaskar
>
>
>
>
> On Sunday, December 16, 2012 9:06:30 PM UTC-6, Massimo Di Pierro wrote:
>>
>> As you say -S  starts the shell but not the web server. Without 
>> -S it starts the web server.
>> The reason is that you may want one without the other.
>>
>>
>> On Sunday, 16 December 2012 14:38:53 UTC-6, Bhaskar Ramachandran wrote:
>>>
>>> I am new to web2py but very excited to learn and use it on a long term 
>>> from now. 
>>> I am having trouble starting an interactive shell (I am using Windows 7 
>>> OS and have installed python2.5 and pywin32 but not ipython as i don't want 
>>> ipython shell). 
>>> I have the latest web2py source copied to C:\. 
>>>
>>> C:\web2py>python web2py.py -S welcome -M
>>> Sorry, -K only supported for python 2.6-2.7
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>> Version 2.3.1 (2012-12-14 15:24:12) stable
>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>>> PostgreSQL(pg8000), IMAP(imaplib)
>>> WARNING:web2py:import IPython error; use default python shell
>>> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit 
>>> (Intel)] on win32
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> (InteractiveConsole)
>>> >>>
>>>
>>> I get the shell but it does not start the browser. Even if i start the 
>>> browser and enter http://127.0.0.1:8000/welcome/default/index it 
>>> doesn't work.
>>> But if i try a non-interactive shell such as the following, i am able to 
>>> start the server and see the welcome page...
>>>
>>> C:\web2py>python web2py.py
>>> Sorry, -K only supported for python 2.6-2.7
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>> Version 2.3.1 (2012-12-14 15:24:12) stable
>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>>> PostgreSQL(pg8000), IMAP(imaplib)
>>> --
>>> I get the pop up window to enter admin password and start the server and 
>>> everything works except an interactive shell...
>>>
>>> Please help.
>>> Thank you
>>> Bhaskar
>>>
>>>
>>>
>>>
>>>
>>>

-- 





[web2py] Re: web2py interactive shell in windows does not start the browser

2012-12-18 Thread Bhaskar Ramachandran
Thanks for the reply. But then how do i do interactive debug of the web2py 
objects from the shell...?
If I can either have the shell or the webserver running, but not both, then 
what if i want to run my application and then access the web2py objects in 
real time from the shell to know its state. ?
By the way, what makes it more interesting to learn web2py is this support 
from others  Thanks a lot.

Regards,
Bhaskar




On Sunday, December 16, 2012 9:06:30 PM UTC-6, Massimo Di Pierro wrote:
>
> As you say -S  starts the shell but not the web server. Without 
> -S it starts the web server.
> The reason is that you may want one without the other.
>
>
> On Sunday, 16 December 2012 14:38:53 UTC-6, Bhaskar Ramachandran wrote:
>>
>> I am new to web2py but very excited to learn and use it on a long term 
>> from now. 
>> I am having trouble starting an interactive shell (I am using Windows 7 
>> OS and have installed python2.5 and pywin32 but not ipython as i don't want 
>> ipython shell). 
>> I have the latest web2py source copied to C:\. 
>>
>> C:\web2py>python web2py.py -S welcome -M
>> Sorry, -K only supported for python 2.6-2.7
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2012
>> Version 2.3.1 (2012-12-14 15:24:12) stable
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>> PostgreSQL(pg8000), IMAP(imaplib)
>> WARNING:web2py:import IPython error; use default python shell
>> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] 
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>>
>>
>> I get the shell but it does not start the browser. Even if i start the 
>> browser and enter http://127.0.0.1:8000/welcome/default/index it 
>> doesn't work.
>> But if i try a non-interactive shell such as the following, i am able to 
>> start the server and see the welcome page...
>>
>> C:\web2py>python web2py.py
>> Sorry, -K only supported for python 2.6-2.7
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2012
>> Version 2.3.1 (2012-12-14 15:24:12) stable
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>> PostgreSQL(pg8000), IMAP(imaplib)
>> --
>> I get the pop up window to enter admin password and start the server and 
>> everything works except an interactive shell...
>>
>> Please help.
>> Thank you
>> Bhaskar
>>
>>
>>
>>
>>
>>

-- 





[web2py] Customizing auth login form but unable to set the form class name

2012-12-18 Thread Bhaskar Ramachandran
As listed in the "view" code below, i am trying to customize the form 
returned by auth.login(). Note that i have in my controller "return 
dict(form=auth.login()). Then in the view code pasted below i am 
customizing the login form.
It seems to work fine except that i am unable to assign a class name to 
this form. So my question is " How to set the class name for a form object 
?. There are posts in the mailing list to specify class name for elements 
within the form object but i couldn't find one that explains how the class 
name for the form object itself can be assinged. 
Please let me know if my question needs more explanation. Thank you.
  {{
if not auth.is_logged_in() :
  if not 'register' in auth.settings.
actions_disabled:
   form.add_button(T('Register'),URL(args=
'register'),_class='btn')
   pass
   if not 'request_reset_password' in auth.
settings.actions_disabled:
 form.add_button(T('Lost Password'),URL(
args='request_reset_password'),_class='btn')
pass 
 }}

{{=form.custom.begin}}
   Sign Up
  
 

  
   
  Remember me
  Forgot? 

 
 {{=form.custom.end}}
   
 {{form.element('div').parent['_class']='navbar-form pull-right 
form-inline'}}

{{pass}}
  

-- 





[web2py] Re: Scheduler tasks stuck in ASSIGNED state

2012-12-18 Thread JimK
I'm not sure what the issue was but replacing the gluon/scheduler.py file 
with the older one fixed the problem.  There were a lot of changes in 2.3.2 
so it's hard to pinpoint what broke things.

On Tuesday, December 18, 2012 6:36:29 PM UTC-8, JimK wrote:
>
> There appears to be a major bug with the scheduler workers with 2.3.2 in 
> tasks are stuck in the ASSIGNED state if that worker group was not the 
> first one started.  This problem did not exist until I upgraded to 2.3.2 
> this morning.
>
> I have 2 task groups in my service (dir, metrics).  
>
> I start the workers after starting the server like so (art is the 
> application name):
> /usr/bin/python2.6 /var/www/web2py/web2py.py -K art:dir
> /usr/bin/python2.6 /var/www/web2py/web2py.py -K art:metrics
> /usr/bin/python2.6 /var/www/web2py/web2py.py -K art:rap
>
> If I start the "dir" worker first and the "metrics", my "dir" group tasks 
> complete fine but the "metrics" group tasks are stuck in the ASSIGNED state.
> To prove my theory, I then killed all of the workers and stared the 
> "metrics" worker first and then "dir" worker.  As hypothesized, the 
> "metrics" group tasks complete but the "dir" group tasks are stuck in the 
> ASSIGNED state.
>
> Any ideas???
>

-- 





[web2py] Scheduler tasks stuck in ASSIGNED state

2012-12-18 Thread JimK
There appears to be a major bug with the scheduler workers with 2.3.2 in 
tasks are stuck in the ASSIGNED state if that worker group was not the 
first one started.  This problem did not exist until I upgraded to 2.3.2 
this morning.

I have 2 task groups in my service (dir, metrics).  

I start the workers after starting the server like so (art is the 
application name):
/usr/bin/python2.6 /var/www/web2py/web2py.py -K art:dir
/usr/bin/python2.6 /var/www/web2py/web2py.py -K art:metrics
/usr/bin/python2.6 /var/www/web2py/web2py.py -K art:rap

If I start the "dir" worker first and the "metrics", my "dir" group tasks 
complete fine but the "metrics" group tasks are stuck in the ASSIGNED state.
To prove my theory, I then killed all of the workers and stared the 
"metrics" worker first and then "dir" worker.  As hypothesized, the 
"metrics" group tasks complete but the "dir" group tasks are stuck in the 
ASSIGNED state.

Any ideas???

-- 





[web2py] Re: Aren't we not able to translate SQLFORM.grid buttons?

2012-12-18 Thread Massimo Di Pierro
Yes, that was missing. I now added it.

On Tuesday, 18 December 2012 16:23:02 UTC-6, Tito Garrido wrote:
>
> Hi Folks!
>
> I am trying to find the 'Add' string on the translation file but I 
> couldn't find anything related to SQLFORM.grid to translate, is it expected?
>
> Thanks!
>
> Tito
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>  

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Massimo Di Pierro
I cannot think of any change in that respect. It could be a problem from 
caching js files after upgrade. Can you make sure you clear the firefox 
cache and try save again?

On Tuesday, 18 December 2012 18:31:01 UTC-6, Tito Garrido wrote:
>
> Also on 2.3.2 I am not able to save via web editor on firefox 10.0.11. And 
> I am able to save on 2.2.1
>
>
> On Tue, Dec 18, 2012 at 6:57 PM, Tito Garrido 
> > wrote:
>
>> I guess I have found a bug on 2.3.2 when I try to use database admin 
>> queries:
>> Ticket ID 
>>
>> 127.0.0.1.2012-12-18.18-56-07.412e0e88-61e7-472c-9e46-c8d1220cba9f
>>  name 'tb' is not defined Version  web2py™ (2, 
>> 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable')  Python Python 
>> 2.6.6: /usr/bin/python  Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>>
>>
>> Traceback (most recent call last
>> ):
>>   File "/home/titog/Documents/Projetos/web2py/gluon/restricted.py", line 
>> 212, in restricted
>>
>>
>>
>> exec ccode in environment
>>   File 
>> "/home/titog/Documents/Projetos/web2py/applications/loja/views/appadmin.html"
>>  , line 
>> 133, in 
>>
>>
>>
>> 
>> NameError: name 'tb' is not defined
>>
>>
>>
>>
>> On Tue, Dec 18, 2012 at 4:18 PM, Richard Vézina 
>> 
>> > wrote:
>>
>>> Forget that, I was pointing database on my dev machine postgres server, 
>>> for some reason, it was not working. I copy the db into local postgres 
>>> database and point on the same server instead of my old dev VM and it gone 
>>> away. Maybe issue with different version of software between Ubuntu 10.04 
>>> and 12.10. I don't know.
>>>
>>> Thanks
>>>
>>> Richard 
>>>
>>>
>>> On Tue, Dec 18, 2012 at 12:21 PM, Richard Vézina 
>>> 
>>> > wrote:
>>>
 Ok, thanks

 It must be my server... It seems to work fine with my dev machine.

 Richard


 On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
 massimo@gmail.com > wrote:

> Are other people having problems with psycopg2 and web2py 2.3.2? 
> Nothing should have changed in this respect. psycopg2 if available takes 
> precendence over pg8000 which has problems.
>
> Massimo
>
>
> On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:
>
>> Is there something different with psycopg2 under web2py 2.3.2 ?
>>
>> I get this error on a new server that I configure :
>>
>>  Failure to connect, tried 5 times: 
>> Traceback (most recent call last): File "/home/www-data/web2py/gluon/
>> **dal.py", line 6853, in __init__ self._adapter = 
>> ADAPTERS[self._dbname](kwargs) File "/home/www-data/web2py/gluon/
>> **dal.py", line 2493, in __init__ if do_connect: 
>> self.find_driver(adapter_args,**uri) File 
>> "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver 
>> raise RuntimeError("driver %s not available" % request_driver) 
>> RuntimeError: driver psycopg2 not available
>>
>> python-psycopg2 is installed
>>
>> For some reason I had to add apdater to my connection string like 
>> this :
>>
>> db=DAL('postgres:psycopg2:...)
>>
>> Because if I didn't not precise it, web2py seems to use pg8000 and I 
>> get this error with pg8000 :
>>
>>  invalid literal for int() with base 
>> 10: 'SELECT'
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in 
>> restricted
>> exec ccode in environment
>>   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py", 
>> line 121, in 
>> for r in db().select(db.dict_database.**table_name, 
>> db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
>>   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
>> return adapter.select(self.query,**fields,attributes)
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
>> return self._select_aux(sql,fields,**attributes)
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in 
>> _select_aux
>> rows = self._fetchall()
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in 
>> _fetchall
>> return self.cursor.fetchall()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line 
>> 246, in _fn
>> return fn(self, *args, **kwargs)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line 
>> 414, in fetchall
>> return tuple(self.cursor.iterate_**tuple())
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
>> line 76, in next
>> retval = self.func(self.obj)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
>> line 270, in read_tuple
>> return self._fetch()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
>> line 205, in _fetch
>

Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Massimo Di Pierro
This is not a 2.3.2 bug. This is a bug in a previous version in the 
appadmin.html file. Your app was probably created with a previous web2py 
version. copy the latest appadmin.py and appadmin.html from the new welcome 
into loja and your problem should go away.

On Tuesday, 18 December 2012 15:57:21 UTC-6, Tito Garrido wrote:
>
> I guess I have found a bug on 2.3.2 when I try to use database admin 
> queries:
> Ticket ID 
>
> 127.0.0.1.2012-12-18.18-56-07.412e0e88-61e7-472c-9e46-c8d1220cba9f
>  name 'tb' is not defined Version  web2py™ (2, 
> 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable')  Python Python 
> 2.6.6: /usr/bin/python  Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
>
> Traceback (most recent call last):
>   File "/home/titog/Documents/Projetos/web2py/gluon/restricted.py", line 212, 
> in restricted
>
>
> exec ccode in environment
>   File 
> "/home/titog/Documents/Projetos/web2py/applications/loja/views/appadmin.html" 
> , line 
> 133, in 
>
>
> 
> NameError: name 'tb' is not defined
>
>
>
>
> On Tue, Dec 18, 2012 at 4:18 PM, Richard Vézina 
> 
> > wrote:
>
>> Forget that, I was pointing database on my dev machine postgres server, 
>> for some reason, it was not working. I copy the db into local postgres 
>> database and point on the same server instead of my old dev VM and it gone 
>> away. Maybe issue with different version of software between Ubuntu 10.04 
>> and 12.10. I don't know.
>>
>> Thanks
>>
>> Richard 
>>
>>
>> On Tue, Dec 18, 2012 at 12:21 PM, Richard Vézina 
>> 
>> > wrote:
>>
>>> Ok, thanks
>>>
>>> It must be my server... It seems to work fine with my dev machine.
>>>
>>> Richard
>>>
>>>
>>> On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
>>> massimo@gmail.com > wrote:
>>>
 Are other people having problems with psycopg2 and web2py 2.3.2? 
 Nothing should have changed in this respect. psycopg2 if available takes 
 precendence over pg8000 which has problems.

 Massimo


 On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:

> Is there something different with psycopg2 under web2py 2.3.2 ?
>
> I get this error on a new server that I configure :
>
>  Failure to connect, tried 5 times: 
> Traceback (most recent call last): File "/home/www-data/web2py/gluon/*
> *dal.py", line 6853, in __init__ self._adapter = 
> ADAPTERS[self._dbname](kwargs) File "/home/www-data/web2py/gluon/*
> *dal.py", line 2493, in __init__ if do_connect: 
> self.find_driver(adapter_args,**uri) File 
> "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver 
> raise RuntimeError("driver %s not available" % request_driver) 
> RuntimeError: driver psycopg2 not available
>
> python-psycopg2 is installed
>
> For some reason I had to add apdater to my connection string like this 
> :
>
> db=DAL('postgres:psycopg2:...)
>
> Because if I didn't not precise it, web2py seems to use pg8000 and I 
> get this error with pg8000 :
>
>  invalid literal for int() with base 10: 
> 'SELECT'
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in 
> restricted
> exec ccode in environment
>   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py", 
> line 121, in 
> for r in db().select(db.dict_database.**table_name, 
> db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
>   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
> return adapter.select(self.query,**fields,attributes)
>   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
> return self._select_aux(sql,fields,**attributes)
>   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in 
> _select_aux
> rows = self._fetchall()
>   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in _fetchall
> return self.cursor.fetchall()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line 
> 246, in _fn
> return fn(self, *args, **kwargs)
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line 
> 414, in fetchall
> return tuple(self.cursor.iterate_**tuple())
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
> line 76, in next
> retval = self.func(self.obj)
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
> line 270, in read_tuple
> return self._fetch()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
> line 205, in _fetch
> self._fill_cache()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", 
> line 190, in _fill_cache
> end_of_data, rows = self.c.fetch_rows(self._**portal_name, 
> self.row_cache_size, self._ro

[web2py] Aren't we not able to translate SQLFORM.grid buttons?

2012-12-18 Thread Tito Garrido
Hi Folks!

I am trying to find the 'Add' string on the translation file but I couldn't
find anything related to SQLFORM.grid to translate, is it expected?

Thanks!

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] Re: Login manually

2012-12-18 Thread Wonton
Well, I've executed again these sentences and this is what I've got:

> python web2py.py -S dianaappv1 -M
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
WARNING:web2py:import IPython error; use default python shell
Python 2.7.1 (r271:86832, Aug  5 2011, 03:30:24) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> rows = db(db.auth_user).select(db.auth_user.password)
>>> print 'check:', any(r.passwords.startswith('|') for r in rows):
  File "", line 1
print 'check:', any(r.passwords.startswith('|') for r in rows):
  ^
SyntaxError: invalid syntax
>>> print 'check:', any(r.passwords.startswith('|') for r in rows)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
AttributeError: 'Row' object has no attribute 'passwords'
check: >>> 


El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro 
escribió:
>
> Can you please check something for me:
>
> python web2py.py -S yourappname -M
> >>> rows = db(db.auth_user).select(db.auth_user.password)
> >>> print 'check:', any(r.passwords.startswith('|') for r in rows):
>
> does it print check: true or check: false?
>
> Massimo
>
>
> On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote:
>>
>> Hi again Massimo!
>>
>> Since I've changed very few from the basic project I will paste my code 
>> here (sorry for my comments and variable names in Spanish, if you want I 
>> could translate the code) .
>>
>> This is my default.py file:
>>
>> servicios_publicos=Service()
>> servicios_privados=Service()
>>
>> def public_call(): 
>> return servicios_publicos()
>>
>> @auth.requires_login()
>> def private_call(): 
>> return servicios_privados()
>>
>> @servicios_publicos.json
>> def registra(usuario, email, password):
>> respuesta = {}
>> estado = 'OK'
>> mensaje = ''
>> tipoError = 0
>> #Comprueba si hay otro usuario con el mismo nombre
>> if db(db.auth_user.username == usuario).count() != 0:
>> estado = 'Error'
>> tipoError = 1
>> #Comprueba si hay otro usuario con el mismo email
>> if db(db.auth_user.email == email).count() != 0:
>> estado = 'Error'
>> tipoError = tipoError + 2
>> #Registrar
>> if estado == 'OK':
>> db.auth_user.insert(username=usuario, email=email, password=db.
>> auth_user.password.validate(password)) 
>> mensaje = 'El registro se ha realizado correctamente.'
>> else:
>> if tipoError == 1:
>> mensaje = 'El usuario ya existe.'
>> elif tipoError == 2:
>> mensaje = 'El email ya existe.'
>> else:
>> mensaje = 'El usuario y el email ya existen.'
>> respuesta['estado'] = estado
>> respuesta['mensaje'] = mensaje
>> return respuesta
>>
>> @servicios_publicos.json
>> def login(usuario, password):
>> respuesta = {}
>> user = auth.login_bare(usuario, password)
>> if not user:
>> respuesta['estado'] = 'Error'
>> respuesta['mensaje'] = 'Nombre de usuario o contraseña 
>> incorrecta'
>> else:
>> respuesta['estado'] = 'OK'
>> respuesta['mensaje'] = 'Login correcto'
>> return respuesta
>>
>>
>> And this is my db.py:
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite')
>> else:
>> ## connect to Google BigTable (optional 
>> 'google:datastore://namespace')
>> db = DAL('google:datastore')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>> ## or store session in Memcache, Redis, etc.
>> ## from gluon.contrib.memdb import MEMDB
>> ## from google.appengine.api.memcache import Client
>> ## session.connect(request, response, db = MEMDB(Client()))
>>
>> ## by default give a view/generic.extension to all actions from localhost
>> ## none otherwise. a pattern can be 'controller/function.extension'
>> response.generic_patterns = ['*'] if request.is_local else []
>> ## (optional) optimize handling of static files
>> # response.optimize_css = 'concat,minify,inline'
>> # response.optimize_js = 'concat,minify,inline'
>>
>> #
>> ## Here is sample code if you need for
>> ## - email capabilities
>> ## - authentication (registration, login, logout, ... )
>> ## - authorization (role based authorization)
>> ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
>> ## - old style crud actions
>> ## (more options discussed in gluon/tools.py)
>> #
>>
>> from gluon

[web2py] Re: Login manually

2012-12-18 Thread Wonton
Hi again Massimo!

I've tried this:

check: >>> print 'check:', any(r.password.startswith('|') for r in rows)
check: True

Hope this helps.

El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro 
escribió:
>
> Can you please check something for me:
>
> python web2py.py -S yourappname -M
> >>> rows = db(db.auth_user).select(db.auth_user.password)
> >>> print 'check:', any(r.passwords.startswith('|') for r in rows):
>
> does it print check: true or check: false?
>
> Massimo
>
>
> On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote:
>>
>> Hi again Massimo!
>>
>> Since I've changed very few from the basic project I will paste my code 
>> here (sorry for my comments and variable names in Spanish, if you want I 
>> could translate the code) .
>>
>> This is my default.py file:
>>
>> servicios_publicos=Service()
>> servicios_privados=Service()
>>
>> def public_call(): 
>> return servicios_publicos()
>>
>> @auth.requires_login()
>> def private_call(): 
>> return servicios_privados()
>>
>> @servicios_publicos.json
>> def registra(usuario, email, password):
>> respuesta = {}
>> estado = 'OK'
>> mensaje = ''
>> tipoError = 0
>> #Comprueba si hay otro usuario con el mismo nombre
>> if db(db.auth_user.username == usuario).count() != 0:
>> estado = 'Error'
>> tipoError = 1
>> #Comprueba si hay otro usuario con el mismo email
>> if db(db.auth_user.email == email).count() != 0:
>> estado = 'Error'
>> tipoError = tipoError + 2
>> #Registrar
>> if estado == 'OK':
>> db.auth_user.insert(username=usuario, email=email, password=db.
>> auth_user.password.validate(password)) 
>> mensaje = 'El registro se ha realizado correctamente.'
>> else:
>> if tipoError == 1:
>> mensaje = 'El usuario ya existe.'
>> elif tipoError == 2:
>> mensaje = 'El email ya existe.'
>> else:
>> mensaje = 'El usuario y el email ya existen.'
>> respuesta['estado'] = estado
>> respuesta['mensaje'] = mensaje
>> return respuesta
>>
>> @servicios_publicos.json
>> def login(usuario, password):
>> respuesta = {}
>> user = auth.login_bare(usuario, password)
>> if not user:
>> respuesta['estado'] = 'Error'
>> respuesta['mensaje'] = 'Nombre de usuario o contraseña 
>> incorrecta'
>> else:
>> respuesta['estado'] = 'OK'
>> respuesta['mensaje'] = 'Login correcto'
>> return respuesta
>>
>>
>> And this is my db.py:
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite')
>> else:
>> ## connect to Google BigTable (optional 
>> 'google:datastore://namespace')
>> db = DAL('google:datastore')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>> ## or store session in Memcache, Redis, etc.
>> ## from gluon.contrib.memdb import MEMDB
>> ## from google.appengine.api.memcache import Client
>> ## session.connect(request, response, db = MEMDB(Client()))
>>
>> ## by default give a view/generic.extension to all actions from localhost
>> ## none otherwise. a pattern can be 'controller/function.extension'
>> response.generic_patterns = ['*'] if request.is_local else []
>> ## (optional) optimize handling of static files
>> # response.optimize_css = 'concat,minify,inline'
>> # response.optimize_js = 'concat,minify,inline'
>>
>> #
>> ## Here is sample code if you need for
>> ## - email capabilities
>> ## - authentication (registration, login, logout, ... )
>> ## - authorization (role based authorization)
>> ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
>> ## - old style crud actions
>> ## (more options discussed in gluon/tools.py)
>> #
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=True, signature=False)
>>
>> ## configure email
>> mail = auth.settings.mailer
>> mail.settings.server = ''
>> mail.settings.sender = ''
>> mail.settings.login = ''
>>
>> ## configure auth policy
>> auth.settings.registration_requires_verification = False
>> auth.settings.registration_requires_approval = False
>> auth.settings.reset_password_requires_verification = True
>>
>> ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
>> ## register with janrain.com, write your domain:api_key in 
>> private/janrain.key
>> from gluon.contrib.login_methods.rpx_account import use_janrain
>> use_janrain(auth, filename='private/janrain.key')
>>
>> If it helps you, I'm using python 2.7.1 and I launch web2py with:
>> python web2py.p

[web2py] Re: Login manually

2012-12-18 Thread Wonton
It prints check: False

El martes, 18 de diciembre de 2012 20:55:06 UTC+1, Massimo Di Pierro 
escribió:
>
> Can you please check something for me:
>
> python web2py.py -S yourappname -M
> >>> rows = db(db.auth_user).select(db.auth_user.password)
> >>> print 'check:', any(r.passwords.startswith('|') for r in rows):
>
> does it print check: true or check: false?
>
> Massimo
>
>
> On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote:
>>
>> Hi again Massimo!
>>
>> Since I've changed very few from the basic project I will paste my code 
>> here (sorry for my comments and variable names in Spanish, if you want I 
>> could translate the code) .
>>
>> This is my default.py file:
>>
>> servicios_publicos=Service()
>> servicios_privados=Service()
>>
>> def public_call(): 
>> return servicios_publicos()
>>
>> @auth.requires_login()
>> def private_call(): 
>> return servicios_privados()
>>
>> @servicios_publicos.json
>> def registra(usuario, email, password):
>> respuesta = {}
>> estado = 'OK'
>> mensaje = ''
>> tipoError = 0
>> #Comprueba si hay otro usuario con el mismo nombre
>> if db(db.auth_user.username == usuario).count() != 0:
>> estado = 'Error'
>> tipoError = 1
>> #Comprueba si hay otro usuario con el mismo email
>> if db(db.auth_user.email == email).count() != 0:
>> estado = 'Error'
>> tipoError = tipoError + 2
>> #Registrar
>> if estado == 'OK':
>> db.auth_user.insert(username=usuario, email=email, password=db.
>> auth_user.password.validate(password)) 
>> mensaje = 'El registro se ha realizado correctamente.'
>> else:
>> if tipoError == 1:
>> mensaje = 'El usuario ya existe.'
>> elif tipoError == 2:
>> mensaje = 'El email ya existe.'
>> else:
>> mensaje = 'El usuario y el email ya existen.'
>> respuesta['estado'] = estado
>> respuesta['mensaje'] = mensaje
>> return respuesta
>>
>> @servicios_publicos.json
>> def login(usuario, password):
>> respuesta = {}
>> user = auth.login_bare(usuario, password)
>> if not user:
>> respuesta['estado'] = 'Error'
>> respuesta['mensaje'] = 'Nombre de usuario o contraseña 
>> incorrecta'
>> else:
>> respuesta['estado'] = 'OK'
>> respuesta['mensaje'] = 'Login correcto'
>> return respuesta
>>
>>
>> And this is my db.py:
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite')
>> else:
>> ## connect to Google BigTable (optional 
>> 'google:datastore://namespace')
>> db = DAL('google:datastore')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>> ## or store session in Memcache, Redis, etc.
>> ## from gluon.contrib.memdb import MEMDB
>> ## from google.appengine.api.memcache import Client
>> ## session.connect(request, response, db = MEMDB(Client()))
>>
>> ## by default give a view/generic.extension to all actions from localhost
>> ## none otherwise. a pattern can be 'controller/function.extension'
>> response.generic_patterns = ['*'] if request.is_local else []
>> ## (optional) optimize handling of static files
>> # response.optimize_css = 'concat,minify,inline'
>> # response.optimize_js = 'concat,minify,inline'
>>
>> #
>> ## Here is sample code if you need for
>> ## - email capabilities
>> ## - authentication (registration, login, logout, ... )
>> ## - authorization (role based authorization)
>> ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
>> ## - old style crud actions
>> ## (more options discussed in gluon/tools.py)
>> #
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=True, signature=False)
>>
>> ## configure email
>> mail = auth.settings.mailer
>> mail.settings.server = ''
>> mail.settings.sender = ''
>> mail.settings.login = ''
>>
>> ## configure auth policy
>> auth.settings.registration_requires_verification = False
>> auth.settings.registration_requires_approval = False
>> auth.settings.reset_password_requires_verification = True
>>
>> ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
>> ## register with janrain.com, write your domain:api_key in 
>> private/janrain.key
>> from gluon.contrib.login_methods.rpx_account import use_janrain
>> use_janrain(auth, filename='private/janrain.key')
>>
>> If it helps you, I'm using python 2.7.1 and I launch web2py with:
>> python web2py.py -c server.crt -k server.key
>> and this is the trace:
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql

Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Tito Garrido
Also on 2.3.2 I am not able to save via web editor on firefox 10.0.11. And
I am able to save on 2.2.1


On Tue, Dec 18, 2012 at 6:57 PM, Tito Garrido  wrote:

> I guess I have found a bug on 2.3.2 when I try to use database admin
> queries:
> Ticket ID
>
> 127.0.0.1.2012-12-18.18-56-07.412e0e88-61e7-472c-9e46-c8d1220cba9f
>  name 'tb' is not defined Version  web2py™ (2,
> 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable')  Python Python
> 2.6.6: /usr/bin/python  Traceback
>
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
>
>
> Traceback (most recent call last
> ):
>   File "/home/titog/Documents/Projetos/web2py/gluon/restricted.py", line 212, 
> in restricted
>
>
> exec ccode in environment
>   File 
> "/home/titog/Documents/Projetos/web2py/applications/loja/views/appadmin.html" 
> , line 
> 133, in 
>
>
> 
> NameError: name 'tb' is not defined
>
>
>
>
> On Tue, Dec 18, 2012 at 4:18 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Forget that, I was pointing database on my dev machine postgres server,
>> for some reason, it was not working. I copy the db into local postgres
>> database and point on the same server instead of my old dev VM and it gone
>> away. Maybe issue with different version of software between Ubuntu 10.04
>> and 12.10. I don't know.
>>
>> Thanks
>>
>> Richard
>>
>>
>> On Tue, Dec 18, 2012 at 12:21 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> Ok, thanks
>>>
>>> It must be my server... It seems to work fine with my dev machine.
>>>
>>> Richard
>>>
>>>
>>> On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Are other people having problems with psycopg2 and web2py 2.3.2?
 Nothing should have changed in this respect. psycopg2 if available takes
 precendence over pg8000 which has problems.

 Massimo


 On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:

> Is there something different with psycopg2 under web2py 2.3.2 ?
>
> I get this error on a new server that I configure :
>
>  Failure to connect, tried 5 times:
> Traceback (most recent call last): File "/home/www-data/web2py/gluon/*
> *dal.py", line 6853, in __init__ self._adapter =
> ADAPTERS[self._dbname](kwargs) File "/home/www-data/web2py/gluon/*
> *dal.py", line 2493, in __init__ if do_connect:
> self.find_driver(adapter_args,**uri) File
> "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver
> raise RuntimeError("driver %s not available" % request_driver)
> RuntimeError: driver psycopg2 not available
>
> python-psycopg2 is installed
>
> For some reason I had to add apdater to my connection string like this
> :
>
> db=DAL('postgres:psycopg2:...)
>
> Because if I didn't not precise it, web2py seems to use pg8000 and I
> get this error with pg8000 :
>
>  invalid literal for int() with base 10:
> 'SELECT'
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in
> restricted
> exec ccode in environment
>   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py",
> line 121, in 
> for r in db().select(db.dict_database.**table_name,
> db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
>   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
> return adapter.select(self.query,**fields,attributes)
>   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
> return self._select_aux(sql,fields,**attributes)
>   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in
> _select_aux
> rows = self._fetchall()
>   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in _fetchall
> return self.cursor.fetchall()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
> 246, in _fn
> return fn(self, *args, **kwargs)
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
> 414, in fetchall
> return tuple(self.cursor.iterate_**tuple())
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
> line 76, in next
> retval = self.func(self.obj)
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
> line 270, in read_tuple
> return self._fetch()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
> line 205, in _fetch
> self._fill_cache()
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
> line 190, in _fill_cache
> end_of_data, rows = self.c.fetch_rows(self._**portal_name,
> self.row_cache_size, self._row_desc)
>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py",
> line 943, in _fn
> return fn(self, *args, **kwarg

Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2012-12-18 Thread Arnon Marcus
Hey guys, I'm also using web2py and redmine, and was concidering moving it 
into a linux-based VM and running it with nginx. Good to know your on it. 
Keep up the good work - I'm a neub in linux-land...

Couple of questions:
1. Are you using postgreSQL in this thing?
2. How can one replicate your achievement ones it works?
3. I saw that BitNami has an ubuntu image of RedMine with MySQL with 
optionally choosing nginex as the web-server, and also a PostgreSQL plugin 
for these stacks (they also have a "Redmine on Postgres" stack, if I 
remember, but I think that combination doesn't exist for the ubuntu-image 
flavor, oddly enough...). Can that be used as a base for your configuration 
for integrating web2py support on-top of it?

On Tuesday, December 18, 2012 6:23:18 AM UTC-8, Richard wrote:
>
> I will, when I finish my research.
>
> I am planning to write a slice about deployment of Redmine beside Web2py 
> with Nginx. So until I finish my Nginx config in case I found other tweaks, 
> I wait for testing the script again. But I have a fresh VM in place that I 
> can clone rapidly to for testing purpose, so when I am ready, it will not 
> be a big task.
>
> :)
>
> Richard
>
> On Tue, Dec 18, 2012 at 4:17 AM, Niphlod  >wrote:
>
>> At this point I did a bit of research.
>>
>> https://github.com/ioerror/duraconf/blob/master/configs/nginx/nginx.conf
>>
>> updated the script to reflect those, but I can't test it. Can you please ?
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: DB insert confusion

2012-12-18 Thread Niphlod
ok, let's try to not make any further confusion. Let's agree on what web2py 
needs to provide and how to call it.
First things first: gluon.contrib.simplejsonrpc supports only 1.1, so 
*only*positional arguments sent as lists.
jsonrpclib instead supports 2.0 spec, so *both* positional arguments sent 
as lists and keyword arguments sent as dicts.

Second thing: it's hard to follow some example if the example is never 
going to work :P

data = db(db.t_test.ALL).select() 
return dict(data=data)

will go on exception no matter what.
data = db().select(db.t_test.ALL)
return dict(data=data)

works as intended.

Third: decorated functions usually need to have arguments.
can we set on a 
@service.jsonrpc
def testlist(arg1, arg2):
data = db().select(db.t_test.ALL)
return dict(data=data, arg=arg1, arg2=arg2)
? Right!

Now, I think with a simple patch we can escape the "pass parameters as a 
mapping or as a list" problem in gluon/tools.py
if isinstance(params, dict):
s = methods[method](**params)
elif isinstance(params, list):
s = methods[method](*params)

That should restore functionality for who calls functions only with 
"positional" style, while retaining the "keywords" style feature. This 
means that using contrib.simplejsonrpc you'll be able to call

s.testlist(1,2)

but not

s.testlist(arg1=1, arg2=2)


NB: This is just because simplejsonrpc adheres only to the 1.1 spec

With jsonrpclib, however, both will work ok (yeah!)

If this is fine, we can further fine-tune responses (e.g. 'version': '2.0' 
instead of 'version': '1.1') or having 2 separate @service decorators as 
Jonathan suggested.

Do we have a deal ?

-- 





[web2py] Re: Is it still possible to hide reference tables in a smartgrid in the 2.3.2 release of web2py?

2012-12-18 Thread Jim S
+1

On Tuesday, December 18, 2012 4:15:54 PM UTC-6, Niphlod wrote:
>
> Not an heavy user of smartgrid, but the "way to go" in my pov is by 
> default show all referenced tables. If someone needs to limit those, use 
> the linked_tables argument (i.e. full flexibility)
>
> On Tuesday, December 18, 2012 8:45:50 PM UTC+1, Massimo Di Pierro wrote:
>>
>> This deserves a discussion. It can go both ways. The bahavior was changed 
>> because of this thread 
>>
>> https://groups.google.com/forum/#!topic/web2py/EKz3FJc6ZPY
>> and this ticket:
>>
>> http://code.google.com/p/web2py/issues/detail?id=1160&can=1&q=readable%20%3D%20True
>>
>> This can go both ways. I do not think there is right or wrong. We just 
>> cannot keep changing it.
>> The grid was labelled as experimental therefore it was ok to fix it.
>>
>> You can always change the behavior by specifying the 
>> grid(...linked_tables=[...]).
>>
>> I am open to discussion. I would like to hear more opinions before this 
>> closed. Anybody?
>>
>> Massimo
>>
>>
>> On Tuesday, 18 December 2012 13:29:20 UTC-6, dev.ld...@gmail.com wrote:
>>>
>>> Since upgrading to release 2.3.2 of web2py my smartgrid code for 
>>> managing users is showing more reference table buttons that I designed.  
>>> After some investigation I see that changes to fix issue #1160 are causing 
>>> the issue.  I have reverted the changes to the sqlhtml.py file to return my 
>>> code to working order.  I want to show the reference button for 
>>> auth_membership but don't care to see buttons for the links to 
>>> auth_membership.created_by and auth_membership.modified_by.  Is there a way 
>>> to hide these buttons with the new version.
>>>
>>> I believe the code as it originally was is the correct implementation 
>>> and the manual code should be updated to add the following cod
>>>
>>> @auth.requires_membership('manager')
>>> def manage():
>>> db.comment.image_id.readable = True
>>> grid = SQLFORM.smartgrid(db.image)
>>> return dict(grid=grid)
>>>
>>> What do others think?
>>>
>>> Dan
>>>
>>>

-- 





[web2py] Re: Is it still possible to hide reference tables in a smartgrid in the 2.3.2 release of web2py?

2012-12-18 Thread Niphlod
Not an heavy user of smartgrid, but the "way to go" in my pov is by default 
show all referenced tables. If someone needs to limit those, use the 
linked_tables argument (i.e. full flexibility)

On Tuesday, December 18, 2012 8:45:50 PM UTC+1, Massimo Di Pierro wrote:
>
> This deserves a discussion. It can go both ways. The bahavior was changed 
> because of this thread 
>
> https://groups.google.com/forum/#!topic/web2py/EKz3FJc6ZPY
> and this ticket:
>
> http://code.google.com/p/web2py/issues/detail?id=1160&can=1&q=readable%20%3D%20True
>
> This can go both ways. I do not think there is right or wrong. We just 
> cannot keep changing it.
> The grid was labelled as experimental therefore it was ok to fix it.
>
> You can always change the behavior by specifying the 
> grid(...linked_tables=[...]).
>
> I am open to discussion. I would like to hear more opinions before this 
> closed. Anybody?
>
> Massimo
>
>
> On Tuesday, 18 December 2012 13:29:20 UTC-6, dev.ld...@gmail.com wrote:
>>
>> Since upgrading to release 2.3.2 of web2py my smartgrid code for managing 
>> users is showing more reference table buttons that I designed.  After some 
>> investigation I see that changes to fix issue #1160 are causing the issue.  
>> I have reverted the changes to the sqlhtml.py file to return my code to 
>> working order.  I want to show the reference button for auth_membership but 
>> don't care to see buttons for the links to auth_membership.created_by and 
>> auth_membership.modified_by.  Is there a way to hide these buttons with the 
>> new version.
>>
>> I believe the code as it originally was is the correct implementation and 
>> the manual code should be updated to add the following cod
>>
>> @auth.requires_membership('manager')
>> def manage():
>> db.comment.image_id.readable = True
>> grid = SQLFORM.smartgrid(db.image)
>> return dict(grid=grid)
>>
>> What do others think?
>>
>> Dan
>>
>>

-- 





[web2py] Re: custom forms can be annoying/confusing...

2012-12-18 Thread Niphlod
you must create widgets that support the placeholder attribute if you want 
to use form.custom.widget 

custom forms help you to place labels, comments, error messages and input 
fields within the page, but the "max granularity" (aka the greater detail 
level) of form.custom.widget.field is a ready-to-be-used INPUT (or SELECT, 
etc).

Don't know if it's the best english way to explain, but you are trying to 
have a custom placeholder attribute *within* form.custom.field.widget, vs 
something *around*  it.

However, given that form.custom.widget.field is just an INPUT(), it can be 
customized as always acting on its keywords

def test():
form = SQLFORM.factory(Field('test'))
return dict(form=form)

{{extend 'layout.html'}}
Original form
{{=form}}
Custom form
{{=form.custom.begin}}
{{wdg = form.custom.widget.test}}
{{wdg['_placeholder'] = 'hello world'}}
ready? go! {{=wdg}}
{{=form.custom.end}}




On Tuesday, December 18, 2012 10:31:35 PM UTC+1, encompass wrote:
>
> I am trying to use existing theme classes and other attributes but can't, 
> for the life of me, figure out how to properly do it.
> He is what I have in HTML, and if someone can tell me how to do with with 
> SQLFORM or SQLFORM.factory, I would greatly appreciate it.
> I tried just doing the inputs with .custom and couldn't get that to work 
> with things like placeholder attributes and so forth. :/  Horrible baffled 
> as the documentation wasn't clear enough there on how to make it happen.
> I would like to do as much of this stuff in the view as this is view 
> stuff.  I think it's weird to be formating in the model if we can put it in 
> the view instead.
>
> I have this as my code in normal HTML5:
>
> 
> 
>  type="text" placeholder="Enter site url">
> 
>
> 
>  type="text" placeholder="Your email">
> 
> 
> Send me the 
> results!
> 
> 
>
> BR,
> Jason Brower (the confused.)
>
>

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Tito Garrido
I guess I have found a bug on 2.3.2 when I try to use database admin
queries:
Ticket ID

127.0.0.1.2012-12-18.18-56-07.412e0e88-61e7-472c-9e46-c8d1220cba9f
 name 'tb' is not defined Version  web2py™ (2,
3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable')  Python Python
2.6.6: /usr/bin/python  Traceback


1.
2.
3.
4.
5.
6.
7.


Traceback (most recent call last):
  File "/home/titog/Documents/Projetos/web2py/gluon/restricted.py",
line 212, in restricted

exec ccode in environment
  File 
"/home/titog/Documents/Projetos/web2py/applications/loja/views/appadmin.html"
,
line 133, in 


NameError: name 'tb' is not defined




On Tue, Dec 18, 2012 at 4:18 PM, Richard Vézina  wrote:

> Forget that, I was pointing database on my dev machine postgres server,
> for some reason, it was not working. I copy the db into local postgres
> database and point on the same server instead of my old dev VM and it gone
> away. Maybe issue with different version of software between Ubuntu 10.04
> and 12.10. I don't know.
>
> Thanks
>
> Richard
>
>
> On Tue, Dec 18, 2012 at 12:21 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Ok, thanks
>>
>> It must be my server... It seems to work fine with my dev machine.
>>
>> Richard
>>
>>
>> On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Are other people having problems with psycopg2 and web2py 2.3.2? Nothing
>>> should have changed in this respect. psycopg2 if available takes
>>> precendence over pg8000 which has problems.
>>>
>>> Massimo
>>>
>>>
>>> On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:
>>>
 Is there something different with psycopg2 under web2py 2.3.2 ?

 I get this error on a new server that I configure :

  Failure to connect, tried 5 times:
 Traceback (most recent call last): File 
 "/home/www-data/web2py/gluon/**dal.py",
 line 6853, in __init__ self._adapter = ADAPTERS[self._dbname](kwargs)
 File "/home/www-data/web2py/gluon/**dal.py", line 2493, in __init__ if
 do_connect: self.find_driver(adapter_args,**uri) File
 "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver raise
 RuntimeError("driver %s not available" % request_driver) RuntimeError:
 driver psycopg2 not available

 python-psycopg2 is installed

 For some reason I had to add apdater to my connection string like this :

 db=DAL('postgres:psycopg2:...)

 Because if I didn't not precise it, web2py seems to use pg8000 and I
 get this error with pg8000 :

  invalid literal for int() with base 10:
 'SELECT'

 Traceback (most recent call last):
   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in
 restricted
 exec ccode in environment
   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py",
 line 121, in 
 for r in db().select(db.dict_database.**table_name,
 db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
 return adapter.select(self.query,**fields,attributes)
   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
 return self._select_aux(sql,fields,**attributes)
   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in
 _select_aux
 rows = self._fetchall()
   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in _fetchall
 return self.cursor.fetchall()
   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
 246, in _fn
 return fn(self, *args, **kwargs)
   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
 414, in fetchall
 return tuple(self.cursor.iterate_**tuple())
   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
 line 76, in next
 retval = self.func(self.obj)
   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
 line 270, in read_tuple
 return self._fetch()
   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
 line 205, in _fetch
 self._fill_cache()
   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
 line 190, in _fill_cache
 end_of_data, rows = self.c.fetch_rows(self._**portal_name,
 self.row_cache_size, self._row_desc)
   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py",
 line 943, in _fn
 return fn(self, *args, **kwargs)
   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py",
 line 1249, in fetch_rows
 retval = reader.handle_messages()
   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py",
 line 906, in handle_messages
 msg = self._conn._read_message()
   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py",

[web2py] custom forms can be annoying/confusing...

2012-12-18 Thread Jason Brower
I am trying to use existing theme classes and other attributes but can't, for 
the life of me, figure out how to properly do it.
He is what I have in HTML, and if someone can tell me how to do with with 
SQLFORM or SQLFORM.factory, I would greatly appreciate it.
I tried just doing the inputs with .custom and couldn't get that to work with 
things like placeholder attributes and so forth. :/  Horrible baffled as the 
documentation wasn't clear enough there on how to make it happen.
I would like to do as much of this stuff in the view as this is view stuff.  I 
think it's weird to be formating in the model if we can put it in the view 
instead.

I have this as my code in normal HTML5:










Send me 
the results!



BR,
Jason Brower (the confused.)

-- 





[web2py] Re: Firewalls, restrictions and appending to two tables

2012-12-18 Thread LightDot
Please post the exact code you use to connect to a database (hide the 
username / password, of course). Someone will perhaps be able to offer a 
workaround if you give us at least some information... Perhaps you're 
connecting to a database remotely without any reason..?

Basically, you're getting no answers about your firewall problems because 
there is no answer to this. Firewalls are designed to stop people from 
accessing things they shouldn't. ;) So, disable the firewall, it's as 
simple as that. If you're not allowed to... well, then your problem is not 
something this group can solve. Talk to people responsible... I know, it's 
a pain. :) But think of it this way, security policies are there for a 
reason, even if they might seem annoying.

Regards,
Ales


On Tuesday, December 18, 2012 7:57:00 PM UTC+1, Seelife wrote:
>
> Hi Ron, thanks for that info.  We thought as much. It seems its the 
> firewall that is causing us so many problems. We can run our apps with no 
> problems on machines with fewer restrictions. Apart from modifying the 
> firewall rights (hard to do), any suggestions to work around them other 
> than placing the apps and running as a pure python from Unix etc (also hard 
> for us to arrange).
>
>
> On Tuesday, December 18, 2012 4:24:58 PM UTC+1, Ron McOuat wrote:
>>
>>
>> The error traceback is saying the connection to the database could not be 
>> opened. The problem should be in the model file that has
>>
>> db=DAL(.), 
>>
>> the first parameter is the connection information. If the database is on 
>> another machine and a firewall is in the way you won't have any ability to 
>> connect. If you can't work out what is wrong on that line then post the 
>> model file.
>>
>

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread Vinicius Assef
What was the problem? How did you solve it?



On Tue, Dec 18, 2012 at 3:19 PM, António Ramos  wrote:
> Done.thank you.
>
> 2012/12/18 Vinicius Assef 
>>
>> Well, if you started your app based on welcome app in Web2py 2.2.1 you
>> should have your default layout.html view linking bootstrap css.
>>
>>
>> On Tue, Dec 18, 2012 at 12:56 PM, António Ramos 
>> wrote:
>> > 2.2.1!
>> > windows version
>> >
>> > 2012/12/18 Vinicius Assef 
>> >>
>> >> What version are you using?
>> >>
>> >> Bootstrap came in version 2.0.1
>> >>
>> >>
>> >>
>> >> On Tue, Dec 18, 2012 at 12:12 PM, António Ramos 
>> >> wrote:
>> >> > I dont see it in my app static folder nor through web inspection...
>> >> >
>> >> > Where is it?
>> >> >
>> >> > 2012/12/18 Vinicius Assef 
>> >> >>
>> >> >> It's already embedded.
>> >> >>
>> >> >> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos
>> >> >> 
>> >> >> wrote:
>> >> >> > Hello, just a simple question
>> >> >> > how do i use twitter bootstrap with web2py?
>> >> >> > thank you
>> >> >> > António
>> >> >> >
>> >> >> >
>> >> >> > 2012/12/18 LightDot 
>> >> >> >>
>> >> >> >> Looks nice. There are also:
>> >> >> >>
>> >> >> >> http://bootswatchr.com/
>> >> >> >> and
>> >> >> >> http://bootswatcher.com/
>> >> >> >>
>> >> >> >> Names are similar, but they're not related. The latter allows you
>> >> >> >> to
>> >> >> >> start
>> >> >> >> with an existing Bootswatch theme and go from there.
>> >> >> >>
>> >> >> >> Regards,
>> >> >> >> Ales
>> >> >> >>
>> >> >> >>
>> >> >> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro
>> >> >> >> wrote:
>> >> >> >>>
>> >> >> >>> http://www.boottheme.com/#generatetheme
>> >> >> >>
>> >> >> >> --
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >>
>> >>
>> >>
>> >
>> > --
>> >
>> >
>> >
>>
>> --
>>
>>
>>
>
> --
>
>
>

-- 





[web2py] Re: Using contrib.webclient to test JSONRPC interfaces

2012-12-18 Thread Massimo Di Pierro
I opened an issue about this:
http://code.google.com/p/web2py/issues/detail?id=1233&thanks=1233&ts=1355860665

On Tuesday, 18 December 2012 03:36:55 UTC-6, Daniel Gonzalez wrote:
>
> Indeed Massimo, that is the file.
>
> Some comments:
>
>- I am forcing Content-Type to 'application/json-rpc' in WebClient.post
>- The data must be already json encoded
>- The opener.addheaders is still used, but since I am using 
>a urllib2.Request (to *really* force the Content-Type, which can not be 
>done with addheaders, as you can see in the previously linked 
> StackOverflow 
>question), I would say the headers set with addheaders are not really 
>active.
>- That means self.detault_headers are probably not used
>- for jsonrpc post I have disabled form processing
>- and last but not least, my changes are based on 2.0.2. I assume no 
>big changes have been done for the WebClient since then, but I have not 
>verified.
>
> I am not sure what are the implicactions of all these changes. Maybe some 
> corrections are in order.
>
> On Tuesday, December 18, 2012 4:27:26 AM UTC+1, Massimo Di Pierro wrote:
>>
>>  you point me to the file? Is it this one?
>>
>>
>> https://github.com/gonvaled/web2py/blob/webclient_add_jsonrpc/gluon/contrib/webclient.py
>>
>>
>> On Monday, 17 December 2012 14:01:18 UTC-6, Daniel Gonzalez wrote:
>>>
>>> I have slightly modified the WebClient to support jsonrpc. I am not sure 
>>> everything is correctly covered, but it is suiting my needs.
>>>
>>> In case you are interested, you can see the changes here:
>>>
>>> https://github.com/gonvaled/web2py/tree/webclient_add_jsonrpc
>>>
>>> The biggest problem I had was 
>>> that opener.addheaders.append((key,str(value))) is not working as (I) 
>>> expected: the content-type is not rewritten:
>>>
>>> http://stackoverflow.com/questions/13920211/not-possible-to-set-content-type-to-application-json-using-urllib2
>>>
>>> On Monday, December 17, 2012 6:38:30 PM UTC+1, Daniel Gonzalez wrote:

 Hi,

 I am trying to understand how to use the included WebClient to test a 
 JSONRPC interface. One showstopper for me at the moment is that I see the 
 following in WebClient.post:

 # time the POST request
 data = urllib.urlencode(data)
 t0 = time.time()
 self.response = opener.open(self.url,data)
 self.time = time.time()-t0

 When doing JSONRPC accesses I do not want the data to be urlencoded. 
 Actually, I will prepare the data with json.dump, and I want WebClient to 
 POST it transparently (I guess this goes in the body of the POST request). 
 Is this at all possible? Is there an example of WebClient usage 
 for JSONRPC interfaces somewhere?

 Thanks,
 Daniel Gonzalez

>>>

-- 





[web2py] Re: Login manually

2012-12-18 Thread Massimo Di Pierro
Can you please check something for me:

python web2py.py -S yourappname -M
>>> rows = db(db.auth_user).select(db.auth_user.password)
>>> print 'check:', any(r.passwords.startswith('|') for r in rows):

does it print check: true or check: false?

Massimo


On Tuesday, 18 December 2012 13:40:41 UTC-6, Wonton wrote:
>
> Hi again Massimo!
>
> Since I've changed very few from the basic project I will paste my code 
> here (sorry for my comments and variable names in Spanish, if you want I 
> could translate the code) .
>
> This is my default.py file:
>
> servicios_publicos=Service()
> servicios_privados=Service()
>
> def public_call(): 
> return servicios_publicos()
>
> @auth.requires_login()
> def private_call(): 
> return servicios_privados()
>
> @servicios_publicos.json
> def registra(usuario, email, password):
> respuesta = {}
> estado = 'OK'
> mensaje = ''
> tipoError = 0
> #Comprueba si hay otro usuario con el mismo nombre
> if db(db.auth_user.username == usuario).count() != 0:
> estado = 'Error'
> tipoError = 1
> #Comprueba si hay otro usuario con el mismo email
> if db(db.auth_user.email == email).count() != 0:
> estado = 'Error'
> tipoError = tipoError + 2
> #Registrar
> if estado == 'OK':
> db.auth_user.insert(username=usuario, email=email, password=db.
> auth_user.password.validate(password)) 
> mensaje = 'El registro se ha realizado correctamente.'
> else:
> if tipoError == 1:
> mensaje = 'El usuario ya existe.'
> elif tipoError == 2:
> mensaje = 'El email ya existe.'
> else:
> mensaje = 'El usuario y el email ya existen.'
> respuesta['estado'] = estado
> respuesta['mensaje'] = mensaje
> return respuesta
>
> @servicios_publicos.json
> def login(usuario, password):
> respuesta = {}
> user = auth.login_bare(usuario, password)
> if not user:
> respuesta['estado'] = 'Error'
> respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta'
> else:
> respuesta['estado'] = 'OK'
> respuesta['mensaje'] = 'Login correcto'
> return respuesta
>
>
> And this is my db.py:
>
> if not request.env.web2py_runtime_gae:
> ## if NOT running on Google App Engine use SQLite or other DB
> db = DAL('sqlite://storage.sqlite')
> else:
> ## connect to Google BigTable (optional 
> 'google:datastore://namespace')
> db = DAL('google:datastore')
> ## store sessions and tickets there
> session.connect(request, response, db=db)
> ## or store session in Memcache, Redis, etc.
> ## from gluon.contrib.memdb import MEMDB
> ## from google.appengine.api.memcache import Client
> ## session.connect(request, response, db = MEMDB(Client()))
>
> ## by default give a view/generic.extension to all actions from localhost
> ## none otherwise. a pattern can be 'controller/function.extension'
> response.generic_patterns = ['*'] if request.is_local else []
> ## (optional) optimize handling of static files
> # response.optimize_css = 'concat,minify,inline'
> # response.optimize_js = 'concat,minify,inline'
>
> #
> ## Here is sample code if you need for
> ## - email capabilities
> ## - authentication (registration, login, logout, ... )
> ## - authorization (role based authorization)
> ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
> ## - old style crud actions
> ## (more options discussed in gluon/tools.py)
> #
>
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=True, signature=False)
>
> ## configure email
> mail = auth.settings.mailer
> mail.settings.server = ''
> mail.settings.sender = ''
> mail.settings.login = ''
>
> ## configure auth policy
> auth.settings.registration_requires_verification = False
> auth.settings.registration_requires_approval = False
> auth.settings.reset_password_requires_verification = True
>
> ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
> ## register with janrain.com, write your domain:api_key in 
> private/janrain.key
> from gluon.contrib.login_methods.rpx_account import use_janrain
> use_janrain(auth, filename='private/janrain.key')
>
> If it helps you, I'm using python 2.7.1 and I launch web2py with:
> python web2py.py -c server.crt -k server.key
> and this is the trace:
> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
> PostgreSQL(pg8000), IMAP(imaplib)
>
> El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro 
> escribió:
>>
>> Can I see you models? Are you changing the validator for 
>> db.auth_user.password?
>> Your error says:
>>
>>  unsupport

[web2py] Re: Login manually

2012-12-18 Thread Wonton
Hi again Massimo!

Since I've changed very few from the basic project I will paste my code 
here (sorry for my comments and variable names in Spanish, if you want I 
could translate the code) .

This is my default.py file:

servicios_publicos=Service()
servicios_privados=Service()

def public_call(): 
return servicios_publicos()

@auth.requires_login()
def private_call(): 
return servicios_privados()

@servicios_publicos.json
def registra(usuario, email, password):
respuesta = {}
estado = 'OK'
mensaje = ''
tipoError = 0
#Comprueba si hay otro usuario con el mismo nombre
if db(db.auth_user.username == usuario).count() != 0:
estado = 'Error'
tipoError = 1
#Comprueba si hay otro usuario con el mismo email
if db(db.auth_user.email == email).count() != 0:
estado = 'Error'
tipoError = tipoError + 2
#Registrar
if estado == 'OK':
db.auth_user.insert(username=usuario, email=email, password=db.
auth_user.password.validate(password)) 
mensaje = 'El registro se ha realizado correctamente.'
else:
if tipoError == 1:
mensaje = 'El usuario ya existe.'
elif tipoError == 2:
mensaje = 'El email ya existe.'
else:
mensaje = 'El usuario y el email ya existen.'
respuesta['estado'] = estado
respuesta['mensaje'] = mensaje
return respuesta

@servicios_publicos.json
def login(usuario, password):
respuesta = {}
user = auth.login_bare(usuario, password)
if not user:
respuesta['estado'] = 'Error'
respuesta['mensaje'] = 'Nombre de usuario o contraseña incorrecta'
else:
respuesta['estado'] = 'OK'
respuesta['mensaje'] = 'Login correcto'
return respuesta


And this is my db.py:

if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL('sqlite://storage.sqlite')
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore')
## store sessions and tickets there
session.connect(request, response, db=db)
## or store session in Memcache, Redis, etc.
## from gluon.contrib.memdb import MEMDB
## from google.appengine.api.memcache import Client
## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=False)

## configure email
mail = auth.settings.mailer
mail.settings.server = ''
mail.settings.sender = ''
mail.settings.login = ''

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in 
private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth, filename='private/janrain.key')

If it helps you, I'm using python 2.7.1 and I launch web2py with:
python web2py.py -c server.crt -k server.key
and this is the trace:
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)

El martes, 18 de diciembre de 2012 18:11:51 UTC+1, Massimo Di Pierro 
escribió:
>
> Can I see you models? Are you changing the validator for 
> db.auth_user.password?
> Your error says:
>
>  unsupported hash type 
> |pbkdf2(1000,20,sha512)
>
> I do not understand where | in  |pbkdf2 would come from.
>
>
> On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote:
>>
>> Hi Massimo!!
>>
>> I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last 
>> week.
>>
>> El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro 
>> escribió:
>>>
>>> Which web2py version? The error suggests you are using an older web2py 
>>> version with newly created database of records.
>>>
>>> Massimo
>>>
>>> On Monday, 17 December 2012 14:59:02 

[web2py] upload from Edit page

2012-12-18 Thread ArNew
Hi Everyone,

I need help urgently.

In my application, I am have included upload fields in Create and edit 
page. Through create page, it was very straight forward with:
{{=form.custom.widget.attachment}} (View)
Field('attachment','upload',uploadfolder=os.path.join(request.folder, 
'attachments')) (DAL). 
if form.vars.attachment:
form.vars.attachment_name = request.vars.attachment.filename
id = 
thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
 
.(Controller) And this works great.

That with Edit page is not the same, as it is not about editing the current 
image, but uploading more attachments. So I tried doing something like this:

 (view)
if request.vars.attachment != '':
form.vars.attachment = request.vars.attachment.file
filename = request.vars.attachment.filename
form.vars.attachment_name = filename
id = 
thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
This follows the very similar procedure of saving the encrypted version of 
attachment name in the attachment field, but it changes the extension to 
.txt for all the attachments. It saves the attachment as 
service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.txt 
where as the orginal attachment is photo.JPG. So ideall it should save it 
as  service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.JPG. 

Can anyone please help me with this?





-- 





[web2py] Re: Is it still possible to hide reference tables in a smartgrid in the 2.3.2 release of web2py?

2012-12-18 Thread Massimo Di Pierro
This deserves a discussion. It can go both ways. The bahavior was changed 
because of this thread 

https://groups.google.com/forum/#!topic/web2py/EKz3FJc6ZPY
and this ticket:
http://code.google.com/p/web2py/issues/detail?id=1160&can=1&q=readable%20%3D%20True

This can go both ways. I do not think there is right or wrong. We just 
cannot keep changing it.
The grid was labelled as experimental therefore it was ok to fix it.

You can always change the behavior by specifying the 
grid(...linked_tables=[...]).

I am open to discussion. I would like to hear more opinions before this 
closed. Anybody?

Massimo


On Tuesday, 18 December 2012 13:29:20 UTC-6, dev.ld...@gmail.com wrote:
>
> Since upgrading to release 2.3.2 of web2py my smartgrid code for managing 
> users is showing more reference table buttons that I designed.  After some 
> investigation I see that changes to fix issue #1160 are causing the issue.  
> I have reverted the changes to the sqlhtml.py file to return my code to 
> working order.  I want to show the reference button for auth_membership but 
> don't care to see buttons for the links to auth_membership.created_by and 
> auth_membership.modified_by.  Is there a way to hide these buttons with the 
> new version.
>
> I believe the code as it originally was is the correct implementation and 
> the manual code should be updated to add the following cod
>
> @auth.requires_membership('manager')
> def manage():
> db.comment.image_id.readable = True
> grid = SQLFORM.smartgrid(db.image)
> return dict(grid=grid)
>
> What do others think?
>
> Dan
>
>

-- 





[web2py] Is it still possible to hide reference tables in a smartgrid in the 2.3.2 release of web2py?

2012-12-18 Thread dev . ldhughes
Since upgrading to release 2.3.2 of web2py my smartgrid code for managing 
users is showing more reference table buttons that I designed.  After some 
investigation I see that changes to fix issue #1160 are causing the issue.  
I have reverted the changes to the sqlhtml.py file to return my code to 
working order.  I want to show the reference button for auth_membership but 
don't care to see buttons for the links to auth_membership.created_by and 
auth_membership.modified_by.  Is there a way to hide these buttons with the 
new version.

I believe the code as it originally was is the correct implementation and 
the manual code should be updated to add the following cod

@auth.requires_membership('manager')
def manage():
db.comment.image_id.readable = True
grid = SQLFORM.smartgrid(db.image)
return dict(grid=grid)

What do others think?

Dan

-- 





Re: [web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
There are some design issues here. The main think is that you click on the 
button you want something to happen without the reloading the page. Yet you 
make the callback=URL() point to the same action that generates the 
page while it should point to a separate action which just performs the 
callback. You need two actions. One renders the page and one deals with the 
callback events.

For example:

db.define_table('friend',Field('name'))

def manage(): # renders page
form = SQLFORM(db.friend)
friends = db(db.friend).select()
return dict(form=form,friends=friends)

def delete_friend(): # executes callback
# should check permissions but ok for now...
del db.friend[request.port_vars.id]
return 'done'

% views/default/manage.html

{{extend 'layout.html'}}
{{=form}}

{{for friend in friends:}}
  
{{=friend.name}}

{{=A('delete',callback=URL('delete_friend',vars=dict(id=friend.id),delete='tr'))}}
  
{{pass}}


On Tuesday, 18 December 2012 11:15:15 UTC-6, Daniele wrote:
>
> Sure thing Massimo,
>
> here's my view: http://bpaste.net/show/nSrzmYsurH2CnXLrpdwJ/
>
> here's my controller: http://bpaste.net/show/KEx38v6ARYgsUwG8oXMd/
>
> Daniele
>
>
> On Tue, Dec 18, 2012 at 5:07 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> Please post your code so we can try it. 
>>
>> Are you sure the edit_profile is not being called? Can you use the JS 
>> console in chorme to see what is going on?
>>
>> Massimo
>>
>> On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote:
>>>
>>> Still isn't working for me :'(
>>>
>>> In my view, I have:
>>> {{=A('Delete Role',_class="btn 
>>> btn-danger",_id='deltutorlink'**, callback=URL('edit_profile'),**
>>> delete='#deltutor')}
>>>
>>> in my controller, under the edit_profile method, I have:
>>>
>>> if request.vars.deltutorlink:
>>> response.flash = T('deltutorlink reached!')
>>>
>>> but this response.flash is never reached. I can't figure out why
>>>
>>>
>>> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:

  {{=A('delete 
 123',callback=URL('delete',**args=123),delete='#row123')}} 
 ... 


 The delete argument indicates that upon success you want to remove the 
 ... from the page. If there is a "delete" argument 
 the confirmation popup is automatic. ;-)

 On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:
>
> I want to do something very simple but it's taking me eons to do this~
>
> When the button is clicked, I want a javascript alert to pop up that 
> asks, are you sure? Yes/No.
> If Yes, then run this code: auth.del_membership('role')
>
> No redirection, just delete the role.
> That's all -_- this is taking me way too long
>
> On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:
>>
>> None. You are asking to ":eval" the result. It meas the action is 
>> supposed to return JS
>>
>> def test():
>> return "alert('hello')"
>>
>> anyway, you should debug this with the JS console in chrome. We do 
>> not know exactly how your code looks like.
>>
>> On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:
>>>
>>> I am trying with:
>>> {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", 
>>> callback=URL('test'), target=":eval")}}
>>>
>>> and in my controller:
>>>
>>> def test():
>>> return "Hello"
>>>
>>> or 
>>>
>>> def test():
>>> return dict()
>>>
>>> but when I click the button, nothing happens. Why is this??
>>>
>>> On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:

 When I use form.add_button() I am able to add a button to a form, 
 which I can display with {{=form}} in my view.

 However, if I'm making a custom form using form.custom, how can I 
 display that button??

 Thanks

>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Richard Vézina
Forget that, I was pointing database on my dev machine postgres server, for
some reason, it was not working. I copy the db into local postgres database
and point on the same server instead of my old dev VM and it gone away.
Maybe issue with different version of software between Ubuntu 10.04 and
12.10. I don't know.

Thanks

Richard

On Tue, Dec 18, 2012 at 12:21 PM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> Ok, thanks
>
> It must be my server... It seems to work fine with my dev machine.
>
> Richard
>
>
> On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Are other people having problems with psycopg2 and web2py 2.3.2? Nothing
>> should have changed in this respect. psycopg2 if available takes
>> precendence over pg8000 which has problems.
>>
>> Massimo
>>
>>
>> On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:
>>
>>> Is there something different with psycopg2 under web2py 2.3.2 ?
>>>
>>> I get this error on a new server that I configure :
>>>
>>>  Failure to connect, tried 5 times:
>>> Traceback (most recent call last): File 
>>> "/home/www-data/web2py/gluon/**dal.py",
>>> line 6853, in __init__ self._adapter = ADAPTERS[self._dbname](kwargs)
>>> File "/home/www-data/web2py/gluon/**dal.py", line 2493, in __init__ if
>>> do_connect: self.find_driver(adapter_args,**uri) File
>>> "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver raise
>>> RuntimeError("driver %s not available" % request_driver) RuntimeError:
>>> driver psycopg2 not available
>>>
>>> python-psycopg2 is installed
>>>
>>> For some reason I had to add apdater to my connection string like this :
>>>
>>> db=DAL('postgres:psycopg2:...)
>>>
>>> Because if I didn't not precise it, web2py seems to use pg8000 and I get
>>> this error with pg8000 :
>>>
>>>  invalid literal for int() with base 10:
>>> 'SELECT'
>>>
>>> Traceback (most recent call last):
>>>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in
>>> restricted
>>> exec ccode in environment
>>>   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py",
>>> line 121, in 
>>> for r in db().select(db.dict_database.**table_name,
>>> db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
>>>   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
>>> return adapter.select(self.query,**fields,attributes)
>>>   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
>>> return self._select_aux(sql,fields,**attributes)
>>>   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in _select_aux
>>> rows = self._fetchall()
>>>   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in _fetchall
>>> return self.cursor.fetchall()
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
>>> 246, in _fn
>>> return fn(self, *args, **kwargs)
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
>>> 414, in fetchall
>>> return tuple(self.cursor.iterate_**tuple())
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
>>> line 76, in next
>>> retval = self.func(self.obj)
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
>>> line 270, in read_tuple
>>> return self._fetch()
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
>>> line 205, in _fetch
>>> self._fill_cache()
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py",
>>> line 190, in _fill_cache
>>> end_of_data, rows = self.c.fetch_rows(self._**portal_name,
>>> self.row_cache_size, self._row_desc)
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>>> 943, in _fn
>>> return fn(self, *args, **kwargs)
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>>> 1249, in fetch_rows
>>> retval = reader.handle_messages()
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>>> 906, in handle_messages
>>> msg = self._conn._read_message()
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>>> 1038, in _read_message
>>> msg = message_types[message_code].**createFromData(bytes)
>>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>>> 783, in createFromData
>>> args['rows'] = int(values[-1])
>>> ValueError: invalid literal for int() with base 10: 'SELECT'
>>>
>>>
>>> I never really use pg8000, because it didn't works for me, maybe because
>>> of my app code or issue with pg8000 in web2py, but I am more inclined in
>>> the former (my app code).
>>>
>>>
>>> I use ubuntu 12.10 and a custom Nginx installation with uwsgi emperor
>>> mode.
>>>
>>> Could it be only because web2py is missing a dependance?
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>>
>>> On Tue, Dec 18, 2012 at 5:23 AM, Niphlod  wrote:
>>>
 totally unrelated epydoc folder in examples/static is 22mb. Leaving
 that one out and artwork.tar.gz (that seems to be a co

Re: [web2py] Re: DB insert confusion

2012-12-18 Thread Kurt Grutzmacher
Any movement on this? I can't seem to get jsonrpclib to force parameterized 
queries. Replicating this is fairly simple:

1. Create a new app, in default.py add a function. Replace t_test with auth or 
whatever:

@service.jsonrpc
def list():
data = db(db.t_test.ALL).select()
return dict(data=data)

2. Drop to a python shell:

>>> import jsonrpclib
>>> j = 
>>> jsonrpclib.Server(uri='http://localhost:8000/appname/default/call/jsonrpc')
>>> j.list()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py",
 line 276, in __call__
return self.__send(self.__name, kwargs)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py",
 line 225, in _request
check_for_errors(response)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py",
 line 529, in check_for_errors
raise ProtocolError((code, message))
ProtocolError: (100, u'TypeError: list() argument after ** must be a mapping, 
not str')

Same problem with simplejsonrpc in gluon/contrib...


Niphlod wrote:
> uhm. The "problem" is that even though every jsonrpc interface I
> worked with was parameter-based, for jsonrpc2 position-based and
> parameter-based are both valid.
>
> On Tuesday, December 11, 2012 10:42:06 PM UTC+1, Jonathan Lundell wrote:
>
> On 11 Dec 2012, at 1:09 PM, Niphlod  > wrote:
>> I took some time to watch at the jsonrpc specs. Right now I had
>> experience with jsonrpc only in the "named parameters" format. I
>> thought it was the standard, my bad.
>> However, I found out that 2.0 introduced "named parameters" that
>> were not supported - explicitely - in 1.0
>>
>> --> {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}
>> <-- {"jsonrpc": "2.0", "result": 19, "id": 1}
>>
>> --> {"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 
>> 23, "minuend": 42}, "id": 3}
>> <-- {"jsonrpc": "2.0", "result": 19, "id": 3}
>>
>> are both valid.
>>
>> Maybe revert this and make a jsonrpc2 decorator to support named
>> parameters explicitely would be a better solution?
>
> How about both jsonrpc1 and jsonrpc2, and then jsonrpc = jsonrpc2?
> (I think it'd be better to make v2 the default.)
>
>>
>> On Tuesday, December 11, 2012 9:57:50 PM UTC+1, Kurt Grutzmacher
>> wrote:
>>
>> I don't think this is a good JSON-RPC example as the change
>> broke our app that uses simplejsonrpc or jsonrpclib to make
>> API calls.
>>
>> Based on the jsonrpclib python module
>> @ https://code.google.com/p/jsonrpclib/
>>  requests look like:
>>
>> >>> import jsonrpclib
>> >>> server = jsonrpclib.Server('http://localhost:8080 
>> ')
>> >>> server.add(5,6)
>> 11
>> >>> print jsonrpclib.history.request
>> {"jsonrpc": "2.0", "params": [5, 6], "id": "gb3c9g37", "method": 
>> "add"}
>> >>> print jsonrpclib.history.response
>> {'jsonrpc': '2.0', 'result': 11, 'id': 'gb3c9g37'}
>>
>>
>> And the JSON-RPC spec states params should be "An Array of
>> objects to pass as arguments to the method."
>> -- http://json-rpc.org/wiki/specification
>> 
>>
>> However the actual spec doesn't specify array, dict or
>> whatever as it tries to be universal: "A Structured value
>> that holds the parameter values to be used during the
>> invocation of the method. This member MAY be omitted."
>>  http://www.jsonrpc.org/specification#request_object
>> 
>>
>> For simplejsonrpc and jsonrpclib to work we have to undo this
>> change in gluon/tools.py
>>
>>
>> On Wednesday, November 14, 2012 1:25:22 PM UTC-8, Mike Anson
>> wrote:
>>
>> Thanks very much for your help Niphlod.
>>
>> On Wednesday, 14 November 2012 16:10:35 UTC-5, Niphlod wrote:
>>
>>
>> Yes I understand your point. The reason it is
>> currently like this is because if I use your
>> suggestion (which I obviously had originally)
>>
>> {"id": 1, "method": "savemessage", "params": {
>> "*message*": "variableholdingmessage", "*uid*" :
>> "variableholdingmail"}}
>>
>> I get message and uid as the values in the DB. So
>> I switched them.
>>
>> {"id": 1, "method": "savemessage", "params": {
>> "variableholdingmessage": "mymessage",
>> "variableholdinguid" : "myemail@localhost"}}
>>
>> The resu

[web2py] Re: Firewalls, restrictions and appending to two tables

2012-12-18 Thread Seelife
Hi Ron, thanks for that info.  We thought as much. It seems its the 
firewall that is causing us so many problems. We can run our apps with no 
problems on machines with fewer restrictions. Apart from modifying the 
firewall rights (hard to do), any suggestions to work around them other 
than placing the apps and running as a pure python from Unix etc (also hard 
for us to arrange).


On Tuesday, December 18, 2012 4:24:58 PM UTC+1, Ron McOuat wrote:
>
>
> The error traceback is saying the connection to the database could not be 
> opened. The problem should be in the model file that has
>
> db=DAL(.), 
>
> the first parameter is the connection information. If the database is on 
> another machine and a firewall is in the way you won't have any ability to 
> connect. If you can't work out what is wrong on that line then post the 
> model file.
>

-- 





[web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele
I tried doing this but absolutely nothing happens when I click the button

On Tuesday, December 18, 2012 5:10:01 PM UTC, Massimo Di Pierro wrote:
>
> BTW...
>
> def edit_record():
> ...
> if request.vars.deltutorlink:
> response.flash = T('deltutorlink reached!')
> ...
>
> If edit_record is called via ajax and not within a component, 
> than response.flash is not displayed because there is no view associated to 
> the callback. You can do:
>
> def edit_record():
> ...
> if request.vars.deltutorlink:
> response.js = "jQuery('.flash').html('deltutorlink 
> reached!').slideDown()"
> ...
>
> and the response flash will be injected in the proper place.
>
>
> On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote:
>>
>> Still isn't working for me :'(
>>
>> In my view, I have:
>> {{=A('Delete Role',_class="btn 
>> btn-danger",_id='deltutorlink', 
>> callback=URL('edit_profile'),delete='#deltutor')}
>>
>> in my controller, under the edit_profile method, I have:
>>
>> if request.vars.deltutorlink:
>> response.flash = T('deltutorlink reached!')
>>
>> but this response.flash is never reached. I can't figure out why
>>
>>
>> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>>>
>>>  {{=A('delete 
>>> 123',callback=URL('delete',args=123),delete='#row123')}} ... 
>>>
>>>
>>> The delete argument indicates that upon success you want to remove the 
>>> ... from the page. If there is a "delete" argument 
>>> the confirmation popup is automatic. ;-)
>>>
>>> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:

 I want to do something very simple but it's taking me eons to do this~

 When the button is clicked, I want a javascript alert to pop up that 
 asks, are you sure? Yes/No.
 If Yes, then run this code: auth.del_membership('role')

 No redirection, just delete the role.
 That's all -_- this is taking me way too long

 On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:
>
> None. You are asking to ":eval" the result. It meas the action is 
> supposed to return JS
>
> def test():
> return "alert('hello')"
>
> anyway, you should debug this with the JS console in chrome. We do not 
> know exactly how your code looks like.
>
> On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:
>>
>> I am trying with:
>> {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", 
>> callback=URL('test'), target=":eval")}}
>>
>> and in my controller:
>>
>> def test():
>> return "Hello"
>>
>> or 
>>
>> def test():
>> return dict()
>>
>> but when I click the button, nothing happens. Why is this??
>>
>> On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:
>>>
>>> When I use form.add_button() I am able to add a button to a form, 
>>> which I can display with {{=form}} in my view.
>>>
>>> However, if I'm making a custom form using form.custom, how can I 
>>> display that button??
>>>
>>> Thanks
>>>
>>

-- 





Re: [web2py] Reusing expensive objects

2012-12-18 Thread Mariano Reingart
If the objects are pickleable (serializable), you can store them in a
cache (ram, disk, etc.)
If you're using a threaded webserver, you can store them in modules,
whom persist between requests.

Object instance reuse is not web2py specific, is more a python general issue.
Also, bear in mind that if you keep many objects alive, you can run
out of memory in some scenarios.

You don't need to instantiate the object in each request, you can
easily use regular python modules too, and create objects on demand.

Best regards,

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


On Mon, Dec 17, 2012 at 9:57 PM, Daniel Gonzalez  wrote:
> Hi,
>
> My application uses some objects which are quite slow to setup. I create
> this object in the models file, so that they are available for all
> controllers.
>
> Specifically, most of my processing is delegated to a celery queue (based on
> rabbitmq). The interface to this queue is wrapped by a class
> (MessageQueueClient) which I instantiate in the model file db.py. If I
> understand things correctly, this object will be instantiated for each
> request coming to web2py.
>
> Would it be possible to reuse these objects, so that successive requests do
> not need to create them again? How could this be done?
>
> Thanks,
> Daniel
>
> --
>
>
>

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Richard Vézina
Ok, thanks

It must be my server... It seems to work fine with my dev machine.

Richard

On Tue, Dec 18, 2012 at 12:05 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Are other people having problems with psycopg2 and web2py 2.3.2? Nothing
> should have changed in this respect. psycopg2 if available takes
> precendence over pg8000 which has problems.
>
> Massimo
>
>
> On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:
>
>> Is there something different with psycopg2 under web2py 2.3.2 ?
>>
>> I get this error on a new server that I configure :
>>
>>  Failure to connect, tried 5 times:
>> Traceback (most recent call last): File 
>> "/home/www-data/web2py/gluon/**dal.py",
>> line 6853, in __init__ self._adapter = ADAPTERS[self._dbname](kwargs)
>> File "/home/www-data/web2py/gluon/**dal.py", line 2493, in __init__ if
>> do_connect: self.find_driver(adapter_args,**uri) File
>> "/home/www-data/web2py/gluon/**dal.py", line 704, in find_driver raise
>> RuntimeError("driver %s not available" % request_driver) RuntimeError:
>> driver psycopg2 not available
>>
>> python-psycopg2 is installed
>>
>> For some reason I had to add apdater to my connection string like this :
>>
>> db=DAL('postgres:psycopg2:...)
>>
>> Because if I didn't not precise it, web2py seems to use pg8000 and I get
>> this error with pg8000 :
>>
>>  invalid literal for int() with base 10:
>> 'SELECT'
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in
>> restricted
>> exec ccode in environment
>>   File "/home/www-data/web2py/**applications/sgddms/models/**dict.py",
>> line 121, in 
>> for r in db().select(db.dict_database.**table_name,
>> db.dict_database.column_name, db.dict_database.column_name_**en_ui)])
>>   File "/home/www-data/web2py/gluon/**dal.py", line 8905, in select
>> return adapter.select(self.query,**fields,attributes)
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1631, in select
>> return self._select_aux(sql,fields,**attributes)
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1597, in _select_aux
>> rows = self._fetchall()
>>   File "/home/www-data/web2py/gluon/**dal.py", line 1590, in _fetchall
>> return self.cursor.fetchall()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
>> 246, in _fn
>> return fn(self, *args, **kwargs)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/dbapi.py", line
>> 414, in fetchall
>> return tuple(self.cursor.iterate_**tuple())
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", line
>> 76, in next
>> retval = self.func(self.obj)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", line
>> 270, in read_tuple
>> return self._fetch()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", line
>> 205, in _fetch
>> self._fill_cache()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/interface.py", line
>> 190, in _fill_cache
>> end_of_data, rows = self.c.fetch_rows(self._**portal_name,
>> self.row_cache_size, self._row_desc)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>> 943, in _fn
>> return fn(self, *args, **kwargs)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>> 1249, in fetch_rows
>> retval = reader.handle_messages()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>> 906, in handle_messages
>> msg = self._conn._read_message()
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>> 1038, in _read_message
>> msg = message_types[message_code].**createFromData(bytes)
>>   File "/home/www-data/web2py/gluon/**contrib/pg8000/protocol.py", line
>> 783, in createFromData
>> args['rows'] = int(values[-1])
>> ValueError: invalid literal for int() with base 10: 'SELECT'
>>
>>
>> I never really use pg8000, because it didn't works for me, maybe because
>> of my app code or issue with pg8000 in web2py, but I am more inclined in
>> the former (my app code).
>>
>>
>> I use ubuntu 12.10 and a custom Nginx installation with uwsgi emperor
>> mode.
>>
>> Could it be only because web2py is missing a dependance?
>>
>> Thanks
>>
>> Richard
>>
>>
>> On Tue, Dec 18, 2012 at 5:23 AM, Niphlod  wrote:
>>
>>> totally unrelated epydoc folder in examples/static is 22mb. Leaving
>>> that one out and artwork.tar.gz (that seems to be a compressed version of
>>> examples/static/images) takes the compressed binary down to ~10 MB
>>> compressed/25MB uncompressed.
>>> Maybe a little cleanup in the next release will save everyone a few MB ?
>>>
>>>
>>> On Tuesday, December 18, 2012 9:20:54 AM UTC+1, apps in tables wrote:

 sorry, both are 45 mb after unzipping, (examples application 25 mb).

 On Tuesday, December 18, 2012 7:34:22 AM UTC+3, Massimo Di Pierro wrote:
>
> Are you sure about this? I cannot explain it. What's in the extra
> +30MB?
>
>>>

Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread António Ramos
Done.thank you.

2012/12/18 Vinicius Assef 

> Well, if you started your app based on welcome app in Web2py 2.2.1 you
> should have your default layout.html view linking bootstrap css.
>
>
> On Tue, Dec 18, 2012 at 12:56 PM, António Ramos 
> wrote:
> > 2.2.1!
> > windows version
> >
> > 2012/12/18 Vinicius Assef 
> >>
> >> What version are you using?
> >>
> >> Bootstrap came in version 2.0.1
> >>
> >>
> >>
> >> On Tue, Dec 18, 2012 at 12:12 PM, António Ramos 
> >> wrote:
> >> > I dont see it in my app static folder nor through web inspection...
> >> >
> >> > Where is it?
> >> >
> >> > 2012/12/18 Vinicius Assef 
> >> >>
> >> >> It's already embedded.
> >> >>
> >> >> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos <
> ramstei...@gmail.com>
> >> >> wrote:
> >> >> > Hello, just a simple question
> >> >> > how do i use twitter bootstrap with web2py?
> >> >> > thank you
> >> >> > António
> >> >> >
> >> >> >
> >> >> > 2012/12/18 LightDot 
> >> >> >>
> >> >> >> Looks nice. There are also:
> >> >> >>
> >> >> >> http://bootswatchr.com/
> >> >> >> and
> >> >> >> http://bootswatcher.com/
> >> >> >>
> >> >> >> Names are similar, but they're not related. The latter allows you
> to
> >> >> >> start
> >> >> >> with an existing Bootswatch theme and go from there.
> >> >> >>
> >> >> >> Regards,
> >> >> >> Ales
> >> >> >>
> >> >> >>
> >> >> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro
> >> >> >> wrote:
> >> >> >>>
> >> >> >>> http://www.boottheme.com/#generatetheme
> >> >> >>
> >> >> >> --
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >>
> >> >>
> >> >>
> >> >
> >> > --
> >> >
> >> >
> >> >
> >>
> >> --
> >>
> >>
> >>
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele Pestilli
Sure thing Massimo,

here's my view: http://bpaste.net/show/nSrzmYsurH2CnXLrpdwJ/

here's my controller: http://bpaste.net/show/KEx38v6ARYgsUwG8oXMd/

Daniele


On Tue, Dec 18, 2012 at 5:07 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Please post your code so we can try it.
>
> Are you sure the edit_profile is not being called? Can you use the JS
> console in chorme to see what is going on?
>
> Massimo
>
> On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote:
>>
>> Still isn't working for me :'(
>>
>> In my view, I have:
>> {{=A('Delete Role',_class="btn
>> btn-danger",_id='deltutorlink'**, callback=URL('edit_profile'),**
>> delete='#deltutor')}
>>
>> in my controller, under the edit_profile method, I have:
>>
>> if request.vars.deltutorlink:
>> response.flash = T('deltutorlink reached!')
>>
>> but this response.flash is never reached. I can't figure out why
>>
>>
>> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>>>
>>>  {{=A('delete 
>>> 123',callback=URL('delete',**args=123),delete='#row123')}}
>>> ... 
>>>
>>>
>>> The delete argument indicates that upon success you want to remove the
>>> ... from the page. If there is a "delete" argument
>>> the confirmation popup is automatic. ;-)
>>>
>>> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:

 I want to do something very simple but it's taking me eons to do this~

 When the button is clicked, I want a javascript alert to pop up that
 asks, are you sure? Yes/No.
 If Yes, then run this code: auth.del_membership('role')

 No redirection, just delete the role.
 That's all -_- this is taking me way too long

 On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:
>
> None. You are asking to ":eval" the result. It meas the action is
> supposed to return JS
>
> def test():
> return "alert('hello')"
>
> anyway, you should debug this with the JS console in chrome. We do not
> know exactly how your code looks like.
>
> On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:
>>
>> I am trying with:
>> {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor",
>> callback=URL('test'), target=":eval")}}
>>
>> and in my controller:
>>
>> def test():
>> return "Hello"
>>
>> or
>>
>> def test():
>> return dict()
>>
>> but when I click the button, nothing happens. Why is this??
>>
>> On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:
>>>
>>> When I use form.add_button() I am able to add a button to a form,
>>> which I can display with {{=form}} in my view.
>>>
>>> However, if I'm making a custom form using form.custom, how can I
>>> display that button??
>>>
>>> Thanks
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: Login manually

2012-12-18 Thread Massimo Di Pierro
Can I see you models? Are you changing the validator for 
db.auth_user.password?
Your error says:

 unsupported hash type |pbkdf2(1000,20,sha512)

I do not understand where | in  |pbkdf2 would come from.


On Tuesday, 18 December 2012 09:33:12 UTC-6, Wonton wrote:
>
> Hi Massimo!!
>
> I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last 
> week.
>
> El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro 
> escribió:
>>
>> Which web2py version? The error suggests you are using an older web2py 
>> version with newly created database of records.
>>
>> Massimo
>>
>> On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote:
>>>
>>> Hello everyone,
>>>
>>> I'm developing a backend site with web2py. I have 2 web services, one to 
>>> register a user and a second one to login the user.
>>> This is the first one:
>>>
>>> def register(user, email, password):
>>>  db.auth_user.insert(username=user, email=email, 
>>> password=db.auth_user.password.validate(password)) 
>>> ...
>>>  return 'OK'
>>>
>>> It's working ok and the users are created without problem.
>>>
>>> This is the second one:
>>>
>>> def login(user, password):
>>> response = auth.login_bare(user, password)
>>>  if not response:
>>> message = 'Error'
>>> else:
>>>  message = 'OK'
>>>return message
>>>
>>> With this service I have the following error:
>>>  unsupported hash type 
>>> |pbkdf2(1000,20,sha512)
>>>
>>> I've tried to find any solution to this problem without success.
>>>
>>> Any of you has any idea of what is happening?
>>>
>>> Thank you very much and kind regards!
>>>
>>> Wonton
>>>
>>

-- 





[web2py] Re: Login manually

2012-12-18 Thread Wonton
Hi Massimo!!

I'm using version 2.2.1 (2012-10-21 16:57:04) stable. I dowloaded it last 
week.

El martes, 18 de diciembre de 2012 16:26:29 UTC+1, Massimo Di Pierro 
escribió:
>
> Which web2py version? The error suggests you are using an older web2py 
> version with newly created database of records.
>
> Massimo
>
> On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote:
>>
>> Hello everyone,
>>
>> I'm developing a backend site with web2py. I have 2 web services, one to 
>> register a user and a second one to login the user.
>> This is the first one:
>>
>> def register(user, email, password):
>>  db.auth_user.insert(username=user, email=email, 
>> password=db.auth_user.password.validate(password)) 
>> ...
>>  return 'OK'
>>
>> It's working ok and the users are created without problem.
>>
>> This is the second one:
>>
>> def login(user, password):
>> response = auth.login_bare(user, password)
>>  if not response:
>> message = 'Error'
>> else:
>>  message = 'OK'
>>return message
>>
>> With this service I have the following error:
>>  unsupported hash type 
>> |pbkdf2(1000,20,sha512)
>>
>> I've tried to find any solution to this problem without success.
>>
>> Any of you has any idea of what is happening?
>>
>> Thank you very much and kind regards!
>>
>> Wonton
>>
>

-- 





[web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
BTW...

def edit_record():
...
if request.vars.deltutorlink:
response.flash = T('deltutorlink reached!')
...

If edit_record is called via ajax and not within a component, 
than response.flash is not displayed because there is no view associated to 
the callback. You can do:

def edit_record():
...
if request.vars.deltutorlink:
response.js = "jQuery('.flash').html('deltutorlink 
reached!').slideDown()"
...

and the response flash will be injected in the proper place.


On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote:
>
> Still isn't working for me :'(
>
> In my view, I have:
> {{=A('Delete Role',_class="btn 
> btn-danger",_id='deltutorlink', 
> callback=URL('edit_profile'),delete='#deltutor')}
>
> in my controller, under the edit_profile method, I have:
>
> if request.vars.deltutorlink:
> response.flash = T('deltutorlink reached!')
>
> but this response.flash is never reached. I can't figure out why
>
>
> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>>
>>  {{=A('delete 
>> 123',callback=URL('delete',args=123),delete='#row123')}} ... 
>>
>>
>> The delete argument indicates that upon success you want to remove the 
>> ... from the page. If there is a "delete" argument 
>> the confirmation popup is automatic. ;-)
>>
>> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:
>>>
>>> I want to do something very simple but it's taking me eons to do this~
>>>
>>> When the button is clicked, I want a javascript alert to pop up that 
>>> asks, are you sure? Yes/No.
>>> If Yes, then run this code: auth.del_membership('role')
>>>
>>> No redirection, just delete the role.
>>> That's all -_- this is taking me way too long
>>>
>>> On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:

 None. You are asking to ":eval" the result. It meas the action is 
 supposed to return JS

 def test():
 return "alert('hello')"

 anyway, you should debug this with the JS console in chrome. We do not 
 know exactly how your code looks like.

 On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:
>
> I am trying with:
> {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", 
> callback=URL('test'), target=":eval")}}
>
> and in my controller:
>
> def test():
> return "Hello"
>
> or 
>
> def test():
> return dict()
>
> but when I click the button, nothing happens. Why is this??
>
> On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:
>>
>> When I use form.add_button() I am able to add a button to a form, 
>> which I can display with {{=form}} in my view.
>>
>> However, if I'm making a custom form using form.custom, how can I 
>> display that button??
>>
>> Thanks
>>
>

-- 





[web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
Please post your code so we can try it. 

Are you sure the edit_profile is not being called? Can you use the JS 
console in chorme to see what is going on?

Massimo

On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote:
>
> Still isn't working for me :'(
>
> In my view, I have:
> {{=A('Delete Role',_class="btn 
> btn-danger",_id='deltutorlink', 
> callback=URL('edit_profile'),delete='#deltutor')}
>
> in my controller, under the edit_profile method, I have:
>
> if request.vars.deltutorlink:
> response.flash = T('deltutorlink reached!')
>
> but this response.flash is never reached. I can't figure out why
>
>
> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>>
>>  {{=A('delete 
>> 123',callback=URL('delete',args=123),delete='#row123')}} ... 
>>
>>
>> The delete argument indicates that upon success you want to remove the 
>> ... from the page. If there is a "delete" argument 
>> the confirmation popup is automatic. ;-)
>>
>> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:
>>>
>>> I want to do something very simple but it's taking me eons to do this~
>>>
>>> When the button is clicked, I want a javascript alert to pop up that 
>>> asks, are you sure? Yes/No.
>>> If Yes, then run this code: auth.del_membership('role')
>>>
>>> No redirection, just delete the role.
>>> That's all -_- this is taking me way too long
>>>
>>> On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:

 None. You are asking to ":eval" the result. It meas the action is 
 supposed to return JS

 def test():
 return "alert('hello')"

 anyway, you should debug this with the JS console in chrome. We do not 
 know exactly how your code looks like.

 On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:
>
> I am trying with:
> {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", 
> callback=URL('test'), target=":eval")}}
>
> and in my controller:
>
> def test():
> return "Hello"
>
> or 
>
> def test():
> return dict()
>
> but when I click the button, nothing happens. Why is this??
>
> On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:
>>
>> When I use form.add_button() I am able to add a button to a form, 
>> which I can display with {{=form}} in my view.
>>
>> However, if I'm making a custom form using form.custom, how can I 
>> display that button??
>>
>> Thanks
>>
>

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Massimo Di Pierro
Are other people having problems with psycopg2 and web2py 2.3.2? Nothing 
should have changed in this respect. psycopg2 if available takes 
precendence over pg8000 which has problems.

Massimo

On Tuesday, 18 December 2012 10:46:16 UTC-6, Richard wrote:
>
> Is there something different with psycopg2 under web2py 2.3.2 ?
>
> I get this error on a new server that I configure :
>
>  Failure to connect, tried 5 times: 
> Traceback (most recent call last): File 
> "/home/www-data/web2py/gluon/dal.py", line 6853, in __init__ self._adapter 
> = ADAPTERS[self._dbname](**kwargs) File 
> "/home/www-data/web2py/gluon/dal.py", line 2493, in __init__ if do_connect: 
> self.find_driver(adapter_args,uri) File 
> "/home/www-data/web2py/gluon/dal.py", line 704, in find_driver raise 
> RuntimeError("driver %s not available" % request_driver) RuntimeError: 
> driver psycopg2 not available
>
> python-psycopg2 is installed
>
> For some reason I had to add apdater to my connection string like this :
>
> db=DAL('postgres:psycopg2:...)
>
> Because if I didn't not precise it, web2py seems to use pg8000 and I get 
> this error with pg8000 :
>
>  invalid literal for int() with base 10: 
> 'SELECT'
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
> exec ccode in environment
>   File "/home/www-data/web2py/applications/sgddms/models/dict.py", line 
> 121, in 
> for r in db().select(db.dict_database.table_name, 
> db.dict_database.column_name, db.dict_database.column_name_en_ui)])
>   File "/home/www-data/web2py/gluon/dal.py", line 8905, in select
> return adapter.select(self.query,fields,attributes)
>   File "/home/www-data/web2py/gluon/dal.py", line 1631, in select
> return self._select_aux(sql,fields,attributes)
>   File "/home/www-data/web2py/gluon/dal.py", line 1597, in _select_aux
> rows = self._fetchall()
>   File "/home/www-data/web2py/gluon/dal.py", line 1590, in _fetchall
> return self.cursor.fetchall()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/dbapi.py", line 246, in 
> _fn
> return fn(self, *args, **kwargs)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/dbapi.py", line 414, in 
> fetchall
> return tuple(self.cursor.iterate_tuple())
>   File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 76, 
> in next
> retval = self.func(self.obj)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 
> 270, in read_tuple
> return self._fetch()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 
> 205, in _fetch
> self._fill_cache()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 
> 190, in _fill_cache
> end_of_data, rows = self.c.fetch_rows(self._portal_name, 
> self.row_cache_size, self._row_desc)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 943, 
> in _fn
> return fn(self, *args, **kwargs)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 
> 1249, in fetch_rows
> retval = reader.handle_messages()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 906, 
> in handle_messages
> msg = self._conn._read_message()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 
> 1038, in _read_message
> msg = message_types[message_code].createFromData(bytes)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 783, 
> in createFromData
> args['rows'] = int(values[-1])
> ValueError: invalid literal for int() with base 10: 'SELECT'
>
>
> I never really use pg8000, because it didn't works for me, maybe because 
> of my app code or issue with pg8000 in web2py, but I am more inclined in 
> the former (my app code).
>
>
> I use ubuntu 12.10 and a custom Nginx installation with uwsgi emperor mode.
>
> Could it be only because web2py is missing a dependance?
>
> Thanks
>
> Richard
>
>
> On Tue, Dec 18, 2012 at 5:23 AM, Niphlod  >wrote:
>
>> totally unrelated epydoc folder in examples/static is 22mb. Leaving 
>> that one out and artwork.tar.gz (that seems to be a compressed version of 
>> examples/static/images) takes the compressed binary down to ~10 MB 
>> compressed/25MB uncompressed.
>> Maybe a little cleanup in the next release will save everyone a few MB ?
>>
>>
>> On Tuesday, December 18, 2012 9:20:54 AM UTC+1, apps in tables wrote:
>>>
>>> sorry, both are 45 mb after unzipping, (examples application 25 mb).
>>>
>>> On Tuesday, December 18, 2012 7:34:22 AM UTC+3, Massimo Di Pierro wrote:

 Are you sure about this? I cannot explain it. What's in the extra +30MB?

 On Monday, 17 December 2012 21:27:44 UTC-6, apps in tables wrote:
>
>
> another advantage:
>
> 2.3.1 is 45 mb
> 2.3.2 is 15 mb
>
> smaller is nicer...:)
>
>
> On Monday, December 17, 2012 6:11:19 PM UTC+3, Massimo Di Pierro wrote:
>>
>> It is the same as 2.3.2 but fixed a major bug with N

[web2py] Re: Documentation bug, mail attachment initializer

2012-12-18 Thread Massimo Di Pierro
Fixed in my repo. Will commit tonight. Thanks for reporting this.


On Tuesday, 18 December 2012 08:21:58 UTC-6, Nick Vargish wrote:
>
> Hi folks,
>
> Just a quick documentation bug: In 
> http://web2py.com/books/default/chapter/29/08#Sending-emails, the 
> attachment object initializer is referred to as "Mail.Attachment()". It 
> took me a little experimentation, but I had to use "mail.Attachment()" for 
> things to work. Someone might want to update the documentation to reflect 
> the correct case.
>
> Many thanks to Massimo and other contributors... Web2py has been an 
> excellent tool for building our in-house applications.
>
> Nick
>
>

-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2012-12-18 Thread Massimo Di Pierro
If there is no ticket here is a problem talking to database or other 
internal web2py error, not an application error. Please check for traceback 
in the app engine logs.

On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:
>
> Hi, I'm using GAE + Cloud SQL but every time I get an error, there is no 
> ticket. Can I set web2py to save tickets to database as in Google NoSQL 
> (big table)?

-- 





[web2py] Re: Web2py thread management

2012-12-18 Thread Massimo Di Pierro
Your question is not about web2py but about the rocket web server. Things 
work differently for different web servers.

With rocket, it creates a fixed number of threads and when a request 
arrives it is assigned to one of the available threads or a new thread is 
created t the request is queued. The number of thread has a minimum (to 
avoid the overhead of creating new threads when a new request arrives) and 
a maximum (to prevent DoS attacks). 

These parameters can be specified with'
$ python web2py.py -h
  
  --minthreads=MINTHREADS
minimum number of server threads
  --maxthreads=MAXTHREADS
maximum number of server threads
  ...

minthreads defaults to 10
maxthreads defaults to 0 (which means no maximum, they will be created as 
necessary and deleted when not necessary).




On Tuesday, 18 December 2012 05:54:11 UTC-6, Daniel Gonzalez wrote:
>
> Hi,
>
> How are threads managed in web2py? I am stress testing with a 
> multithreaded programm, and I see that web2py spawns 14 "worker threads".
> These threads are not created/destroyed, but seem to run forever.
>
> python,8698 web2py.py -a 
>   |-{python},9005
>   |-{python},9023
>   |-{python},9042
>   |-{python},9043
>   |-{python},9044
>   |-{python},9050
>   |-{python},9051
>   |-{python},9053
>   |-{python},9054
>   |-{python},9055
>   |-{python},9057
>   |-{python},9058
>   |-{python},9059
>   `-{python},9060
>
> I have several questions:
>
>- How do these threads map to the requests? Does each thread serve a 
>request?
>- That means web2py can maximally cope with 14 parallel requests?
>- Is this number (14) configurable?
>- Are the objects defined in the models initialized at thread 
>creation, and then reused for all requests?
>
> Thanks,
>
> Daniel
>

-- 





[web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele
Still isn't working for me :'(

In my view, I have:
{{=A('Delete Role',_class="btn 
btn-danger",_id='deltutorlink', 
callback=URL('edit_profile'),delete='#deltutor')}

in my controller, under the edit_profile method, I have:

if request.vars.deltutorlink:
response.flash = T('deltutorlink reached!')

but this response.flash is never reached. I can't figure out how to get the 
callback go to the controller and pass in the request.vars.deltutorlink as 
being clicked so that it can run the code I want...


On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>
>  {{=A('delete 
> 123',callback=URL('delete',args=123),delete='#row123')}} ... 
>
>
> The delete argument indicates that upon success you want to remove the 
> ... from the page. If there is a "delete" argument 
> the confirmation popup is automatic. ;-)
>
> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:
>>
>> I want to do something very simple but it's taking me eons to do this~
>>
>> When the button is clicked, I want a javascript alert to pop up that 
>> asks, are you sure? Yes/No.
>> If Yes, then run this code: auth.del_membership('role')
>>
>> No redirection, just delete the role.
>> That's all -_- this is taking me way too long
>>
>> On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:
>>>
>>> None. You are asking to ":eval" the result. It meas the action is 
>>> supposed to return JS
>>>
>>> def test():
>>> return "alert('hello')"
>>>
>>> anyway, you should debug this with the JS console in chrome. We do not 
>>> know exactly how your code looks like.
>>>
>>> On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote:

 I am trying with:
 {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", 
 callback=URL('test'), target=":eval")}}

 and in my controller:

 def test():
 return "Hello"

 or 

 def test():
 return dict()

 but when I click the button, nothing happens. Why is this??

 On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote:
>
> When I use form.add_button() I am able to add a button to a form, 
> which I can display with {{=form}} in my view.
>
> However, if I'm making a custom form using form.custom, how can I 
> display that button??
>
> Thanks
>


-- 





[web2py] Re: web3py?

2012-12-18 Thread Massimo Di Pierro
No question he is reinventing web2py helpers. They look almost identical. 
In fact an acknowledgement would be in order. Web2py helpers have been 
around almost unchanged since Oct 2007.

I agree he is adding context managers. We did not create them not because 
we did not think about them but because we were supporting python 2.4 which 
does not have a with statement.

There is a problem with minima's syntax.
It can do

   with div.myclass: 

but this means you cannot "myclass" be a name of a method or attribute of 
div. Also you cannot do

   with div#myid:  

so this tries use the css / haml syntax in Python but only partially 
succeed.

In web3py we have helpers.py which are almost identical to web2py helpers 
but faster and simpler. I just added contexts (it took 10 lines of code, 
pretty much the same as in minima's, I will post the code later today).

https://github.com/mdipierro/web3py/commit/41a5c0f7e47e87e2bafdb5bef1f85df562803d8d

It allows this:

from web3py helpers import tag
div, h1, p = tag.div, tag.h1, tag.p

with div(_class='test') as html:
h1('title')
p('hello world')
print html

I like it. It is slightly different from minima's but it will stay in. 
Perhaps we should backport it to web2py.

Massimo 

 

On Tuesday, 18 December 2012 03:04:10 UTC-6, Arnon Marcus wrote:
>
> Has anybody taken a look at this?
>
> http://tomerfiliba.com/blog/Hypertext/
>
> My first reaction was "oh my, the poor guy is reinventing the wheel that 
> already exists in web2py..."
> Then a friend of mine pointed out that:
> "
> ...context managers allow your code structure to correlate to the the 
> html layout, through nesting blocks. that's the key difference
> "
>
> Is he correct?
> Could this be implemented in web3py's HTML helpers?
>

-- 





Re: [web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Richard Vézina
Is there something different with psycopg2 under web2py 2.3.2 ?

I get this error on a new server that I configure :

 Failure to connect, tried 5 times:
Traceback (most recent call last): File
"/home/www-data/web2py/gluon/dal.py", line 6853, in __init__ self._adapter
= ADAPTERS[self._dbname](**kwargs) File
"/home/www-data/web2py/gluon/dal.py", line 2493, in __init__ if do_connect:
self.find_driver(adapter_args,uri) File
"/home/www-data/web2py/gluon/dal.py", line 704, in find_driver raise
RuntimeError("driver %s not available" % request_driver) RuntimeError:
driver psycopg2 not available

python-psycopg2 is installed

For some reason I had to add apdater to my connection string like this :

db=DAL('postgres:psycopg2:...)

Because if I didn't not precise it, web2py seems to use pg8000 and I get
this error with pg8000 :

 invalid literal for int() with base 10:
'SELECT'

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/home/www-data/web2py/applications/sgddms/models/dict.py", line
121, in 
for r in db().select(db.dict_database.table_name,
db.dict_database.column_name, db.dict_database.column_name_en_ui)])
  File "/home/www-data/web2py/gluon/dal.py", line 8905, in select
return adapter.select(self.query,fields,attributes)
  File "/home/www-data/web2py/gluon/dal.py", line 1631, in select
return self._select_aux(sql,fields,attributes)
  File "/home/www-data/web2py/gluon/dal.py", line 1597, in _select_aux
rows = self._fetchall()
  File "/home/www-data/web2py/gluon/dal.py", line 1590, in _fetchall
return self.cursor.fetchall()
  File "/home/www-data/web2py/gluon/contrib/pg8000/dbapi.py", line 246, in
_fn
return fn(self, *args, **kwargs)
  File "/home/www-data/web2py/gluon/contrib/pg8000/dbapi.py", line 414, in
fetchall
return tuple(self.cursor.iterate_tuple())
  File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 76,
in next
retval = self.func(self.obj)
  File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 270,
in read_tuple
return self._fetch()
  File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 205,
in _fetch
self._fill_cache()
  File "/home/www-data/web2py/gluon/contrib/pg8000/interface.py", line 190,
in _fill_cache
end_of_data, rows = self.c.fetch_rows(self._portal_name,
self.row_cache_size, self._row_desc)
  File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 943,
in _fn
return fn(self, *args, **kwargs)
  File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 1249,
in fetch_rows
retval = reader.handle_messages()
  File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 906,
in handle_messages
msg = self._conn._read_message()
  File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 1038,
in _read_message
msg = message_types[message_code].createFromData(bytes)
  File "/home/www-data/web2py/gluon/contrib/pg8000/protocol.py", line 783,
in createFromData
args['rows'] = int(values[-1])
ValueError: invalid literal for int() with base 10: 'SELECT'


I never really use pg8000, because it didn't works for me, maybe because of
my app code or issue with pg8000 in web2py, but I am more inclined in the
former (my app code).


I use ubuntu 12.10 and a custom Nginx installation with uwsgi emperor mode.

Could it be only because web2py is missing a dependance?

Thanks

Richard


On Tue, Dec 18, 2012 at 5:23 AM, Niphlod  wrote:

> totally unrelated epydoc folder in examples/static is 22mb. Leaving
> that one out and artwork.tar.gz (that seems to be a compressed version of
> examples/static/images) takes the compressed binary down to ~10 MB
> compressed/25MB uncompressed.
> Maybe a little cleanup in the next release will save everyone a few MB ?
>
>
> On Tuesday, December 18, 2012 9:20:54 AM UTC+1, apps in tables wrote:
>>
>> sorry, both are 45 mb after unzipping, (examples application 25 mb).
>>
>> On Tuesday, December 18, 2012 7:34:22 AM UTC+3, Massimo Di Pierro wrote:
>>>
>>> Are you sure about this? I cannot explain it. What's in the extra +30MB?
>>>
>>> On Monday, 17 December 2012 21:27:44 UTC-6, apps in tables wrote:


 another advantage:

 2.3.1 is 45 mb
 2.3.2 is 15 mb

 smaller is nicer...:)


 On Monday, December 17, 2012 6:11:19 PM UTC+3, Massimo Di Pierro wrote:
>
> It is the same as 2.3.2 but fixed a major bug with NEWINSTALL being
> ignored and therefore not creating the welcome.w2p for the new scaffolding
> app.
>
> If you are using 2.3.1 you may still be using an older welcome instead
> of the cool new one. Upgrade to 2.3.2 to fix this.
>
> Massimo
>
  --
>
>
>
>

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread Vinicius Assef
Well, if you started your app based on welcome app in Web2py 2.2.1 you
should have your default layout.html view linking bootstrap css.


On Tue, Dec 18, 2012 at 12:56 PM, António Ramos  wrote:
> 2.2.1!
> windows version
>
> 2012/12/18 Vinicius Assef 
>>
>> What version are you using?
>>
>> Bootstrap came in version 2.0.1
>>
>>
>>
>> On Tue, Dec 18, 2012 at 12:12 PM, António Ramos 
>> wrote:
>> > I dont see it in my app static folder nor through web inspection...
>> >
>> > Where is it?
>> >
>> > 2012/12/18 Vinicius Assef 
>> >>
>> >> It's already embedded.
>> >>
>> >> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos 
>> >> wrote:
>> >> > Hello, just a simple question
>> >> > how do i use twitter bootstrap with web2py?
>> >> > thank you
>> >> > António
>> >> >
>> >> >
>> >> > 2012/12/18 LightDot 
>> >> >>
>> >> >> Looks nice. There are also:
>> >> >>
>> >> >> http://bootswatchr.com/
>> >> >> and
>> >> >> http://bootswatcher.com/
>> >> >>
>> >> >> Names are similar, but they're not related. The latter allows you to
>> >> >> start
>> >> >> with an existing Bootswatch theme and go from there.
>> >> >>
>> >> >> Regards,
>> >> >> Ales
>> >> >>
>> >> >>
>> >> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro
>> >> >> wrote:
>> >> >>>
>> >> >>> http://www.boottheme.com/#generatetheme
>> >> >>
>> >> >> --
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >>
>> >>
>> >>
>> >
>> > --
>> >
>> >
>> >
>>
>> --
>>
>>
>>
>
> --
>
>
>

-- 





[web2py] Re: tuple to gluon.dal.Rows conversion

2012-12-18 Thread Anthony
See http://web2py.com/books/default/chapter/29/06#executesql. Note that 
executesql() takes optional "fields" and "colnames" arguments -- if you 
provide one or the other, it will automatically convert the results to a 
Rows object.

Anthony

On Tuesday, December 18, 2012 9:14:14 AM UTC-5, at wrote:
>
>
> Can we convert tuple to gluon.dal.Rows (and vise verse) using any standard 
> function?
>
> The requirement is to convert executesql results to gluon.dal.Rows.
>
> Thanks in advance
>

-- 





[web2py] web2py 2.3.2 added "+ -" to some form elements

2012-12-18 Thread Daniele
The newest version of web2py has added some + and - clickable links to form 
elements so that it is possible to remove the element. However, if there is 
only one element and one clicks the "-", the form disappears and there's no 
way to get the form element back without refreshing the page.

I'll post an image so that you can see what it looks like.

I think this is a bug with the newest version because my code hasn't 
changed at all. There was only a "+" before...

-- 



<><>

Re: [web2py] formatting time string during field update

2012-12-18 Thread Carlos Costa
In web2py_ajax.html there is the format that is used for jquery, try that.


2012/12/18 marino segnan 

> Hello,
>
> I am a beginner with web2py and I have this apparently simple problem.
> I have a db table:
>
>   db.define_table('tappe',
>Field('ora','time',requires=IS_TIME('%H:%M'))
> )
>
> I would like to display the time in  all the forms
> always in the same format as the validator, foe example '12:13'
> but:
>
> 1)  I tried represent(..) and works only in crud.read(..);
>crud.update(..) ignores it
>
> 2) I tried using SQLFORM(..) and changed the variable value, eg.
>
>  form.vars.ora = row.ora.strftime('%H:%M')
>
>  and the string is temporarily formatted as requested,
>  but when I edit it, it changes again to ' %H:%M:%S'
>
> What am I missing?
> What is the recommended solution?
>
> Thanks in advance.
>
> --
>
>
>
>



-- 
Att.

Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן

-- 





Re: [web2py] refresh div in a html page (web2py)

2012-12-18 Thread Carlos Costa
What you get when you access the test2.html url in the browser?
Maybe the url is wrong.
Try to inspect using firebug in error console.


2012/12/18 yn yn 

> Hi I am starting using web2py. I have a page web Test.html in view with a
> div: . On the other hand, I have a page web in the same folder: Test2.html
> with some code in python:
>
> {{items = ['a', 'b', 'c']}}{{i=1}}{{for item in items:}}
> 
> SOME CONTENT
> {{i=i+1}}{{pass}}
>
> How can I do to put the Test2.html content in the div IDtest? any example?
> Thanks. The goal is to learn how to insert a dynamic table in IDtest. I
> mean, I would refresh the IDtest content afther pushing a button for
> example
>
> LAST TEST: I have tested
>
>  type="text/javascript"> ... and then 

[web2py] Re: web2py performance, without db

2012-12-18 Thread Massimo Di Pierro
One more thing, which may not be relevant in your case,... do not run 
benchmarks from web2py running under a dropbox folder or a 
remotely mounted folder. They cause significative performance penalties.

On Monday, 17 December 2012 18:23:57 UTC-6, Daniel Gonzalez wrote:
>
> Hi,
>
> I am trying to get some metrics on my installation. For that I have 
> disabled the database (db=None) and I am requesting a very simple 
> controller:
>
> def hello1():
> return "Hello World"
>
> I have a multi-threaded test program which is sending requests to web2py 
> (using WebClient). I have let my test run for several iterations, and I got 
> the following metrics:
>
> CLIENTS ROUNDS ELLAPSED (s)TOT REQ   AVG (ms)  REQ/s
>   8 72 17.969576 31.197  32.05
>   9 25  6.973225 30.991  32.27
>   6  4  0.748 24 31.179  32.07
>   7 17  3.645119 30.634  32.64
>   7 58 12.340406 30.393  32.90
>   3 73  6.751219 30.827  32.44
>  10 12  3.399120 28.329  35.30
>   4 32  3.941128 30.791  32.48
>   1 27  0.742 27 27.496  36.37
>   8 58 14.156464 30.508  32.78
>   4 31  3.574124 28.819  34.70
>   8 14  3.274112 29.232  34.21
>   9 68 18.722612 30.591  32.69
>   9 81 22.070729 30.275  33.03
>   4 47  6.031188 32.079  31.17
>   7 75 15.491525 29.506  33.89
>   1 90  2.495 90 27.719  36.08
>   8 38  9.495304 31.234  32.02
>   2 60  4.000120 33.335  30.00
>   2 81  5.057162 31.214  32.04
>
> (CLIENTS is the number of active threads, ROUNDS is the number of requests 
> that each thread performs)
>
> As you see, I am getting quite stable speed of between 30 and 36 
> requests/s.
> This is fine, but 32 req/s is quite low. My system is (this is my 
> development system, an HP 635):
>
>- web2py 2.0.2
>- 2 cores, AMD E-450 
>- 4 GB RAM
>- Linux 2.6.32-5-686
>- CrunchBang Linux statler
>- Python 2.7.2
>- I am using Rocket
>- No apache (or any other frontend). Directly accessing localhost:8000
>- web2py and my test program are sharing the same machine.
>
> I would like to optimize these parameters before moving to production. Is 
> there something obvious that I could try to improve these metrics?
> Is 30 req/s an expected value for such a simple test? I expected more than 
> 100 req/s.
>
> Now that I am writing and thinking about this, I am not even sure if the 
> limiting factor is web2py or my test program ... How could I know which 
> party is "saturating"?
>
> Thanks,
>
> Daniel
>

-- 





[web2py] Re: REF: Displaying a Virtual Field in SQLFORM.grid throws an exception....

2012-12-18 Thread Massimo Di Pierro
Right now grid does not work with virtual fields. There is a pending 
proposal for enhancement to support them.

On Tuesday, 18 December 2012 01:03:05 UTC-6, software.ted wrote:
>
> Does SQLFORM.grid support adding and display of a virtual field...am 
> getting an exception...my code:
>
> db.file_subject_issue.file_name = Field.Virtual(lambda row: 
> get_file_name(row.file_subject_issue.file_id))
> fields = [db.file_subject_issue.file_id, 
> db.file_subject_issue.date_created, db.file_subject_issue.file_name]
> query =
>
> form = SQLFORM.grid(query,fields=fields,...)
>
> I am getting the error
>
>  'FieldVirtual' object has no attribute 
> '_tablename'
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
>
> exec ccode in environment
>   File 
> "/home/www-data/web2py/applications/intranet/controllers/administration.py" 
> ,
>  line 176, in 
>
>   File "/home/www-data/web2py/gluon/globals.py", line 188, in 
>
> self._caller = lambda f: f()
>
>   File 
> "/home/www-data/web2py/applications/intranet/controllers/administration.py" 
> ,
>  line 71, in file_track
>
> selectable=False,csv=False , paginate=20, user_signature=False)
>
>   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1796, in grid
>
> if field._tablename in tablenames]
> AttributeError: 'FieldVirtual' object has no attribute '_tablename'
>
>
>
>
> -- 
>
> ...
> Teddy Lubasi Nyambe
> Opensource Zambia
> Lusaka, ZAMBIA
>
> Cell: +260 97 7760473
> website: http://www.opensource.org.zm
>
> ~/
> Human Knowledge belongs to the world! - AntiTrust
>
> Man is a tool-using animal. Without tools he is nothing, with tools he is 
> all - Thomas Carlyle 1795-1881
>
> /~
>  

-- 





Re: [web2py] Re: REF: SQLFORM.grid error

2012-12-18 Thread Massimo Di Pierro
I will edit the code to make it work as in the slice.

On Monday, 17 December 2012 23:38:11 UTC-6, software.ted wrote:
>
> Hi Massimo!
>
> It works thanks, the slice I am following is very useful and popular that 
> error must be edited.
>
> Teddy L.
>
>
> On Mon, Dec 17, 2012 at 5:09 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> Replace
>>
>>  fields = 
>> (db.file_transaction.file_id,**db.file_transaction.source_**office_id, 
>> \
>> db.file_transaction.**destination_office_id, 
>> db.file_transaction.**transaction_date_time)
>>
>> with
>>
>>  fields = 
>> [db.file_transaction.file_id,**db.file_transaction.source_**office_id, 
>> \
>> db.file_transaction.**destination_office_id, 
>> db.file_transaction.**transaction_date_time]
>>
>> On Monday, 17 December 2012 08:58:36 UTC-6, software.ted wrote:
>>>
>>> I am trying to set the fields to display in my grid...I am following the 
>>> slice at 
>>> http://www.web2pyslices.**com/slice/show/1471/**sqlformgrid,
>>>  however, I am having an error with fields...I am using it as follows and 
>>> I getting an error as below:
>>>
>>> links = [lambda row: A('View Post',_href=URL("**
>>> administration","file_details"**,args=[row.file_transaction.**
>>> file_id]))]
>>> fields = (db.file_transaction.file_id,**db.file_transaction.source_*
>>> *office_id, \
>>> db.file_transaction.**destination_office_id, 
>>> db.file_transaction.**transaction_date_time)
>>> query = ((db.file_subject_issue.**circulation_status==True) & 
>>> (db.file_transaction.file_**subject_issue_id == db.file_subject_issue.id
>>> ))
>>> form = SQLFORM.grid(query,searchable=**True,links=links, 
>>> fields=fields, deletable=False, \
>>> details=False, editable=False, \
>>> selectable=False,csv=False , paginate=20, 
>>> user_signature=False)
>>>
>>> Error:
>>>
>>>  'tuple' object has no attribute 
>>> 'append'
>>>
>>>
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in 
>>> restricted
>>>
>>>
>>> exec ccode in environment
>>>   File 
>>> "/home/www-data/web2py/**applications/intranet/**controllers/administration.py"
>>>  
>>> **,
>>>  line 175, in 
>>>
>>>
>>>   File "/home/www-data/web2py/gluon/**globals.py", line 188, in 
>>>
>>>
>>> self._caller = lambda f: f()
>>>
>>>
>>>   File 
>>> "/home/www-data/web2py/**applications/intranet/**controllers/administration.py"
>>>  
>>> **,
>>>  line 70, in file_track
>>>
>>>
>>> selectable=False,csv=False , paginate=20, user_signature=False)
>>>
>>>
>>>   File "/home/www-data/web2py/gluon/**sqlhtml.py", line 1799, in grid
>>>
>>>
>>> fields.append(field_id)
>>>
>>> AttributeError: 'tuple' object has no attribute 'append'
>>>
>>>
>>> -- Teddy L
>>>  
>>  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>
> ...
> Teddy Lubasi Nyambe
> Opensource Zambia
> Lusaka, ZAMBIA
>
> Cell: +260 97 7760473
> website: http://www.opensource.org.zm
>
> ~/
> Human Knowledge belongs to the world! - AntiTrust
>
> Man is a tool-using animal. Without tools he is nothing, with tools he is 
> all - Thomas Carlyle 1795-1881
>
> /~
>  

-- 





[web2py] Re: Login manually

2012-12-18 Thread Massimo Di Pierro
Which web2py version? The error suggests you are using an older web2py 
version with newly created database of records.

Massimo

On Monday, 17 December 2012 14:59:02 UTC-6, Wonton wrote:
>
> Hello everyone,
>
> I'm developing a backend site with web2py. I have 2 web services, one to 
> register a user and a second one to login the user.
> This is the first one:
>
> def register(user, email, password):
>  db.auth_user.insert(username=user, email=email, 
> password=db.auth_user.password.validate(password)) 
> ...
>  return 'OK'
>
> It's working ok and the users are created without problem.
>
> This is the second one:
>
> def login(user, password):
> response = auth.login_bare(user, password)
>  if not response:
> message = 'Error'
> else:
>  message = 'OK'
>return message
>
> With this service I have the following error:
>  unsupported hash type 
> |pbkdf2(1000,20,sha512)
>
> I've tried to find any solution to this problem without success.
>
> Any of you has any idea of what is happening?
>
> Thank you very much and kind regards!
>
> Wonton
>

-- 





[web2py] Re: Firewalls, restrictions and appending to two tables

2012-12-18 Thread Ron McOuat

The error traceback is saying the connection to the database could not be 
opened. The problem should be in the model file that has

db=DAL(.), 

the first parameter is the connection information. If the database is on 
another machine and a firewall is in the way you won't have any ability to 
connect. If you can't work out what is wrong on that line then post the 
model file.

-- 





[web2py] Re: Transactions in Web2Py over Google App Engine.

2012-12-18 Thread José Manuel López Muñoz
Thank you all for the answers, 
I finally have created a function and run it in a transaction.
Regards.

On Thursday, November 29, 2012 11:18:47 AM UTC+1, José Manuel López Muñoz 
wrote:
>
> I'm making a room reservation system in Web2Py over Google App Engine. 
> When a user is booking a Room the system must be sure that this room is 
> really available and no one else have reserved it just a moment before. To 
> be sure I make a query to see if the room is available, then I make the 
> reservation. The problem is how can I do this transaction in a kind of 
> "Mutual exclusion" to be sure that this room is really for this user?
>
> Thank you!! :)
>

-- 





[web2py] formatting time string during field update

2012-12-18 Thread marino segnan
Hello,

I am a beginner with web2py and I have this apparently simple problem.
I have a db table:

  db.define_table('tappe',
   Field('ora','time',requires=IS_TIME('%H:%M'))
)

I would like to display the time in  all the forms 
always in the same format as the validator, foe example '12:13'
but:

1)  I tried represent(..) and works only in crud.read(..); 
   crud.update(..) ignores it

2) I tried using SQLFORM(..) and changed the variable value, eg. 

 form.vars.ora = row.ora.strftime('%H:%M')

 and the string is temporarily formatted as requested,
 but when I edit it, it changes again to ' %H:%M:%S'

What am I missing?
What is the recommended solution?

Thanks in advance.

-- 





[web2py] Re: help with login

2012-12-18 Thread Wonton
Hello Derek!

I have this problem too but I have OpenSSL installed, in fact, I've used 
OpenSSL to build server.crt and server.key files so I can gain access to my 
web2py site using https.

If it helps, I'm nowadays working on localhost, using web2py from source 
code (not the binary), and I'm using https access wouthout any problem .


On Tuesday, December 18, 2012 12:06:30 AM UTC+1, Derek wrote:
>
> Make sure you have OpenSSL installed.
>
> On Monday, December 17, 2012 4:04:51 PM UTC-7, Derek wrote:
>>
>> This is telling me that your system doesn't support sha512?
>>
>> On Monday, December 17, 2012 3:31:48 PM UTC-7, samuel bonilla wrote:
>>>
>>> @servicios_publicos.json
>>> def login(usuario, password):
>>> respuesta = {}
>>> user = auth.login_bare(usuario, password)
>>> if not user:
>>> respuesta['estado'] = 'Error'
>>> respuesta['mensaje'] = 'Nombre de usuario o contraseña 
>>> incorrecta'
>>> else:
>>> respuesta['estado'] = 'OK'
>>> respuesta['mensaje'] = 'Login correcto'
>>> return respuesta
>>>
>>> i get this error
>>>
>>>  unsupported hash type 
>>> |pbkdf2(1000,20,sha512)
>>
>>

-- 





[web2py] refresh div in a html page (web2py)

2012-12-18 Thread yn yn
 

Hi I am starting using web2py. I have a page web Test.html in view with a 
div: . On the other hand, I have a page web in the same folder: Test2.html 
with some code in python:

{{items = ['a', 'b', 'c']}}{{i=1}}{{for item in items:}} 

SOME CONTENT
{{i=i+1}}{{pass}}

How can I do to put the Test2.html content in the div IDtest? any example? 
Thanks. The goal is to learn how to insert a dynamic table in IDtest. I 
mean, I would refresh the IDtest content afther pushing a button for 
example

LAST TEST: I have tested 

 ... and then 

[web2py] Re: web2py inline editable grid

2012-12-18 Thread Willoughby
I have a legacy system that uses JQGrid and it's a pain because the docs 
are lacking but it does work.
We do saving via a 'SAVE' button using jquery and the dirty-cell function 
of the grid.  This creates a string which is parsed by the controller and 
does an insert back into the DB.  There may be a better way now, but that's 
what I inherited...

You can do drop downs and all sorts of things - there was an interactive 
example page on their wiki if I remember.



-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread António Ramos
2.2.1!
windows version

2012/12/18 Vinicius Assef 

> What version are you using?
>
> Bootstrap came in version 2.0.1
>
>
>
> On Tue, Dec 18, 2012 at 12:12 PM, António Ramos 
> wrote:
> > I dont see it in my app static folder nor through web inspection...
> >
> > Where is it?
> >
> > 2012/12/18 Vinicius Assef 
> >>
> >> It's already embedded.
> >>
> >> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos 
> >> wrote:
> >> > Hello, just a simple question
> >> > how do i use twitter bootstrap with web2py?
> >> > thank you
> >> > António
> >> >
> >> >
> >> > 2012/12/18 LightDot 
> >> >>
> >> >> Looks nice. There are also:
> >> >>
> >> >> http://bootswatchr.com/
> >> >> and
> >> >> http://bootswatcher.com/
> >> >>
> >> >> Names are similar, but they're not related. The latter allows you to
> >> >> start
> >> >> with an existing Bootswatch theme and go from there.
> >> >>
> >> >> Regards,
> >> >> Ales
> >> >>
> >> >>
> >> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro
> >> >> wrote:
> >> >>>
> >> >>> http://www.boottheme.com/#generatetheme
> >> >>
> >> >> --
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> >
> >> >
> >> >
> >>
> >> --
> >>
> >>
> >>
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread Vinicius Assef
What version are you using?

Bootstrap came in version 2.0.1



On Tue, Dec 18, 2012 at 12:12 PM, António Ramos  wrote:
> I dont see it in my app static folder nor through web inspection...
>
> Where is it?
>
> 2012/12/18 Vinicius Assef 
>>
>> It's already embedded.
>>
>> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos 
>> wrote:
>> > Hello, just a simple question
>> > how do i use twitter bootstrap with web2py?
>> > thank you
>> > António
>> >
>> >
>> > 2012/12/18 LightDot 
>> >>
>> >> Looks nice. There are also:
>> >>
>> >> http://bootswatchr.com/
>> >> and
>> >> http://bootswatcher.com/
>> >>
>> >> Names are similar, but they're not related. The latter allows you to
>> >> start
>> >> with an existing Bootswatch theme and go from there.
>> >>
>> >> Regards,
>> >> Ales
>> >>
>> >>
>> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro
>> >> wrote:
>> >>>
>> >>> http://www.boottheme.com/#generatetheme
>> >>
>> >> --
>> >>
>> >>
>> >>
>> >
>> >
>> > --
>> >
>> >
>> >
>>
>> --
>>
>>
>>
>
> --
>
>
>

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2012-12-18 Thread Richard Vézina
I will, when I finish my research.

I am planning to write a slice about deployment of Redmine beside Web2py
with Nginx. So until I finish my Nginx config in case I found other tweaks,
I wait for testing the script again. But I have a fresh VM in place that I
can clone rapidly to for testing purpose, so when I am ready, it will not
be a big task.

:)

Richard

On Tue, Dec 18, 2012 at 4:17 AM, Niphlod  wrote:

> At this point I did a bit of research.
>
> https://github.com/ioerror/duraconf/blob/master/configs/nginx/nginx.conf
>
> updated the script to reflect those, but I can't test it. Can you please ?
>
> --
>
>
>
>

-- 





[web2py] Documentation bug, mail attachment initializer

2012-12-18 Thread Nick Vargish
Hi folks,

Just a quick documentation bug: 
In http://web2py.com/books/default/chapter/29/08#Sending-emails, the 
attachment object initializer is referred to as "Mail.Attachment()". It 
took me a little experimentation, but I had to use "mail.Attachment()" for 
things to work. Someone might want to update the documentation to reflect 
the correct case.

Many thanks to Massimo and other contributors... Web2py has been an 
excellent tool for building our in-house applications.

Nick

-- 





[web2py] tuple to gluon.dal.Rows conversion

2012-12-18 Thread at

Can we convert tuple to gluon.dal.Rows (and vise verse) using any standard 
function?

The requirement is to convert executesql results to gluon.dal.Rows.

Thanks in advance

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread António Ramos
I dont see it in my app static folder nor through web inspection...

Where is it?

2012/12/18 Vinicius Assef 

> It's already embedded.
>
> On Tue, Dec 18, 2012 at 11:46 AM, António Ramos 
> wrote:
> > Hello, just a simple question
> > how do i use twitter bootstrap with web2py?
> > thank you
> > António
> >
> >
> > 2012/12/18 LightDot 
> >>
> >> Looks nice. There are also:
> >>
> >> http://bootswatchr.com/
> >> and
> >> http://bootswatcher.com/
> >>
> >> Names are similar, but they're not related. The latter allows you to
> start
> >> with an existing Bootswatch theme and go from there.
> >>
> >> Regards,
> >> Ales
> >>
> >>
> >> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro wrote:
> >>>
> >>> http://www.boottheme.com/#generatetheme
> >>
> >> --
> >>
> >>
> >>
> >
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread Vinicius Assef
It's already embedded.

On Tue, Dec 18, 2012 at 11:46 AM, António Ramos  wrote:
> Hello, just a simple question
> how do i use twitter bootstrap with web2py?
> thank you
> António
>
>
> 2012/12/18 LightDot 
>>
>> Looks nice. There are also:
>>
>> http://bootswatchr.com/
>> and
>> http://bootswatcher.com/
>>
>> Names are similar, but they're not related. The latter allows you to start
>> with an existing Bootswatch theme and go from there.
>>
>> Regards,
>> Ales
>>
>>
>> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro wrote:
>>>
>>> http://www.boottheme.com/#generatetheme
>>
>> --
>>
>>
>>
>
>
> --
>
>
>

-- 





Re: [web2py] How to access a Virtual Field

2012-12-18 Thread at
thanks for the prompt reply* ..
*If the old syntax is used (as below), how can we fetch the virtual field 
records?*

class MyVirtualFields(object):
  def name(self):
return myaes.decrypt(self.taxpayer.enc_name)
db.taxpayer.virtualfields.append(MyVirtualFields())*

web2py documentation says:
they do not appear in the list of db.table.fields and are not visualized by 
default in tables (TABLE) and grids (SQLFORM.grid, SQLFORM.smartgrid).

On Tuesday, 18 December 2012 18:33:43 UTC+5, Jose wrote:
>
>
>
> El martes, 18 de diciembre de 2012 10:24:08 UTC-3, at escribió:
>>
>> Using Version 1.99.7 stable on production and Version 2.2.1 stable on my 
>> development box.
>>
>> I've tried this out on version 2.2.1; it's giving error:
>>
>> db.define_table('taxpayer',
>> Field('name'),
>> Field('married', 'boolean'),
>> Field('spouse_name'),
>> Field.Virtual('namey',lambda row: row.taxpayer.name+'y'))
>> * __init__() takes exactly 2 arguments (3 
>> given)*
>
>
> because it is available since version 2.3.1
>
> José 
>

-- 





Re: [web2py] Re: bootstrap themes generator

2012-12-18 Thread António Ramos
Hello, just a simple question
how do i use twitter bootstrap with web2py?
thank you
António

2012/12/18 LightDot 

> Looks nice. There are also:
>
> http://bootswatchr.com/
> and
> http://bootswatcher.com/
>
> Names are similar, but they're not related. The latter allows you to start
> with an existing Bootswatch theme and go from there.
>
> Regards,
> Ales
>
>
> On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro wrote:
>>
>> http://www.boottheme.com/#**generatetheme
>>
>  --
>
>
>
>

-- 





Re: [web2py] How to access a Virtual Field

2012-12-18 Thread Jose


El martes, 18 de diciembre de 2012 10:24:08 UTC-3, at escribió:
>
> Using Version 1.99.7 stable on production and Version 2.2.1 stable on my 
> development box.
>
> I've tried this out on version 2.2.1; it's giving error:
>
> db.define_table('taxpayer',
> Field('name'),
> Field('married', 'boolean'),
> Field('spouse_name'),
> Field.Virtual('namey',lambda row: row.taxpayer.name+'y'))
> * __init__() takes exactly 2 arguments (3 
> given)*


because it is available since version 2.3.1

José 

-- 





Re: [web2py] How to access a Virtual Field

2012-12-18 Thread at
Using Version 1.99.7 stable on production and Version 2.2.1 stable on my 
development box.

I've tried this out on version 2.2.1; it's giving error:

db.define_table('taxpayer',
Field('name'),
Field('married', 'boolean'),
Field('spouse_name'),
Field.Virtual('namey',lambda row: row.taxpayer.name+'y'))
* __init__() takes exactly 2 arguments (3 
given)*

On Tuesday, 18 December 2012 17:32:00 UTC+5, viniciusban wrote:
>
> See this: http://web2py.com/examples/default/changelog 
>
>
> On Tue, Dec 18, 2012 at 8:29 AM, at > 
> wrote: 
> > Hello, 
> > 
> > Suppose I've following table def: in my db.py: 
> > 
> > db.define_table('taxpayer', 
> > Field('enc_name'), 
> > Field('age'), 
> > Field('married', 'boolean'), 
> > Field('spouse_name'), 
> > Field('occupation')) 
> > 
> > class MyVirtualFields(object): 
> >   def name(self): 
> > return myaes.decrypt(self.taxpayer.enc_name) 
> > 
> > db.taxpayer.virtualfields.append(MyVirtualFields()) 
> > 
> > (where myaes.decrypt is a function defined in myaes module) 
> > 
> > In the following code how can I access virtual field name? In 
> record_list I 
> > dont find name. 
> > myorder = db.taxpayer.id 
> > queryset = db(db.taxpayer) 
> > record_list = queryset.select(db.taxpayer.ALL, orderby = myorder) 
> > 
> > Thanks & Regards, 
> > AT 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] Re: bootstrap themes generator

2012-12-18 Thread LightDot
Looks nice. There are also:

http://bootswatchr.com/
and
http://bootswatcher.com/

Names are similar, but they're not related. The latter allows you to start 
with an existing Bootswatch theme and go from there.

Regards,
Ales


On Tuesday, December 18, 2012 4:24:48 AM UTC+1, Massimo Di Pierro wrote:
>
> http://www.boottheme.com/#generatetheme
>

-- 





Re: [web2py] How to access a Virtual Field

2012-12-18 Thread Vinicius Assef
See this: http://web2py.com/examples/default/changelog


On Tue, Dec 18, 2012 at 8:29 AM, at  wrote:
> Hello,
>
> Suppose I've following table def: in my db.py:
>
> db.define_table('taxpayer',
> Field('enc_name'),
> Field('age'),
> Field('married', 'boolean'),
> Field('spouse_name'),
> Field('occupation'))
>
> class MyVirtualFields(object):
>   def name(self):
> return myaes.decrypt(self.taxpayer.enc_name)
>
> db.taxpayer.virtualfields.append(MyVirtualFields())
>
> (where myaes.decrypt is a function defined in myaes module)
>
> In the following code how can I access virtual field name? In record_list I
> dont find name.
> myorder = db.taxpayer.id
> queryset = db(db.taxpayer)
> record_list = queryset.select(db.taxpayer.ALL, orderby = myorder)
>
> Thanks & Regards,
> AT
>
> --
>
>
>

-- 





Re: [web2py] Can we override DAL methods?

2012-12-18 Thread Vinicius Assef
In stable version there is a simpler way to define virtual fields. See
this: http://web2py.com/examples/default/changelog


On Tue, Dec 18, 2012 at 9:26 AM, at  wrote:
> Thanks for your reply; I am trying to use virtual fields but unable to fetch
> records.
>
> my db.py defines:
> db.define_table('taxpayer',
> Field('enc_name'),
> Field('age'),
> Field('married', 'boolean'),
> Field('spouse_name'),
> Field('occupation'))
>
> class MyVirtualFields(object):
>   def name(self):
> return myaes.decrypt(self.taxpayer.enc_name)
>
> db.taxpayer.virtualfields.append(MyVirtualFields())
>
> (where myaes.decrypt is a function defined in myaes module)
>
> In the following code how can I access virtual field name? In record_list I
> dont find name.
> myorder = db.taxpayer.id
> queryset = db(db.taxpayer)
> record_list = queryset.select(db.taxpayer.ALL, orderby = myorder)
>
> Thanks & Regards,
>
>
>
> On Friday, 14 December 2012 19:38:28 UTC+5, viniciusban wrote:
>>
>> I think the most simple option in your situation is use computed fields.
>>
>> But if you really need to use a SQL function, you should write your
>> query by hand.
>>
>>
>>
>> On Thu, Dec 13, 2012 at 3:48 PM, at  wrote:
>> >
>> > Hi,
>> >
>> > Lets say we've a table with name taxpayers; it contains 5 fields. Out of
>> > these 5, two start with ar_.
>> > What I want is to run some special function (say convertme() ) on these
>> > two
>> > fields starting with ar_ , while fetching data through DAL, like:
>> >
>> > query = (db.taxpayers.id > 10)
>> > result = db(query)
>> >
>> > Can we somehow override the above method in a way that it would run the
>> > following query:
>> > select field1, field2, convertme(ar_field3), field4,
>> > convertme(ar_field5)
>> > from taxpayers where id > 0
>> >
>> > Thanks in advance.
>> >
>> >
>> > --
>> >
>> >
>> >
>
> --
>
>
>

-- 





Re: [web2py] bootstrap themes generator

2012-12-18 Thread Vinicius Assef
Give this a try: http://www.lavishbootstrap.com



On Tue, Dec 18, 2012 at 1:24 AM, Massimo Di Pierro
 wrote:
> http://www.boottheme.com/#generatetheme
>
> --
>
>
>

-- 





[web2py] GAE + Cloud SQL: Tickets

2012-12-18 Thread Felipe Meirelles
Hi, I'm using GAE + Cloud SQL but every time I get an error, there is no 
ticket. Can I set web2py to save tickets to database as in Google NoSQL 
(big table)?

-- 





[web2py] Web2py thread management

2012-12-18 Thread Daniel Gonzalez
Hi,

How are threads managed in web2py? I am stress testing with a multithreaded 
programm, and I see that web2py spawns 14 "worker threads".
These threads are not created/destroyed, but seem to run forever.

python,8698 web2py.py -a 
  |-{python},9005
  |-{python},9023
  |-{python},9042
  |-{python},9043
  |-{python},9044
  |-{python},9050
  |-{python},9051
  |-{python},9053
  |-{python},9054
  |-{python},9055
  |-{python},9057
  |-{python},9058
  |-{python},9059
  `-{python},9060

I have several questions:

   - How do these threads map to the requests? Does each thread serve a 
   request?
   - That means web2py can maximally cope with 14 parallel requests?
   - Is this number (14) configurable?
   - Are the objects defined in the models initialized at thread creation, 
   and then reused for all requests?

Thanks,

Daniel

-- 





Re: [web2py] Can we override DAL methods?

2012-12-18 Thread at
Thanks for your reply; I am trying to use virtual fields but unable to 
fetch records. 

my db.py defines:
*db.define_table('taxpayer',
Field('enc_name'),
Field('age'),
Field('married', 'boolean'),
Field('spouse_name'),
Field('occupation'))

class MyVirtualFields(object):
  def name(self):
return myaes.decrypt(self.taxpayer.enc_name)

db.taxpayer.virtualfields.append(MyVirtualFields())

*(where myaes.decrypt is a function defined in myaes module)*

*In the following code how can I access virtual field name? In *record_list 
*I dont find *name**.**
myorder = db.taxpayer.id
queryset = db(db.taxpayer)
record_list = queryset.select(db.taxpayer.ALL, orderby = myorder)
**
*Thanks & Regards,



On Friday, 14 December 2012 19:38:28 UTC+5, viniciusban wrote:
>
> I think the most simple option in your situation is use computed fields. 
>
> But if you really need to use a SQL function, you should write your 
> query by hand. 
>
>
>
> On Thu, Dec 13, 2012 at 3:48 PM, at > 
> wrote: 
> > 
> > Hi, 
> > 
> > Lets say we've a table with name taxpayers; it contains 5 fields. Out of 
> > these 5, two start with ar_. 
> > What I want is to run some special function (say convertme() ) on these 
> two 
> > fields starting with ar_ , while fetching data through DAL, like: 
> > 
> > query = (db.taxpayers.id > 10) 
> > result = db(query) 
> > 
> > Can we somehow override the above method in a way that it would run the 
> > following query: 
> > select field1, field2, convertme(ar_field3), field4, 
> convertme(ar_field5) 
> > from taxpayers where id > 0 
> > 
> > Thanks in advance. 
> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] How to access a Virtual Field

2012-12-18 Thread at
Hello,

Suppose I've following table def: in my db.py:

*db.define_table('taxpayer',
Field('enc_name'),
Field('age'),
Field('married', 'boolean'),
Field('spouse_name'),
Field('occupation'))

class MyVirtualFields(object):
  def name(self):
return myaes.decrypt(self.taxpayer.enc_name)

db.taxpayer.virtualfields.append(MyVirtualFields())

*(where myaes.decrypt is a function defined in myaes module)*

*In the following code how can I access virtual field name? In *record_list 
*I dont find *name**.**
myorder = db.taxpayer.id
queryset = db(db.taxpayer)
record_list = queryset.select(db.taxpayer.ALL, orderby = myorder)
**
*Thanks & Regards,
AT

-- 





[web2py] Re: web2py 2.3.2 is OUT

2012-12-18 Thread Niphlod
totally unrelated epydoc folder in examples/static is 22mb. Leaving 
that one out and artwork.tar.gz (that seems to be a compressed version of 
examples/static/images) takes the compressed binary down to ~10 MB 
compressed/25MB uncompressed.
Maybe a little cleanup in the next release will save everyone a few MB ?

On Tuesday, December 18, 2012 9:20:54 AM UTC+1, apps in tables wrote:
>
> sorry, both are 45 mb after unzipping, (examples application 25 mb).
>
> On Tuesday, December 18, 2012 7:34:22 AM UTC+3, Massimo Di Pierro wrote:
>>
>> Are you sure about this? I cannot explain it. What's in the extra +30MB?
>>
>> On Monday, 17 December 2012 21:27:44 UTC-6, apps in tables wrote:
>>>
>>>
>>> another advantage:
>>>
>>> 2.3.1 is 45 mb
>>> 2.3.2 is 15 mb
>>>
>>> smaller is nicer...:)
>>>
>>>
>>> On Monday, December 17, 2012 6:11:19 PM UTC+3, Massimo Di Pierro wrote:

 It is the same as 2.3.2 but fixed a major bug with NEWINSTALL being 
 ignored and therefore not creating the welcome.w2p for the new scaffolding 
 app.

 If you are using 2.3.1 you may still be using an older welcome instead 
 of the cool new one. Upgrade to 2.3.2 to fix this.

 Massimo

>>>

-- 





Re: [web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread at
@Niphlod

yes it worked :)
thanks a lot for all your help and quick support.

best regards,
AT

On Tuesday, 18 December 2012 15:06:49 UTC+5, Niphlod wrote:
>
> he is connecting fine but apparently messed up something because tables 
> were not created.
>
> @at: try to delete the taxpayer*.table file in the database folder, it 
> should trigger the migration.
>
> On Tuesday, December 18, 2012 10:56:38 AM UTC+1, Johann Spies wrote:
>>
>>
>>  
>>> Then I've define following statement in db.py:
>>> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>>>
>>
>> I do not use Windows but maybe you can try using the port number on which 
>> the postgresql-server is listening in your connection string eg.:
>>
>> *db = DAL('postgres://testuser:12345@localhost:5432/testdb')*
>>  
>> On Linux 5432 is the default port. 
>>
>> Also check your postgresql-logfile for possible problems.
>>
>> Regards
>> Johann
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>

-- 





Re: [web2py] SQLFORM.grid

2012-12-18 Thread Johann Spies
On 13 December 2012 23:08, Drew  wrote:

> Greetings,
>
> I'd like to use the sql 'distinct' in a SQLFORM.grid 'query', but it is
> only valid as parameter in the 'select' method.
> I guess the 'group' parameter to SQLFORM.grid would work, but then I have
> to build the columns to group by, which seems excessive.
>
> Is it possible to create or pass raw sql to create a 'query' object and
> pass as parameter to SQLFORM.grid?
>
> Many cool features of 'select' are not available in SQLFORM.grid, unless
> I'm missing something.
>
>
SQLFORM.grid is limited as far as complex queries is concerned.

You can try bypassing 'distinct'  with a clever use of 'groupby'.  I rarely
use 'distinct'  since I found that postgresql's 'group by' is a faster
option.

What I do in case of complex queries (also because it takes a lot of time
to execute) is to use db.executesql() and put the result in temporary
tables which then can be viewed quickly using SQLFORM.grid.

I use this technique for a series of standard queries.   The user then has
the option in the menu to update the query and wait for the result to
become available or view the last result immediately.

Here is an example of such a query which is not that complex but it takes
quite a while to execute:

 query = """
   SET SEARCH_PATH TO isi;

DROP TABLE IF EXISTS isi.nr_arts_per_journal;
CREATE TABLE isi.nr_arts_per_journal AS  (SELECT 1 as id, C.so,
A.py, COUNT(B.ut) AS aantal
 FROM
isi.rjoern_uitgawe A,
isi.rjoernaal C,
isi.rarticle B
WHERE
A.rj_id = C.uuid
AND
B.ui =  A.ui
GROUP BY C.so, A.py
ORDER BY count(B.ut) desc);
ALTER TABLE isi.nr_arts_per_journal
  OWNER TO crest; """

the table db.nr_arts_per_journal  has the following definition as model:

db.executesql("set search_path to isi;")

db.define_table('nr_arts_per_journal',
Field('so'),
Field('py'),
Field('aantal', "integer"),
migrate=False,
fake_migrate=True)

db.executesql("set search_path to isi, public;")

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread Niphlod
he is connecting fine but apparently messed up something because tables 
were not created.

@at: try to delete the taxpayer*.table file in the database folder, it 
should trigger the migration.

On Tuesday, December 18, 2012 10:56:38 AM UTC+1, Johann Spies wrote:
>
>
>  
>> Then I've define following statement in db.py:
>> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>>
>
> I do not use Windows but maybe you can try using the port number on which 
> the postgresql-server is listening in your connection string eg.:
>
> *db = DAL('postgres://testuser:12345@localhost:5432/testdb')*
>  
> On Linux 5432 is the default port. 
>
> Also check your postgresql-logfile for possible problems.
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





Re: [web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread Johann Spies
>
> Then I've define following statement in db.py:
> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>

I do not use Windows but maybe you can try using the port number on which
the postgresql-server is listening in your connection string eg.:

*db = DAL('postgres://testuser:12345@localhost:5432/testdb')*

On Linux 5432 is the default port.

Also check your postgresql-logfile for possible problems.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Passing an environment variable to wep2py

2012-12-18 Thread Kostas M

Thank you Massimo for the response.

os.environ["WEB2PY_USE_DB_TESTING"]= "1"   

is the correct way to set env. variables, and "modification of os.environ 
affect both the running program and subprocesses created by Python" (Python 
essential reference 4th ed.).

In my case after all, both ways are succeeding in transferring env 
variables to the models: either through passing a --config=MYCONFIG, or 
setting them in the setUP methods of unittest.TestCase subclasses. The 
problems were in the 'if' evaluation for the first case, and a restart of 
the shell in the second.. I chose finally the second method, as it does not 
create one more file (e.g. MYCONFIG.py) in the directories, and keeps the 
setting definition near where it belongs: at the unittest.TestCase 
construction.

-- 





Re: [web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread Muhammad Atif Ayaz
yes it's the same application that worked properly with sqlite and now I am
trying to connect it to new postgres db.
sql.log doesn't have a single error message.


On Tue, Dec 18, 2012 at 2:38 PM, Niphlod  wrote:

> yeah, but you must be sure that those refer to the new database: if it's
> the same app that worked with sqlite, those statements are for creating
> tables in the sqlite database, not the new postgres one.
>
> On Tuesday, December 18, 2012 10:04:22 AM UTC+1, at wrote:
>>
>>
>> databases/sql.log contains only success messages .. no errors there
>>
>>
>> On Tuesday, 18 December 2012 13:36:25 UTC+5, Niphlod wrote:
>>>
>>> see databases/sql.log to see what went wrong.
>>>
>>> On Tuesday, December 18, 2012 7:53:39 AM UTC+1, at wrote:


 Hi,

 Previously I was working on sqlite database with web2py. Now I've
 installed postgresql-9.1.7-1-windows-**x64, created a user role
 (testuser) and database (testdb) and tested connectivity using psql; all
 went fine.

 Then I've define following statement in db.py:
 *db = DAL('postgres://testuser:12345@localhost/testdb')*

 Previously it was:
 #db = DAL('sqlite://storage.sqlite')

 Web2py and application started successfully, but it doesn't create
 tables defined in db.py; consider the following def:
 *db.define_table('taxpayer',
 Field('name'),
 Field('married', 'boolean'),
 Field('spouse_name'))
 *
 When I try to insert records in this table, I get following error
 message:
  ('ERROR',
 '42P01', 'relation "taxpayer" does not exist')

 Can somebody help please ?

 Thanks & Regards
 AT



  --
>
>
>
>

-- 





[web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread Niphlod
yeah, but you must be sure that those refer to the new database: if it's 
the same app that worked with sqlite, those statements are for creating 
tables in the sqlite database, not the new postgres one.

On Tuesday, December 18, 2012 10:04:22 AM UTC+1, at wrote:
>
>
> databases/sql.log contains only success messages .. no errors there
>
>
> On Tuesday, 18 December 2012 13:36:25 UTC+5, Niphlod wrote:
>>
>> see databases/sql.log to see what went wrong. 
>>
>> On Tuesday, December 18, 2012 7:53:39 AM UTC+1, at wrote:
>>>
>>>
>>> Hi,
>>>
>>> Previously I was working on sqlite database with web2py. Now I've 
>>> installed postgresql-9.1.7-1-windows-x64, created a user role (testuser) 
>>> and database (testdb) and tested connectivity using psql; all went fine.
>>>
>>> Then I've define following statement in db.py:
>>> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>>>
>>> Previously it was:
>>> #db = DAL('sqlite://storage.sqlite')
>>>
>>> Web2py and application started successfully, but it doesn't create 
>>> tables defined in db.py; consider the following def:
>>> *db.define_table('taxpayer',
>>> Field('name'),
>>> Field('married', 'boolean'),
>>> Field('spouse_name'))
>>> *
>>> When I try to insert records in this table, I get following error 
>>> message:
>>>  ('ERROR', 
>>> '42P01', 'relation "taxpayer" does not exist')
>>>
>>> Can somebody help please ?
>>>
>>> Thanks & Regards
>>> AT
>>>
>>>
>>>
>>>

-- 





Re: [web2py] Re: SQLFORM.grid joins and view/edit

2012-12-18 Thread Johann Spies
On 17 December 2012 14:58, Michael Hall  wrote:

> Just bumping this as I am still struggling with view and edit for joined
> SQLFORM.grid's
>
> On Wednesday, 28 November 2012 11:17:36 UTC, Michael Hall wrote:
>>
>> I have a SQLFORM.grid with a join, however when I insert, edit or update
>> a record displayed in the grid I am only ever given a form for the parent
>> table.
>>
>> What is the preferred method for creating insert, update and delete forms
>> for a joined SQLFORM.grid? Common sense tells me that it is the method
>> outlines in chapter 7: "One form for multiple tables" but this uses form
>> factory which to my noobish eyes does not seem to cover updating the same
>> way as vanilla SQLFORM in chapter 7's "SQLFORM and insert/update/delete"
>>
>> Can I create multi table update forms with either of these?
>>
>>
>>
When inserting/updating more than one table I would use the SQLFORM.factory
method for multiple tables you refer to.

Regards
Johann

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Using contrib.webclient to test JSONRPC interfaces

2012-12-18 Thread Daniel Gonzalez
Indeed Massimo, that is the file.

Some comments:

   - I am forcing Content-Type to 'application/json-rpc' in WebClient.post
   - The data must be already json encoded
   - The opener.addheaders is still used, but since I am using 
   a urllib2.Request (to *really* force the Content-Type, which can not be 
   done with addheaders, as you can see in the previously linked StackOverflow 
   question), I would say the headers set with addheaders are not really 
   active.
   - That means self.detault_headers are probably not used
   - for jsonrpc post I have disabled form processing
   - and last but not least, my changes are based on 2.0.2. I assume no big 
   changes have been done for the WebClient since then, but I have not 
   verified.

I am not sure what are the implicactions of all these changes. Maybe some 
corrections are in order.

On Tuesday, December 18, 2012 4:27:26 AM UTC+1, Massimo Di Pierro wrote:
>
>  you point me to the file? Is it this one?
>
>
> https://github.com/gonvaled/web2py/blob/webclient_add_jsonrpc/gluon/contrib/webclient.py
>
>
> On Monday, 17 December 2012 14:01:18 UTC-6, Daniel Gonzalez wrote:
>>
>> I have slightly modified the WebClient to support jsonrpc. I am not sure 
>> everything is correctly covered, but it is suiting my needs.
>>
>> In case you are interested, you can see the changes here:
>>
>> https://github.com/gonvaled/web2py/tree/webclient_add_jsonrpc
>>
>> The biggest problem I had was 
>> that opener.addheaders.append((key,str(value))) is not working as (I) 
>> expected: the content-type is not rewritten:
>>
>> http://stackoverflow.com/questions/13920211/not-possible-to-set-content-type-to-application-json-using-urllib2
>>
>> On Monday, December 17, 2012 6:38:30 PM UTC+1, Daniel Gonzalez wrote:
>>>
>>> Hi,
>>>
>>> I am trying to understand how to use the included WebClient to test a 
>>> JSONRPC interface. One showstopper for me at the moment is that I see the 
>>> following in WebClient.post:
>>>
>>> # time the POST request
>>> data = urllib.urlencode(data)
>>> t0 = time.time()
>>> self.response = opener.open(self.url,data)
>>> self.time = time.time()-t0
>>>
>>> When doing JSONRPC accesses I do not want the data to be urlencoded. 
>>> Actually, I will prepare the data with json.dump, and I want WebClient to 
>>> POST it transparently (I guess this goes in the body of the POST request). 
>>> Is this at all possible? Is there an example of WebClient usage 
>>> for JSONRPC interfaces somewhere?
>>>
>>> Thanks,
>>> Daniel Gonzalez
>>>
>>

-- 





[web2py] Firewalls, restrictions and appending to two tables

2012-12-18 Thread Seelife
Hi Folks, this is a repost of the last question regarding networking over a 
windows work/lab network.  
We have quite restricted firewalls to protect from running unknown programs 
etc.

Can anyone suggest a way to deal with firewalls and run rocket so that we 
can share the App?
This is my usual error when rocket tries to open the welcome page is :


Traceback (most recent call last):
  File "gluon/restricted.py", line 205, in restricted
  File "F:/Web2Py/applications/welcome/models/db.py" 
, line 14, in 
  File "gluon/dal.py", line 5968, in __init__
RuntimeError: Failure to connect, tried 5 times:

I can open the admin area and edit the apps etc, just not run the app or 
welcome on the firewalled windows machines ... frustrating.

By the way - Im using Forms to add data to my table/s.
Is there a command I can replace Form with that I can update more than one 
table with data?
eg 2 tables  samples, donor
When I add data and submit to samples, I want to also update (append) the a 
common reference code to the donor table.
(The reference code is one we scan in) 

Thanks heaps...

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2012-12-18 Thread Niphlod
At this point I did a bit of research.

https://github.com/ioerror/duraconf/blob/master/configs/nginx/nginx.conf

updated the script to reflect those, but I can't test it. Can you please ?

-- 





[web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread at

databases/sql.log contains only success messages .. no errors there


On Tuesday, 18 December 2012 13:36:25 UTC+5, Niphlod wrote:
>
> see databases/sql.log to see what went wrong. 
>
> On Tuesday, December 18, 2012 7:53:39 AM UTC+1, at wrote:
>>
>>
>> Hi,
>>
>> Previously I was working on sqlite database with web2py. Now I've 
>> installed postgresql-9.1.7-1-windows-x64, created a user role (testuser) 
>> and database (testdb) and tested connectivity using psql; all went fine.
>>
>> Then I've define following statement in db.py:
>> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>>
>> Previously it was:
>> #db = DAL('sqlite://storage.sqlite')
>>
>> Web2py and application started successfully, but it doesn't create tables 
>> defined in db.py; consider the following def:
>> *db.define_table('taxpayer',
>> Field('name'),
>> Field('married', 'boolean'),
>> Field('spouse_name'))
>> *
>> When I try to insert records in this table, I get following error message:
>>  ('ERROR', '42P01', 
>> 'relation "taxpayer" does not exist')
>>
>> Can somebody help please ?
>>
>> Thanks & Regards
>> AT
>>
>>
>>
>>

-- 





[web2py] Re: web3py?

2012-12-18 Thread Arnon Marcus
Has anybody taken a look at this?

http://tomerfiliba.com/blog/Hypertext/

My first reaction was "oh my, the poor guy is reinventing the wheel that 
already exists in web2py..."
Then a friend of mine pointed out that:
"
...context managers allow your code structure to correlate to the the html 
layout, through nesting blocks. that's the key difference
"

Is he correct?
Could this be implemented in web3py's HTML helpers?

-- 





[web2py] Re: Webassets in web2py

2012-12-18 Thread Arnon Marcus
That's interesting - you seem to be using the e-mail response and not 
google-groups.
Try viewing this thread in google-groups, and see the difference.

In this case, I already found my error and corrected it inside the post 
itself, long before you corrected me.
I basically said what you said - CoffeCup (the real one) is not the answer.

It's kind of an interesting thing what happened here - because whenever I 
post something, it automatically sends you an email, than if I find out a 
mistake and correct it by editing the post itself, you will not get the 
updated version of my post - you will still have my original one in your 
mail to respond to...
Bummer...

On Tuesday, December 18, 2012 1:33:54 AM UTC+2, Niphlod wrote:
>
>
>
>> BTW, I actually DID mean coffeCup, It refers to the python module I 
>> referenced in my second post here:
>>
>> http://42coffeecups.com/
>>
>>  
> that page lends to something I can't trace to some source code doing that. 
> I found only tddspry and django couchdb adapter and some sites they made in 
> django.
> Googling around , this https://github.com/dsc/coffeecup is what are you 
> pointing to, I think. As stated clearly in the readme
>
> *CoffeeCup depends on CoffeeScript, which depends on 
> node.js
> .*
>  
> Sorry.
>

-- 





[web2py] Re: web2py performance, without db

2012-12-18 Thread Niphlod
the most important one is "do not use rocket". It's fine for small-medium 
traffic but against uwsgi or gunicorn suffers a lot.

On Tuesday, December 18, 2012 4:31:55 AM UTC+1, Massimo Di Pierro wrote:
>
> Do you have model files at all?
> tricks for speedup:
> - use web2py 2.3.2 (the 2.2.1 had some tricks for speedup)
> - bytecode compile the app
> - use a production web sever like nginx
> - remove language files
>
> I also would expect more then 100reqs/sec.
>
>
> On Monday, 17 December 2012 18:23:57 UTC-6, Daniel Gonzalez wrote:
>>
>> Hi,
>>
>> I am trying to get some metrics on my installation. For that I have 
>> disabled the database (db=None) and I am requesting a very simple 
>> controller:
>>
>> def hello1():
>> return "Hello World"
>>
>> I have a multi-threaded test program which is sending requests to web2py 
>> (using WebClient). I have let my test run for several iterations, and I got 
>> the following metrics:
>>
>> CLIENTS ROUNDS ELLAPSED (s)TOT REQ   AVG (ms)  REQ/s
>>   8 72 17.969576 31.197  32.05
>>   9 25  6.973225 30.991  32.27
>>   6  4  0.748 24 31.179  32.07
>>   7 17  3.645119 30.634  32.64
>>   7 58 12.340406 30.393  32.90
>>   3 73  6.751219 30.827  32.44
>>  10 12  3.399120 28.329  35.30
>>   4 32  3.941128 30.791  32.48
>>   1 27  0.742 27 27.496  36.37
>>   8 58 14.156464 30.508  32.78
>>   4 31  3.574124 28.819  34.70
>>   8 14  3.274112 29.232  34.21
>>   9 68 18.722612 30.591  32.69
>>   9 81 22.070729 30.275  33.03
>>   4 47  6.031188 32.079  31.17
>>   7 75 15.491525 29.506  33.89
>>   1 90  2.495 90 27.719  36.08
>>   8 38  9.495304 31.234  32.02
>>   2 60  4.000120 33.335  30.00
>>   2 81  5.057162 31.214  32.04
>>
>> (CLIENTS is the number of active threads, ROUNDS is the number of 
>> requests that each thread performs)
>>
>> As you see, I am getting quite stable speed of between 30 and 36 
>> requests/s.
>> This is fine, but 32 req/s is quite low. My system is (this is my 
>> development system, an HP 635):
>>
>>- web2py 2.0.2
>>- 2 cores, AMD E-450 
>>- 4 GB RAM
>>- Linux 2.6.32-5-686
>>- CrunchBang Linux statler
>>- Python 2.7.2
>>- I am using Rocket
>>- No apache (or any other frontend). Directly accessing localhost:8000
>>- web2py and my test program are sharing the same machine.
>>
>> I would like to optimize these parameters before moving to production. Is 
>> there something obvious that I could try to improve these metrics?
>> Is 30 req/s an expected value for such a simple test? I expected more 
>> than 100 req/s.
>>
>> Now that I am writing and thinking about this, I am not even sure if the 
>> limiting factor is web2py or my test program ... How could I know which 
>> party is "saturating"?
>>
>> Thanks,
>>
>> Daniel
>>
>

-- 





[web2py] Re: Unable to create/Insert-in tables in potgre database

2012-12-18 Thread Niphlod
see databases/sql.log to see what went wrong. 

On Tuesday, December 18, 2012 7:53:39 AM UTC+1, at wrote:
>
>
> Hi,
>
> Previously I was working on sqlite database with web2py. Now I've 
> installed postgresql-9.1.7-1-windows-x64, created a user role (testuser) 
> and database (testdb) and tested connectivity using psql; all went fine.
>
> Then I've define following statement in db.py:
> *db = DAL('postgres://testuser:12345@localhost/testdb')*
>
> Previously it was:
> #db = DAL('sqlite://storage.sqlite')
>
> Web2py and application started successfully, but it doesn't create tables 
> defined in db.py; consider the following def:
> *db.define_table('taxpayer',
> Field('name'),
> Field('married', 'boolean'),
> Field('spouse_name'))
> *
> When I try to insert records in this table, I get following error message:
>  ('ERROR', '42P01', 
> 'relation "taxpayer" does not exist')
>
> Can somebody help please ?
>
> Thanks & Regards
> AT
>
>
>
>

-- 





  1   2   >