[web2py] replace simplejson with ujson?

2013-01-15 Thread dederocks
According to ujson documentation, it is on average twice as fast as 
simplejson. Would it be an option to replace simplejson in web2py with 
ujson?
I read though that Massimo had to extend simplejson to deal with datetime 
values -- I don't know if it's possible to do the same with ujson.

-- 





[web2py] Re: OT -- PyCon registration open

2013-01-15 Thread Joe Barnhart
That's too bad Massimo. There's so many more places here in Santa Clara that 
you haven't visited yet! But I'll still be here the next time you can come and 
visit.

-- 





Re: [web2py] Re: Postgres : created new database, but tables not being create when I access the app

2013-01-15 Thread Johann Spies
On 6 January 2013 22:00, Anthony  wrote:

> See http://web2py.com/books/default/chapter/29/06#Migrations:
>
> The value of migrate is the filename (in the "databases" folder for the
> application) where web2py stores internal migration information for this
> table. These files are very important and should never be removed except
> when the entire database is dropped. In this case, the ".table" files have
> to be removed manually.
>
>
I regularly have situations where I have to delete a file for one table in
the "databases" folder on my development system.  In my view this advice in
the documentation is not practical.

Regards
Johann

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

-- 





Re: [web2py] Having some strange occurence with label printing and FPDF

2013-01-15 Thread Mariano Reingart
Hello Paul:

Could you send a sample without actual data?
(without the db query, so it can be reproduced)

fpdf.cell will jump to the next page if no more room available, maybe
there is a sizing or rounding issue.
Also, you have to take a look at page margins.

Best regards,

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


On Tue, Jan 15, 2013 at 8:02 PM, Paul Rykiel  wrote:
> Greetings this is my code:
>
> def triagePrintTags(bikeIds):
> assert(bikeIds != None)
> assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple))
> pdf = FPDF('P', 'mm', (66.548, 25.4))
> # get all the r(ows
> rows = db(db.bike.id.belongs(bikeIds)).select()
> for row in rows:
> pdf.add_page()
> pdf.set_font('Times', 'B', 8)
> idString = row.destination + str(row.id)
> pdf.cell(0, 2, idString, 0, 1)
> if row.make != None:
> pdf.cell(0, 2, "Make:  " + row.make,0,1)
> if row.model != None:
> pdf.cell(0, 2, "Model:  " + row.model,0,1)
> if row.size != 0:
> sz = "Size:  " + str(row.size)
> pdf.cell(0, 2, sz,0,1)
> if row.color != None:
> pdf.cell(0, 2, "Color:  " + row.color,0,1)
> # TODO this should be a true temp file, stored in /tmp with random
> unique filename.
> fileName = request.folder + '/static/temp.pdf'
> pdf.output(name=fileName)
> response.headers['Content-Disposition']='attachment.filename =
> sample.pdf'
> response.headers['Content-Type']='application/pdf'
> return response.stream(open(fileName, 'rb'), chunk_size=4096)
>
> the problem with the above code is:
>
> my dimentions of my page are supposed to simulate a label (no problem)
> my text should all be on the same label, but when the next cell prints, it
> jumps to the
> next label. What am I doing incorrectly here?
>
> Or maybe is it is just wrong print with pdf.cell, maybe there is a better
> way.
> Please help if you can?
>
> Thank you in advance.
>
>
>
>
>
> --
>
>
>

-- 





[web2py] Run view html and error shows different code

2013-01-15 Thread jayvandal
I am running simple wiki code and I get an error. I shows the news code in 
controller code. I eliminated the news code from my code, saved the  code 
and  ran views. I get an error and the ticket shows the old deleted code. 
What is happening???

-- 





[web2py] 2.3.2 feels faster

2013-01-15 Thread Lewis
I have no way to quantify it (except I note that db stats now appear in 
hundredths of milliseconds!) but the new release certainly feels faster. 
 There is so much in between our browsers and web2py and the data so that 
the truth must be that web latency and database swamp what web2py itself 
does.  It just feels snappier and that is good.

-- 





[web2py] record versioning: what if tables are manually changed with migrate=False?

2013-01-15 Thread Rick Ree
Hi,

I would like to enable record versioning on an existing MySQL database in 
which all tables are managed manually (migrate=False). I am concerned about 
what happens if the structure of a table changes in db.define_table( ... ). 
Is the associated archive table changed to match accordingly?

thanks,
-Rick

-- 





[web2py] Re: can't install v 2.3

2013-01-15 Thread Lewis
Back in business.

There was detritus from previous installs interfering with new installs.

So, the culprit is not uwsgi:  unjustly accused.  Apologies.

File based config is inherently fragile.

Uninstalling with apt-get --purge remove uwsgi, etc. was the only way to 
really start fresh.

I think the scripts need to be more robust to deal with upgrade in place 
scenarios, not just new "from-scratch" installation.

-- 





Re: [web2py] output goes to wrong place

2013-01-15 Thread Bruno Rocha
You need to write to response

{{=crud.select(db.HumanLanguage, fields=['languageName'],
headers={'HumanLanguage.languageName': 'Language Name'})}}

or

{{response.write(crud.select(db.HumanLanguage, fields=['languageName'],
headers={'HumanLanguage.languageName': 'Language Name'}))}}

-- 





[web2py] output goes to wrong place

2013-01-15 Thread Alex Glaros
I put the following lines in views/default/index.html

{{print crud.select(db.HumanLanguage, fields=['languageName'],
headers={'HumanLanguage.languageName': 'Language Name'})}}

but the output went to the server's command line (in MS-Windows, the black 
DOS-command-line looking window).  How can I make the output appear on the 
html page instead?

thanks,

Alex Glaros

-- 





[web2py] Re: can't install v 2.3

2013-01-15 Thread Lewis

I have completely replaced my config with the slice from Bruno Rocha for 
ubuntu 12.04 (I upgraded everything).

It still won't work because import gluon.main fails.  There is clearly a 
path problem but I am clueless.  Everything is in the same place before I 
upgraded to web2py 2.2.3 and now it won't work.  I assume Bruno's script is 
clean. I only changed to use my directory names.

Here is the offending line from the uwsgi log:
Traceback (most recent call last):
  File "/var/web2py/wsgihandler.py", line 33, in 
import gluon.main

Of course, beyond this point nothing can work.

Is there some alternative to uwsgi?  For what should be a proxy only, it 
has such vast api surface area that it is simply too fragile to setup 
reliably.  Does it need 5 different syntaxes for config files?  etc.  But, 
we use it in a very narrow way for web2py.  It has worked for me and for 
others.  It is just pretty much impossible to diagnose failure.

I'd rather be coding not config'ing.

-- 





[web2py] Re: why is this table reference not working?

2013-01-15 Thread Alex Glaros
this code works great: requires = IS_IN_DB

db.define_table('HumanWord',Field('wordname','string'),Field('languageID','reference
 
HumanLanguage'),Field('comments','string'),Field('personID','reference 
auth_user'), redefine=True)
db.HumanWord.languageID.requires = IS_IN_DB(db, 'HumanLanguage.id', 
'%(languageName)s',zero=T('choose one'))

Is this all I need?

Thanks,

Alex

On Tuesday, January 15, 2013 1:12:45 PM UTC-8, Alex Glaros wrote:
>
> I am correctly getting a dropdown choice for referenced field personID for 
> fields below in database admin.   But why am I not getting a dropdown 
> choice for fields *wordID* and* languageID*? Do you see any syntax 
> errors? 
>
> db.define_table('HumanLanguage',Field('languageName','string'),Field('comments','string'),
>  
> redefine=True)
>
> db.define_table('HumanWord',Field('wordname','string'),Field('*languageID*','reference
>  
> HumanLanguage'),Field('comments','string'),Field('personID','reference 
> auth_user'), redefine=True)
>
> db.define_table('WordComments',Field('*wordID*','reference 
> HumanWord'),Field('comments','string'),Field('personID','reference 
> auth_user'),Field('datetime','string'), redefine=True)
>
> Thanks,
>
> Alex Glaros
>

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-15 Thread Derek
That would be cool, perhaps you could add a class to the fields and key off 
the classes. Or, have the validation function append error messages to a 
list and return that as json?

On Tuesday, January 15, 2013 10:03:06 AM UTC-7, Alec Taylor wrote:
>
> How do I expose validators as JSON? 
>
> I am not using web2py views in any capacity. Instead I am using AngularJS. 
>
> So with web2py I am exposing my models RESTfully as JSON, and then 
> consuming them with AngularJS. 
>
> To reduce double-typing, how do I send field validators such as 
> `IS_EMAIL` as JSON? 
>
> # Model 
> db.define_table( 
> 'foo', 
> Field('email', requires=IS_EMAIL()) 
> ) 
>
> # Controller 
> @service.json 
> def foo_form(): 
> return dict(my_foo_form=crud.create(db.foo)) 
>
> # Output I want 
> { 'my_foo_form': { 'type': 'form', 'fields' { 'email', 
> 'validator:IS_EMAIL'}, 'csrf':  } } 
>
>  
>
> With this I can then write the equivalent functions in JavaScript and 
> attach them to their corresponding fields. 
>
> How do I do this with web2py? 
>
> Thanks for all suggestions, 
>
> Alec Taylor 
>

-- 





[web2py] Re: Amazon RDS

2013-01-15 Thread Simon Ashley
Never mind - RTFL. Above string works fine .Issue in the security groups. 

-- 





[web2py] Re: why is this table reference not working?

2013-01-15 Thread Anthony
You should add the "format" attribute to the HumanLanguage table definition 
in order to tell it how to represent records that reference the table. It 
works for the auth_user table because auth.define_tables() does set the 
"format" attribute for that table.

db.define_table('HumanLanguage',
Field('languageName', 'string'),
Field('comments', 'string'),
format='%(languageName)s', redefine=True,)

You can also explicitly set the "represent" attribute for the two reference 
fields in question.

Anthony

On Tuesday, January 15, 2013 4:12:45 PM UTC-5, Alex Glaros wrote:
>
> I am correctly getting a dropdown choice for referenced field personID for 
> fields below in database admin.   But why am I not getting a dropdown 
> choice for fields *wordID* and* languageID*? Do you see any syntax 
> errors? 
>
> db.define_table('HumanLanguage',Field('languageName','string'),Field('comments','string'),
>  
> redefine=True)
>
> db.define_table('HumanWord',Field('wordname','string'),Field('*languageID*','reference
>  
> HumanLanguage'),Field('comments','string'),Field('personID','reference 
> auth_user'), redefine=True)
>
> db.define_table('WordComments',Field('*wordID*','reference 
> HumanWord'),Field('comments','string'),Field('personID','reference 
> auth_user'),Field('datetime','string'), redefine=True)
>
> Thanks,
>
> Alex Glaros
>

-- 





[web2py] Re: can't install v 2.3

2013-01-15 Thread Lewis
Thanks.  I originally started with a clean install of the new version and 
tried it untouched.  That didn't work.  

I have always meant to create a more repeatable install and config so I am 
going to try one of Bruno's scripts from the slices. That way as I make 
changes I'll capture them in the script.  

Still it is frustrating when it's unclear why something that worked 
subsequently broke.

On Tuesday, January 15, 2013 5:22:10 AM UTC-8, Niphlod wrote:
>
> using an extract of the latest version of the install script, this 
> works. try to pin down the differences between this and your config
>
> 
>  /tmp/web2py.socket
>  /home/www-data/web2py/
>  /=wsgihandler:application
>  
>  4
>  60
>  8
>  1
>  /tmp/stats.socket
>  2000
>  512
>  256
>  192
>  www-data
>  www-data
>  
> 
>
> The thing is ..
>
> path = os.path.dirname(os.path.abspath(__file__))
> os.chdir(path)
> sys.path = [path] + [p for p in sys.path if not p == path]
>
> is at the top of wsgihandler.py , so it chdir's to the dir where 
> wsgihandler is, and usually in that dir there's the gluon one holding all 
> the modules of web2py.
>
> Triple check and get back with your findings
>
> Il giorno martedì 15 gennaio 2013 13:15:37 UTC+1, Lewis ha scritto:
>>
>> I tried to run the auto upgrade to the latest version.  Worked on 
>> Windows/Rocket several times.  Would not work on my linode vps because of 
>> various permissions problems.  Not a big deal.
>>
>> Uploaded and unzipped the zip file in /var/web2py.   Set permissions so 
>> that www-data is the group for all files with rw access.
>>
>> My constant result is uWSGI Error Python Application not found.  Prior to 
>> the update, this had never occurred. In the update, I did not modify my 
>> uWSGI config at all.
>>
>> Here is the uWSGI log:
>>
>>
>> *** Starting uWSGI 1.2.3 (32bit) on [Tue Jan 15 11:41:15 2013] ***
>> compiled with version: 4.6.1 on 17 May 2012 23:33:21
>> detected number of CPU cores: 4
>> current working directory: /
>> writing pidfile to /var/run/uwsgi.pid
>> detected binary path: /usr/local/bin/uwsgi
>> uWSGI running as root, you can use --uid/--gid/--chroot options
>> setgid() to 33
>> setuid() to 33
>> your memory page size is 4096 bytes
>> detected max file descriptor number: 1024
>> lock engine: pthread robust mutexes
>> uwsgi socket 0 bound to UNIX address /tmp/web2py.sock fd 3
>> Python version: 2.7.2+ (default, Oct  4 2011, 20:29:37)  [GCC 4.6.1]
>> *** Python threads support is disabled. You can enable it with 
>> --enable-threads ***
>> Python main interpreter initialized at 0x8d69538
>> your server socket listen backlog is limited to 100 connections
>> *** Operational MODE: preforking ***
>> added /var/web2py/ to pythonpath.
>> Traceback (most recent call last):
>>   File "/var/web2py/wsgihandler.py", line 33, in 
>> import gluon.main
>> ImportError: No module named gluon.main
>> unable to load app 0 (mountpoint='') (callable not found or import error)
>> *** no app loaded. going in full dynamic mode ***
>> *** uWSGI is running in multiple interpreter mode ***
>> spawned uWSGI master process (pid: 23798)
>> spawned uWSGI worker 1 (pid: 23799, cores: 1)
>> spawned uWSGI worker 2 (pid: 23800, cores: 1)
>> spawned uWSGI worker 3 (pid: 23801, cores: 1)
>> spawned uWSGI worker 4 (pid: 23802, cores: 1)
>>
>>
>> You can see in the log that the import of gluon.main fails.  I tried a 
>> very old hint from Massimo to hard code the path to web2py in 
>> wsgihandler.py.  This is what lines of wsgihandler.py up to that point look 
>> like:
>>
>> login as: root
>> ro...@96.126.123.83's password:
>> Welcome to Ubuntu 11.10 (GNU/Linux 3.0.18-linode43 i686)
>>
>>  * Documentation:  https://help.ubuntu.com/
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>>
>> """
>> This file is part of the web2py Web Framework
>> Copyrighted by Massimo Di Pierro 
>> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
>>
>>
>> This is a WSGI handler for Apache
>> Requires apache+mod_wsgi.
>>
>> In httpd.conf put something like:
>>
>> LoadModule wsgi_module modules/mod_wsgi.so
>> WSGIScriptAlias / /path/to/wsgihandler.py
>>
>> """
>>
>> # change these parameters as required
>> LOGGING = False
>> SOFTCRON = False
>>
>> import sys
>> import os
>>
>> path = '/var/web2py'
>> os.chdir(path)
>> sys.path = [path] + [p for p in sys.path if not p == path]
>>
>> sys.stdout = sys.stderr
>>
>> import gluon.main
>>
>> if LOGGING:
>> application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
>> logfilename='httpserver.log',
>> profilerfilename=None)
>> else:
>> application = gluon.main.wsgibase
>>
>> if SOFTCRON:
>> from gluon.settings import global_settings
>> global_settings.web2py_crontype = 'soft'
>>
>>
>>
>> I also set the sys.path for python to include both web2py and 
>> web2py/gluon in my uwsgi init script: 
>>  PYTHONPATH=/var/web2py:/var/web2py/gluon.  After doi

[web2py] Re: Exposing validators as JSON?

2013-01-15 Thread Alan Etkin

>
> How do I expose validators as JSON?
>

Is there any standard way of mapping relational table definitions to json? 
In such case, you could open a ticket asking for the enhancement in the 
project page. web2py already supports JSON for other tasks like export 
data, json field type and validation

-- 





Re: [web2py] Re: onvalidation form.vars empty

2013-01-15 Thread António Ramos
I´m testing this book example
http://web2py.com/books/default/chapter/29/07#onvalidation
I get error on field named 'a'


Traceback (most recent call last):
  File "C:\web2pyGit\web2py\gluon\restricted.py", line 212, in restricted

exec ccode in environment
  File "C:/web2pyGit/web2py/applications/teste1/models/db.py"
, line
91, in 

Field('c', 'integer', readable=False, writable=False))

  File "C:\web2pyGit\web2py\gluon\dal.py", line 7189, in define_table

table = self.lazy_define_table(tablename,*fields,**args)

  File "C:\web2pyGit\web2py\gluon\dal.py", line 7206, in lazy_define_table

table = table_class(self, tablename, *fields, **args)

  File "C:\web2pyGit\web2py\gluon\dal.py", line 7612, in __init__

db.check_reserved_keyword(field_name)

  File "C:\web2pyGit\web2py\gluon\dal.py", line 6933, in check_reserved_keyword

'invalid table/column name "%s" is a "%s" reserved SQL keyword' %
(name, backend.upper()))
SyntaxError: invalid table/column name "a" is a "ALL" reserved SQL keyword


So i renamed all to a1,b1,c1 and it works !

Now my initial complain is still not working. I will test tomorrow and post
some code.
Meanwhile please check why a is not a valid field name and update the book
if necessary.
thank you

2013/1/15 Anthony 

> form.vars should work. Can you show more code? Note, form.request_vars is
> simply a copy of the original request.post_vars, so not equivalent to
> form.vars.
>
> Anthony
>
>
> On Tuesday, January 15, 2013 10:17:08 AM UTC-5, Ramos wrote:
>>
>> hello reading the book online i tried the code
>>
>>
>> def my_form_processing(form):
>> c = form.vars.a
>>
>> form.vars.b
>> if c < 0:
>> form.errors.b = 'a'
>> else:
>> form.vars.c = c
>>
>>
>>
>> but form.vars was empty
>>
>> to access my form vars i changed to form.request_vars
>>
>> *Is the book wrong?*
>>
>> Thank you
>> António
>>
>  --
>
>
>
>

-- 





[web2py] Having some strange occurence with label printing and FPDF

2013-01-15 Thread Paul Rykiel
Greetings this is my code:
 
def triagePrintTags(bikeIds):
assert(bikeIds != None)
assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple))
pdf = FPDF('P', 'mm', (66.548, 25.4))
# get all the r(ows 
rows = db(db.bike.id.belongs(bikeIds)).select()
for row in rows:
pdf.add_page()
pdf.set_font('Times', 'B', 8)
idString = row.destination + str(row.id)
pdf.cell(0, 2, idString, 0, 1)
if row.make != None:
pdf.cell(0, 2, "Make:  " + row.make,0,1)
if row.model != None:
pdf.cell(0, 2, "Model:  " + row.model,0,1)
if row.size != 0:
sz = "Size:  " + str(row.size)
pdf.cell(0, 2, sz,0,1)
if row.color != None:
pdf.cell(0, 2, "Color:  " + row.color,0,1)
# TODO this should be a true temp file, stored in /tmp with random 
unique filename.
fileName = request.folder + '/static/temp.pdf'
pdf.output(name=fileName)
response.headers['Content-Disposition']='attachment.filename = 
sample.pdf'
response.headers['Content-Type']='application/pdf'
return response.stream(open(fileName, 'rb'), chunk_size=4096)
 
the problem with the above code is:
 
my dimentions of my page are supposed to simulate a label (no problem)
my text should all be on the same label, but when the next cell prints, it 
jumps to the 
next label. What am I doing incorrectly here?
 
Or maybe is it is just wrong print with pdf.cell, maybe there is a better 
way.
Please help if you can?
 
Thank you in advance.
 
 
 
 

-- 





[web2py] why is this table reference not working?

2013-01-15 Thread Alex Glaros
I am correctly getting a dropdown choice for referenced field personID for 
fields below in database admin.   But why am I not getting a dropdown 
choice for fields *wordID* and* languageID*? Do you see any syntax errors? 
Also, is there a table of reserved words I can check?

db.define_table('HumanLanguage',Field('languageName','string'),Field('comments','string'),
 
redefine=True)

db.define_table('HumanWord',Field('wordname','string'),Field('*languageID*','reference
 
HumanLanguage'),Field('comments','string'),Field('personID','reference 
auth_user'), redefine=True)

db.define_table('WordComments',Field('*wordID*','reference 
HumanWord'),Field('comments','string'),Field('personID','reference 
auth_user'),Field('datetime','string'), redefine=True)

Thanks,

Alex Glaros

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Anthony
On Tuesday, January 15, 2013 2:48:45 PM UTC-5, Massimo Di Pierro wrote:

> You can do
>
> db._LAZY_TABLES['yourtablename'][2]['on_define'] = 
>

Good one -- didn't think of that. :-)

Anthony 

-- 





Re: [web2py] Re: width

2013-01-15 Thread Derek
Inspect the element in Chrome, it will say where it gets the width, for my 
app, it's web2py.css and the width is 300px. You can change the CSS to make 
it larger, or take out the width and let it automatically size.

On Tuesday, January 15, 2013 1:13:27 PM UTC-7, Saba wrote:
>
> thanks for the reply. I already tried that and it seems maxtextlengths 
> applies to only when displaying all the data. But when I try to add new 
> data (in the new page that opens after clicking the Add button), the 
> dropdown column width for the fields are still small. How to increase the 
> width of the dropdown? can you please suggest?
>  
>  
>
> On Monday, January 14, 2013 7:58:53 AM UTC-8, Ramos wrote:
>
>> i know that in form.smartgrid you can set the with of columns with  
>> a paramenter in form.smartgrid( maxtextlengths={10,20,etc}
>>
>>
>>
>>  maxtextlength sets the maximum length of text to be displayed for each
>> field value, in the grid view. This value can be overwritten for each 
>> field
>> using maxtextlengths, a dictionary of ’tablename.fieldname’:length
>>
>>  maxtextlengths={},
>> maxtextlength=20,
>>
>>
>> 2013/1/14 Saba 
>>
>>> Any suggestions please? 
>>>
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





Re: [web2py] Re: width

2013-01-15 Thread Saba
thanks for the reply. I already tried that and it seems maxtextlengths 
applies to only when displaying all the data. But when I try to add new 
data (in the new page that opens after clicking the Add button), the 
dropdown column width for the fields are still small. How to increase the 
width of the dropdown? can you please suggest?
 
 

On Monday, January 14, 2013 7:58:53 AM UTC-8, Ramos wrote:

> i know that in form.smartgrid you can set the with of columns with  
> a paramenter in form.smartgrid( maxtextlengths={10,20,etc}
>
>
>
>  maxtextlength sets the maximum length of text to be displayed for each
> field value, in the grid view. This value can be overwritten for each field
> using maxtextlengths, a dictionary of ’tablename.fieldname’:length
>
>  maxtextlengths={},
> maxtextlength=20,
>
>
> 2013/1/14 Saba >
>
>> Any suggestions please? 
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-15 Thread Derek
It is said earlier in the 'grid' documentation that onvalidation, oncreate, 
onupdate, and ondelete are all callbacks, as such, callbacks are functions, 
not dictionaries. Callbacks are functions that are passed to other 
functions. 

onvalidation, oncreate, onupdate and ondelete are callback functions. All 
but ondelete take a form object as input

On Tuesday, January 15, 2013 2:24:56 AM UTC-7, Kostas M wrote:
>
> OK fine, then why, in continuation of the above example,
>
> def test():
> grid = SQLFORM.smartgrid(db.person, linked_tables=['dog'], ondelete=
> dict( dog=ondelete_test ))
> return dict(grid=grid)
>
> def ondelete_test(table_involved, id_of_the_deleted_record):
> print table_involved
> print id_of_the_deleted_record
>
>
> ondelete=dict( dog=ondelete_test ) doesn't fire  (nothing is printed, one 
> dog row is removed but on refresh is back), 
> while 
> ondelete=ondelete_test   does fire, prints the values, and removes 
> permantly the rows
>
> ondelete doesn't belong to both grid and smartgrid? Or this is a bug?
>
>
> On Tuesday, January 15, 2013 1:30:12 AM UTC, Massimo Di Pierro wrote:
>>
>> The rule is simple. All options that belong to both grid and smartgrid 
>> (except args) can take a dictionary in smartgrid. If a dictionary is 
>> passed, the value is passed the grid, in correspondance to a key == 
>> tablename.
>>
>>
>>

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Massimo Di Pierro
You can do

db._LAZY_TABLES['yourtablename'][2]['on_define'] = 

Not as nice as what Anthony is proposing but works the same. We can change 
it but it would require treating one argument of define_table, on_define_ 
differently than all the other ones.

On Tuesday, 15 January 2013 11:42:05 UTC-6, Paolo valleri wrote:
>
> Hi Anthony, I agree with you. It would be nice to have such a on_define 
> function, this will not only optimize the code but also makes the code more 
> readable. I prefer the function rather than distributing in several 
> controllers the code that forces the definition of Auth
>
>
> 2013/1/15 Anthony >
>
>> On Tuesday, January 15, 2013 9:27:55 AM UTC-5, Paolo valleri wrote:
>>
>>> I am using lazy_tables=True at DAL definition, actually I don't know how 
>>> to enable lazy_table for auth. Does it exist?
>>
>>
>> Setting lazy_tables at the DAL definition affects all tables, including 
>> the Auth tables.
>>  
>>
>>> As I can see, auth.define_tables doesn't take any lazy_table parameter, 
>>> moreover in my code I have a few lines of auth.settings.* which needs auth. 
>>>
>>
>> If you have code that directly refers to an Auth table after it has been 
>> defined lazily, then the table will be fully defined. In that case, you 
>> could move that code to the action that actually needs it (e.g., the user() 
>> action). Perhaps we should add an _on_define attribute to tables so it is 
>> possible to add an on_define function after the initial lazy table 
>> definition.
>>
>> Anthony
>>
>>>   -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>  Paolo 
>

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Massimo Di Pierro
zy_define

On Tuesday, 15 January 2013 11:42:05 UTC-6, Paolo valleri wrote:
>
> Hi Anthony, I agree with you. It would be nice to have such a on_define 
> function, this will not only optimize the code but also makes the code more 
> readable. I prefer the function rather than distributing in several 
> controllers the code that forces the definition of Auth
>
>
> 2013/1/15 Anthony >
>
>> On Tuesday, January 15, 2013 9:27:55 AM UTC-5, Paolo valleri wrote:
>>
>>> I am using lazy_tables=True at DAL definition, actually I don't know how 
>>> to enable lazy_table for auth. Does it exist?
>>
>>
>> Setting lazy_tables at the DAL definition affects all tables, including 
>> the Auth tables.
>>  
>>
>>> As I can see, auth.define_tables doesn't take any lazy_table parameter, 
>>> moreover in my code I have a few lines of auth.settings.* which needs auth. 
>>>
>>
>> If you have code that directly refers to an Auth table after it has been 
>> defined lazily, then the table will be fully defined. In that case, you 
>> could move that code to the action that actually needs it (e.g., the user() 
>> action). Perhaps we should add an _on_define attribute to tables so it is 
>> possible to add an on_define function after the initial lazy table 
>> definition.
>>
>> Anthony
>>
>>>   -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>  Paolo 
>

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-15 Thread Anthony
crud.create() serializes into an HTML form, not JSON. There's nothing built 
in that does what you want. I think you would just have to write a custom 
function/module to convert either a FORM object or DAL table object into 
the desired JSON.

Anthony

On Tuesday, January 15, 2013 12:03:06 PM UTC-5, Alec Taylor wrote:
>
> How do I expose validators as JSON? 
>
> I am not using web2py views in any capacity. Instead I am using AngularJS. 
>
> So with web2py I am exposing my models RESTfully as JSON, and then 
> consuming them with AngularJS. 
>
> To reduce double-typing, how do I send field validators such as 
> `IS_EMAIL` as JSON? 
>
> # Model 
> db.define_table( 
> 'foo', 
> Field('email', requires=IS_EMAIL()) 
> ) 
>
> # Controller 
> @service.json 
> def foo_form(): 
> return dict(my_foo_form=crud.create(db.foo)) 
>
> # Output I want 
> { 'my_foo_form': { 'type': 'form', 'fields' { 'email', 
> 'validator:IS_EMAIL'}, 'csrf':  } } 
>
>  
>
> With this I can then write the equivalent functions in JavaScript and 
> attach them to their corresponding fields. 
>
> How do I do this with web2py? 
>
> Thanks for all suggestions, 
>
> Alec Taylor 
>

-- 





[web2py] Re: Burned by web2py.js ... again

2013-01-15 Thread LightDot
So web2py would provide helpers to use this JS file upload library? And 
helper's syntax would be backwards compatible?

In the mean time, for anyone else searching for upgrade advice, here is how 
I look at it: upgrading web2py and upgrading anything within an application 
running on web2py, are two different things.

I consider any contents of any of my web2py applications *not* to be a part 
of web2py itself. Even if some of their parts originally shipped as a part 
of the Welcome application.

So, if I run my entire existing app, unchanged, on a newer version of 
web2py than it was developed with, I'd expect backwards compatibility for 
all non-experimental functionality of web2py I used. One of the great 
features of web2py framework...

But if I ever change anything within my app, ie. update jQuery, web2py.js, 
etc., I fully expect I have to do compatibility tests to see if my code 
still works as intended.

I think it's technically impossible to ie. achieve full backward and 
forward compatibility with different combinations of jQuery, web2py.js, 
other custom js code, etc. within an application. It just can't be done. 
So, assume if you upgrade one of these components, things will break.

Further, I'd strongly advice against performing web2py updates and app 
updates at the same time. Too many different things that could go wrong.

Regards,
Ales

On Tuesday, January 15, 2013 1:38:15 PM UTC+1, weheh wrote:
>
> On Tuesday, January 15, 2013 1:39:54 AM UTC+8, Massimo Di Pierro wrote:
>
>> What did you upgrade from? What specifically changed that broke your 
>> code? 
>
>
> Upgrade was from 2.1.x. I tried to trace down exactly what broke the code, 
> but may have wiped out the tracks accidentally by changing some code in 
> another place. Nonetheless, when I have some more time this week I'll go 
> back and try to trace it through again.
>  
>
>>
>> When you upgrade web2py we do not upgrade web2py.js in your applications.
>>
>
> Yes, I know. However, I try to keep web2py.js up to date as best as 
> possible.
>  
>
>>
>> The fact that form uploads is second citizen is not a web2py issue. It is 
>> an Ajax issues. 
>>
>
> Yes, I am well aware of this.
>  
>
>> Ajax does not support multipart forms.
>> I am not award of a satisfactory solution to this problem unless we 
>> implement our own custom ajax data encoding. I do not think that would be a 
>> good idea.
>>
>
> No, I am not suggesting this. I am suggesting, instead, that we package up 
> a jquery single-file uploader and ship it with web2py so that it becomes a 
> standard *tested* way of uploading files from a component. It seems like 
> this has already been done with the menu system and possibly other stuff 
> inside web2py. I don't think it would be inconsistent to make a component 
> file uploader a standard part of the tool as well.
>
> As for claiming this is the third time, I did hedge a little by saying it 
> was "possibly" the 3rd time. I haven't kept good enough notes to be sure of 
> this.
>
> My action item is to trace things through and try to identify the 
> web2py.js code that's causing the problems. 
>
>

-- 





[web2py] Re: onvalidation form.vars empty

2013-01-15 Thread Anthony
form.vars should work. Can you show more code? Note, form.request_vars is 
simply a copy of the original request.post_vars, so not equivalent to 
form.vars.

Anthony

On Tuesday, January 15, 2013 10:17:08 AM UTC-5, Ramos wrote:
>
> hello reading the book online i tried the code
>
>
> def my_form_processing(form):
> c = form.vars.a
>
> form.vars.b
> if c < 0:
> form.errors.b = 'a'
> else:
> form.vars.c = c
>
>
>
> but form.vars was empty
>
> to access my form vars i changed to form.request_vars 
>
> *Is the book wrong?*
>
> Thank you
> António
>

-- 





[web2py] Re: OT -- PyCon registration open

2013-01-15 Thread Massimo Di Pierro
I will not be going. Not because web2py is not there (although that would 
have given a stronger motivation) for I cannot for other 
personal commitment. Too bad, I was hoping to see you again.

Despite everything I encourage those who can to participate, it is an 
excellent conference.

Massimo

On Tuesday, 15 January 2013 05:20:12 UTC-6, Joe Barnhart wrote:
>
> I'm disappointed there are no web2py talks... But I'm still going. 
>
> It sold out pretty quickly last year so sign up now if you're going. 
>
> -- Joe B. 
>
>

-- 





[web2py] Re: auth.wiki menu

2013-01-15 Thread Alan Etkin
> Now I want to have response.menu populated with the wiki pages too  in 
every page I have, is there a way to populate it calling
> somehow auth.wiki or I have to do that by hand, updating each time 
menu.py? 

If you put this on top of the controller (or model), you get the wiki menu

from gluon.tools import Wiki
response.menu += Wiki(auth).menu(controller="default", function="wiki")

The controller and / or function is required since otherwise, the wiki 
object cannot resolve redirection to edit/search/etc., and that address 
should be an action that calls auth.wiki(). And also you must check the 
action name to avoid duplicating the sub-menu

What about an extra set of keyword arguments to activate the menu?:

auth.wiki(resolve=False, menu=True, controller=..., function=)


-- 





[web2py] Re: Postgres User-Defined Types?

2013-01-15 Thread Massimo Di Pierro
can you show us the code?

On Tuesday, 15 January 2013 02:25:50 UTC-6, pbreit wrote:
>
> I'm trying to connect to a DB that has some user-defined types. Is this 
> supported in Web2py? I get:
>
> Traceback (most recent call last):
>   File "/Users/pbreit/Sites/web2py/gluon/restricted.py", line 212, in 
> restricted
> exec ccode in environment
>   File 
> "/Users/pbreit/Sites/web2py/applications/balanced/controllers/default.py" 
> , 
> line 95, in 
>   File "/Users/pbreit/Sites/web2py/gluon/globals.py", line 193, in 
> self._caller = lambda f: f()
>   File 
> "/Users/pbreit/Sites/web2py/applications/balanced/controllers/default.py" 
> , 
> line 39, in holds
> (db.holds.marketplace_guid.like('MP%'))).select()
>   File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 8966, in select
> return adapter.select(self.query,fields,attributes)
>   File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1636, in select
> return self._select_aux(sql,fields,attributes)
>   File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1601, in _select_aux
> self.execute(sql)
>   File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1714, in execute
> return self.log_execute(*a, **b)
>   File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1708, in log_execute
> ret = self.cursor.execute(*a, **b)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 246, 
> in _fn
> return fn(self, *args, **kwargs)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 317, 
> in execute
> self._execute(operation, args)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 322, 
> in _execute
> self.cursor.execute(new_query, *new_args)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/interface.py", line 
> 399, in execute
> self._stmt.execute(*args, **kwargs)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/interface.py", line 
> 169, in execute
> self._row_desc, cmd = self.c.bind(self._portal_name, 
> self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/protocol.py", line 
> 943, in _fn
> return fn(self, *args, **kwargs)
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/protocol.py", line 
> 1117, in bind
> output_fc = [types.py_type_info(f) for f in row_desc.fields]
>   File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/types.py", line 162, 
> in py_type_info
> raise NotSupportedError("type oid %r not mapped to py type" % type_oid)
> NotSupportedError: type oid 20716 not mapped to py type
>
>

-- 





[web2py] Re: parse_as_rest, many to many and multiple tables

2013-01-15 Thread Massimo Di Pierro
In trunk. Thanks. :-)

On Monday, 14 January 2013 23:27:10 UTC-6, DenesL wrote:
>
> Hi pin,
>
> you are welcome.
>
> I just sent Massimo another patch, if it is included then:
> '/{ownership.personid}/pets[pet.id]'
> would work to get all pet table fields for those pets whose owner is 
> personid.
>
> Trunk version 4613 already has support for
> *'*/pets/{ownership.personid}/toys[toy.owner]'
>
> Denes
>

-- 





[web2py] Re: parse_as_rest queries

2013-01-15 Thread Massimo Di Pierro
This may affect other concurrent apps which use this adapter. Not sure.

On Monday, 14 January 2013 19:31:52 UTC-6, DenesL wrote:
>
>
> This also seems to work:
>
> db._adapter.parse_blob=lambda value,field_type: value
>
> Any cons?.
>

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread paolo.vall...@gmail.com
Hi Anthony, I agree with you. It would be nice to have such a on_define
function, this will not only optimize the code but also makes the code more
readable. I prefer the function rather than distributing in several
controllers the code that forces the definition of Auth


2013/1/15 Anthony 

> On Tuesday, January 15, 2013 9:27:55 AM UTC-5, Paolo valleri wrote:
>
>> I am using lazy_tables=True at DAL definition, actually I don't know how
>> to enable lazy_table for auth. Does it exist?
>
>
> Setting lazy_tables at the DAL definition affects all tables, including
> the Auth tables.
>
>
>> As I can see, auth.define_tables doesn't take any lazy_table parameter,
>> moreover in my code I have a few lines of auth.settings.* which needs auth.
>>
>
> If you have code that directly refers to an Auth table after it has been
> defined lazily, then the table will be fully defined. In that case, you
> could move that code to the action that actually needs it (e.g., the user()
> action). Perhaps we should add an _on_define attribute to tables so it is
> possible to add an on_define function after the initial lazy table
> definition.
>
> Anthony
>
>>   --
>
>
>
>



-- 
 Paolo

-- 





[web2py] Exposing validators as JSON?

2013-01-15 Thread Alec Taylor
How do I expose validators as JSON?

I am not using web2py views in any capacity. Instead I am using AngularJS.

So with web2py I am exposing my models RESTfully as JSON, and then
consuming them with AngularJS.

To reduce double-typing, how do I send field validators such as
`IS_EMAIL` as JSON?

# Model
db.define_table(
'foo',
Field('email', requires=IS_EMAIL())
)

# Controller
@service.json
def foo_form():
return dict(my_foo_form=crud.create(db.foo))

# Output I want
{ 'my_foo_form': { 'type': 'form', 'fields' { 'email',
'validator:IS_EMAIL'}, 'csrf':  } }



With this I can then write the equivalent functions in JavaScript and
attach them to their corresponding fields.

How do I do this with web2py?

Thanks for all suggestions,

Alec Taylor

-- 





[web2py] web2py and ab testing

2013-01-15 Thread ala
Hi,

is there a "standard" or recommended method for web2py to do ab testing?

thanks

ala

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Anthony
On Tuesday, January 15, 2013 9:27:55 AM UTC-5, Paolo valleri wrote:

> I am using lazy_tables=True at DAL definition, actually I don't know how 
> to enable lazy_table for auth. Does it exist?


Setting lazy_tables at the DAL definition affects all tables, including the 
Auth tables.
 

> As I can see, auth.define_tables doesn't take any lazy_table parameter, 
> moreover in my code I have a few lines of auth.settings.* which needs auth. 
>

If you have code that directly refers to an Auth table after it has been 
defined lazily, then the table will be fully defined. In that case, you 
could move that code to the action that actually needs it (e.g., the user() 
action). Perhaps we should add an _on_define attribute to tables so it is 
possible to add an on_define function after the initial lazy table 
definition.

Anthony

>

-- 





[web2py] auth.wiki menu

2013-01-15 Thread Paolo valleri
Hi all, 
I started using the wiki. I created my pages, and I edited the wiki-menu 
page as I like.
Now I want to have response.menu populated with the wiki pages too  in 
every page I have, is there a way to populate it calling somehow auth.wiki 
or I have to do that by hand, updating each time menu.py? 

Thanks, Paolo

-- 





[web2py] Re: Web2Py function to query the database...

2013-01-15 Thread Anthony
Answered on StackOverflow: http://stackoverflow.com/a/14341931/440323

On Tuesday, January 15, 2013 3:19:13 AM UTC-5, Mihir Lade wrote:
>
> Hi Anthony, 
>
> Thanks for your reply.
>
> The code to searchFlights is as below:
>
> def searchFlights():
> return dict()
>
> def show():
> *receivedFlights = 
> request.vars.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.vlassType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants
> *
> return dict(txt1=recievedflights, 
> flights=db().select(db.Flight.request.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.classType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants))
>
> However I am currently getting an error with this:-
>
> receivedFlights = 
> request.vars.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.vlassType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants
> TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
>
> The error is with the line being highlighted above.. 
>
> I am not to sure as to how I can fix this error... 
>
>
>

-- 





[web2py] Re: TypeError: __call__() takes exactly 3 arguments (4 given)

2013-01-15 Thread aabelyakov
It works! Thanks... 

понедельник, 14 января 2013 г., 21:43:26 UTC+4 пользователь Massimo Di 
Pierro написал:
>
> Very odd. Can you try replace
>
> thread.start_new_thread(start_browser,
> (get_url(ip, proto=proto, port=port),),
> dict(startup=True))
>
> with
>
> thread.start_new_thread(start_browser,
> (get_url(ip, proto=proto, port=port), 
> True))
>
> On Sunday, 13 January 2013 23:44:45 UTC-6, aabelyakov wrote:
>>
>> ubuntu v.11.04 (Natty), v.12.04 (Precise), windows 8
>> web2py v.2.3.2 (2012-12-17 15:03:30) stable
>>
>>
>> When you run web2py.py without parameter -a 
>>
>> Exception in Tkinter callback
>> Traceback (most recent call last):
>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
>> return self.func(*args)
>> File "/home/aabelyakov/MyPython/web2py/gluon/widget.py", line 514, in 
>> start
>> dict(startup=True))
>> TypeError: __call__() takes exactly 3 arguments (4 given)
>>
>

-- 





[web2py] Re: Problem with combination of SQLForm.grid + LEFT JOIN + Computed Fields

2013-01-15 Thread Sebastien Stormacq
OK, using a debugger, I found out my problem.

When doing a left join, the "row" variable does not contain directly the 
fields.  We must use row.table_name.field_name instead.

This is now working.  Problem solved.

Seb

On Tuesday, January 15, 2013 4:13:45 PM UTC+1, Sebastien Stormacq wrote:
>
> Dear All,
>
> In one of my views, I am using a SQLForm.grid object.  The grid is fed 
> with a table that has two computed fields and the query needs a LEFT JOIN 
> to another table.
> The grid also use 'Links' to compute a field (create an column with an IMG 
> element depending on a column's value)
>
> Everything is OK, except when I mix computed fields and left join.
>
> Left join alone is OK
> Computed field alone is OK
>
> Here is my model
>
> db('message',
>
> Field('address', 'text'),
>
> Field('date', 'datetime', required=True),
>
> Field('flags', 'integer'),
>
> Field('msgaccount', 'text'),
>
> Field('msgflags', 'integer'),
>
> Field('msghandle', 'text'),
>
> Field('ismsg', 'integer'),
>
> Field('text', 'text', required=True),
>
> Field('cfrom', 'text', compute=lambda r: computeCFrom(r)),
>
> Field('cflags', 'integer', compute=lambda r: computeCFlags(r)))
>
> Here is my grid
>
> grid = SQLFORM.grid(dbMsg.message,
>
> fields=[dbMsg.message.address, 
> dbMsg.message.date, dbMsg.message.flags, 
>
> dbMsg.message.msgaccount, 
> dbMsg.message.msgflags,
>
> dbMsg.message.msghandle, 
> dbMsg.message.ismsg, dbMsg.message.text, 
>
> dbMsg.message.cfrom, 
> dbMsg.message.cflags,dbMsg.address.description  ],
>
> field_id=dbMsg.message.id,
>
> 
> #left=dbMsg.address.on(dbMsg.message.cfrom==dbMsg.address.address),
>
> orderby=~dbMsg.message.date,
>
> maxtextlengths={'message.date':5, 
> 'message.cfrom':20, 'address.description':20, 'message.text':160},
>
> headers={'message.cfrom' : T('From')},
>
> editable=False,
>
> create=False,
>
> details=False,
>
> deletable=False,
>
> csv=False,
>
> selectable=lambda ids: delete(ids),
>
> selectable_text=T('Delete'),
>
> links=[dict(header=T('Flags'), body=lambdarow: 
> formatFlag(row.cflags, row.ismsg))],
>
> ui='jquery-ui')
>
>
> The 'links' attribute is working with the left attribute commented out.  
>
> When removing the comment on the 'left' attribute, I do receive at runtime
>
> ERROR - Exception occurred in SQLFORM.grid : 'Row' object has no attribute 
> 'cflags'
>
>
> I am new to web2py, maybe I missed something obvious with computed fields 
> and grid.
>
>
> Thanks for your help
>
>
> Seb
>
>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2013-01-15 Thread Arnon Marcus
The folders of web2py, nginx, and postgres, each are "owned" by a different 
use, each of which is different from my user - so I don't have permission 
to edit them...
What should I do?

On Thursday, January 3, 2013 10:55:48 PM UTC+2, Richard wrote:
>
> I may don't understand... But I think it just a matter of DNS 
> configuration, you just need to set a local domain name to your machine 
> pointing on their IP address and then configure these VM as well, 
> /etc/hostname (
> http://askubuntu.com/questions/87665/how-do-i-change-the-hostname-without-a-restart)
>  
> and tell nginx hostname...
>
> ?!
>
> Richard
>
>
>
>
> On Thu, Jan 3, 2013 at 3:38 PM, Arnon Marcus 
> > wrote:
>
>> "
>> Also, hosting a staging/prod server on your own dev computer is kind of use 
>> less you will run 2 VMs at the same time on the same machine (one forthe 
>> prod/staging VM and one for your Dev machine), and you will get in 
>> trouble with memory soon. If you don't have a really prod server, for 
>> example ESXi or bare metal dedicated server, you should stick with one VM 
>> where you configure Nginx, etc. and you developpe with Rocket server 
>> included in web2py. 
>> "
>>
>> I guess I did not make myself clear enough. That is not exactly my 
>> intent, and that's not what we're doing.
>>
>> The machine I've installed the VM on, is a BOXX bare metal dedicated to 
>> become this server. You may ask "then why a VM at all? why not install 
>> it fresh as the main os?" Well, I have my reasons, but that's beside the 
>> point. The machine is a 64bit double-dual-core AMD with 8GB of RAM. The 
>> application is for intranet-use, so it's not going to have too much load 
>> anyways - it's going to serve up to 60 clients total at the very most - 
>> and mostly not all simultaneously. I don't expect it to have a problem 
>> running 2 VMs, I would just have to give each one around 3.5GB of RAM. You 
>> may then ask "then why a 64bit VM stack?" Well, future-proofing - We are 
>> supposed to get a newer dedicated bare-metal, which would probably have 
>> 16GB of RAM at least. But in any case, the 2 VMs are NOT your typical 
>> prod/dev configuration - it's more of a stable/nightly configuration - I 
>> want some of the workers to be able to QA new code by using a different 
>> server-instance. We DO also have a dev-environment, in each of the 
>> developer's machine, using the Rocket server as you said - that's on-top of 
>> the 2 VMs I'm planning. Another reason for having the production server 
>> served from a VM, is for backup reasons - it's easier/quicker to clone an 
>> entire VM-image with the whole stack + database, in case something goes 
>> wrong. Plug, we are almost a purely Microsoft-stack based shop, so I think 
>> it's going to be easier that way - with having all the remote-desktop 
>> experience super-simple, having the server logged in to the 
>> active-directory, etc...
>>
>> So then the question still remains - how do my users use this server on 
>> our network? Using the domain of the hosting machine as the host-address, 
>> doesn't work...
>> So what address should they use?
>>
>> On Thursday, January 3, 2013 7:12:09 AM UTC-8, Richard wrote:
>>
>>> See below answer...
>>>
>>>
>>> On Sun, Dec 30, 2012 at 3:55 PM, Arnon Marcus wrote:
>>>
 10x for the info.
 Is there any benefit for using the server vs. the desktop flavor?

 About pgAdmin, I don't really understand what you mean.
 We have been using posgreSQL with web2py in production for almost 3 
 years now. Using phpPgAdmin on our production was never an option - 
 always a necessity. Maybe it's becuse we are using an outdated version 
 of web2py, but from our experience, the DAL isn't perfect - there are many 
 advanced features of PostgreSQL that are not supported (I can give you a 
 list of those), so we HAVE to use some kind of interface to further 
 customize our schema outside of web2py. I don't really see how we can do 
 this in a dev machine and not need to do the same for the prod. machine. 
 If they share a database, then the database is on the prod. machine - 
 and we need phpPgAdmin. If each of them have a separate machine, then 
 we need 2 phpPgAdmins one on each machine. As far as I know, you can't 
 have your database installed in one machine, and have your phpPgAdmin 
 hosted 
 on another - in its configuration file, you have to specify the local path 
 of the pg_dump.exe and stuff like that it needs for it's operation. 
 And again, we need it's operation for unsupported feattures of 
 postgreSQL in web2py.
 As for PgAdmin-III, well, we basically only use if when transferring 
 our database + schema as an SQL string, from one machine to another. 
 Somehow the same thing using phpPgAdmin doesn't take us the whole way 
 the same way PgAdmin-III does when doing that.
 If we were starting a new project, I could have agreed with you - we 
 wouldn'

[web2py] onvalidation form.vars empty

2013-01-15 Thread António Ramos
hello reading the book online i tried the code


def my_form_processing(form):
c = form.vars.a

form.vars.b
if c < 0:
form.errors.b = 'a'
else:
form.vars.c = c



but form.vars was empty

to access my form vars i changed to form.request_vars

*Is the book wrong?*

Thank you
António

-- 





[web2py] Problem with combination of SQLForm.grid + LEFT JOIN + Computed Fields

2013-01-15 Thread Sebastien Stormacq
Dear All,

In one of my views, I am using a SQLForm.grid object.  The grid is fed with 
a table that has two computed fields and the query needs a LEFT JOIN to 
another table.
The grid also use 'Links' to compute a field (create an column with an IMG 
element depending on a column's value)

Everything is OK, except when I mix computed fields and left join.

Left join alone is OK
Computed field alone is OK

Here is my model

db('message',

Field('address', 'text'),

Field('date', 'datetime', required=True),

Field('flags', 'integer'),

Field('msgaccount', 'text'),

Field('msgflags', 'integer'),

Field('msghandle', 'text'),

Field('ismsg', 'integer'),

Field('text', 'text', required=True),

Field('cfrom', 'text', compute=lambda r: computeCFrom(r)),

Field('cflags', 'integer', compute=lambda r: computeCFlags(r)))

Here is my grid

grid = SQLFORM.grid(dbMsg.message,

fields=[dbMsg.message.address, 
dbMsg.message.date, dbMsg.message.flags, 

dbMsg.message.msgaccount, 
dbMsg.message.msgflags,

dbMsg.message.msghandle, 
dbMsg.message.ismsg, dbMsg.message.text, 

dbMsg.message.cfrom, 
dbMsg.message.cflags,dbMsg.address.description  ],

field_id=dbMsg.message.id,


#left=dbMsg.address.on(dbMsg.message.cfrom==dbMsg.address.address),

orderby=~dbMsg.message.date,

maxtextlengths={'message.date':5, 
'message.cfrom':20, 'address.description':20, 'message.text':160},

headers={'message.cfrom' : T('From')},

editable=False,

create=False,

details=False,

deletable=False,

csv=False,

selectable=lambda ids: delete(ids),

selectable_text=T('Delete'),

links=[dict(header=T('Flags'), body=lambda row: 
formatFlag(row.cflags, row.ismsg))],

ui='jquery-ui')


The 'links' attribute is working with the left attribute commented out.  

When removing the comment on the 'left' attribute, I do receive at runtime

ERROR - Exception occurred in SQLFORM.grid : 'Row' object has no attribute 
'cflags'


I am new to web2py, maybe I missed something obvious with computed fields 
and grid.


Thanks for your help


Seb

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Paolo valleri
I am using lazy_tables=True at DAL definition, actually I don't know how to 
enable lazy_table for auth. Does it exist?
As I can see, auth.define_tables doesn't take any lazy_table parameter, 
moreover in my code I have a few lines of auth.settings.* which needs auth. 
To customize my own tables without forcing their creation I am using the 
on_define function, as shown in the example below:

db.define_table('answers',
Field('question_id', db.questions),
Field('route_id', db.route),
Field('description', 'text' ),

   auth.signature,
on_define = lambda table: [
table.route_id.set_attributes(readable = False, writable = False),
]
)


Paolo

On Tuesday, January 15, 2013 3:10:32 PM UTC+1, Anthony wrote:
>
> Good point. Even better, use lazy_tables. You should also compile the app.
>
> On Tuesday, January 15, 2013 8:11:48 AM UTC-5, Paolo valleri wrote:
>>
>> Thanks for clarifying it. 
>> So that, to speed up web2py, we must use migrate_enabled=False instead of 
>> migrate=False at DAL definition. Otherwise for all the auth_* tables, 
>> web2py will access the disk to verify if the relative file in 
>> databases/hash_tablename.table exists and is updated, right?
>> If what I have said is correct I would suggest to update the book, 
>> http://web2py.com/books/default/chapter/29/13#Efficiency-tricks
>> changing migrate=False with migrate_enabled=False
>>
>> Paolo
>>
>>
>> 2013/1/15 Anthony 
>>
>>> DAL(..., migrate=False) does not completely turn off migrations but 
>>> merely sets the default migrate value for each table to False if it is not 
>>> set explicitly. The auth.define_tables() method, however, explicitly sets 
>>> migrate to True for each Auth table unless otherwise specified, so you 
>>> would have to do auth.define_tables(..., migrate=False). Another option is 
>>> to completely disable all migrations, regardless of individual table 
>>> settings, via:
>>>
>>> DAL(..., migrate_enabled=False)
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:

 is on the db definition. 
 db = DAL('postgres://web2py:web2py@**localhost:5432/traffic', 
  migrate=False,
 lazy_tables=True,
 )

 Paolo

 On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:
>
> migrate=False is on the db or on Auth define_table() call ?
>
>
>
> Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha 
> scritto:
>>
>> Hi all, I tried something odd.
>> I pulled a fresh copy of my code from git and I connected the app to 
>> an already 'working' database. 'working' in the meaning that both tables 
>> and data are already in the database. In web2py this approach 
>> fails, because at the first run it tries to create all the tables, and 
>> the 
>> db raises an exception like 'table already exist'.
>> In order to fix that I thought that migrate=False would help, however 
>> it fails again. due to Auth that tries to create the tables. Ticket:
>>
>> Traceback (most recent call last):
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/restricted.py", line 212, in 
>> restricted
>>
>>
>> exec ccode in environment
>>
>>
>>   File 
>> "/home/pvalleri/src/web2py/**applications/vtraffic/**controllers/default.py"
>>  
>> ,
>>  line 6, in 
>>
>>
>> start = db.record.with_alias('start_**point')
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
>> __getattr__
>>
>>
>> return self.lazy_define_table(tablena**me,*fields,**args)
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7174, in 
>> lazy_define_table
>>
>>
>> table = table_class(self, tablename, *fields, **args)
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7594, in __init__
>>
>>
>> field.requires = sqlhtml_validators(field)
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 6338, in 
>> sqlhtml_validators
>>
>>
>> referenced = db[field_type[10:]]
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
>> __getitem__
>>
>>
>> return self.__getattr__(str(key))
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
>> __getattr__
>>
>>
>> return self.lazy_define_table(tablena**me,*fields,**args)
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7177, in 
>> lazy_define_table
>>
>>
>> table._create_references() # must follow above line to handle self 
>> references
>>
>>
>>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7663, in 
>> _create_references
>>
>>
>> rtable

[web2py] Re: SqlAlchemy and Web2py

2013-01-15 Thread Anthony
You would lose the SQLFORM and SQLFORM.grid functionality, though you could 
use SQLFORM.factory or create DAL models only for those tables that require 
forms. Auth also depends on the DAL, but you might be comfortable just 
leaving that to web2py since it creates all the DAL models for you anyway.

Anthony

On Tuesday, January 15, 2013 7:47:45 AM UTC-5, puercoespin wrote:
>
> I need to access to a legacy and complex MS-SQLServer. And i decide to use 
> sqlAlchemy. What features of web2py am I missing?

-- 





[web2py] Re: SqlAlchemy and Web2py

2013-01-15 Thread puercoespin
Are there a similar script for MS-SQL server, as extract_pgsql_models.py?

And extracting models is only one part of the problem. The second is manage 
the tables without incremental keyed fields.


El martes, 15 de enero de 2013 14:02:55 UTC+1, Nico Zanferrari escribió:
>
> Have you already read this 
> topic ? 
> I also have your needs, and the answers from Massimo were really 
> inspiring...
>
> Cheers,
> Nico 
>
> Il giorno martedì 15 gennaio 2013 13:47:45 UTC+1, puercoespin ha scritto:
>>
>> I need to access to a legacy and complex MS-SQLServer. And i decide to 
>> use sqlAlchemy. What features of web2py am I missing?
>
>

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Anthony
Good point. Even better, use lazy_tables. You should also compile the app.

On Tuesday, January 15, 2013 8:11:48 AM UTC-5, Paolo valleri wrote:
>
> Thanks for clarifying it. 
> So that, to speed up web2py, we must use migrate_enabled=False instead of 
> migrate=False at DAL definition. Otherwise for all the auth_* tables, 
> web2py will access the disk to verify if the relative file in 
> databases/hash_tablename.table exists and is updated, right?
> If what I have said is correct I would suggest to update the book, 
> http://web2py.com/books/default/chapter/29/13#Efficiency-tricks
> changing migrate=False with migrate_enabled=False
>
> Paolo
>
>
> 2013/1/15 Anthony >
>
>> DAL(..., migrate=False) does not completely turn off migrations but 
>> merely sets the default migrate value for each table to False if it is not 
>> set explicitly. The auth.define_tables() method, however, explicitly sets 
>> migrate to True for each Auth table unless otherwise specified, so you 
>> would have to do auth.define_tables(..., migrate=False). Another option is 
>> to completely disable all migrations, regardless of individual table 
>> settings, via:
>>
>> DAL(..., migrate_enabled=False)
>>
>> Anthony
>>
>>
>> On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:
>>>
>>> is on the db definition. 
>>> db = DAL('postgres://web2py:web2py@**localhost:5432/traffic', 
>>>  migrate=False,
>>> lazy_tables=True,
>>> )
>>>
>>> Paolo
>>>
>>> On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:

 migrate=False is on the db or on Auth define_table() call ?



 Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha 
 scritto:
>
> Hi all, I tried something odd.
> I pulled a fresh copy of my code from git and I connected the app to 
> an already 'working' database. 'working' in the meaning that both tables 
> and data are already in the database. In web2py this approach 
> fails, because at the first run it tries to create all the tables, and 
> the 
> db raises an exception like 'table already exist'.
> In order to fix that I thought that migrate=False would help, however 
> it fails again. due to Auth that tries to create the tables. Ticket:
>
> Traceback (most recent call last):
>
>
>   File "/home/pvalleri/src/web2py/**gluon/restricted.py", line 212, in 
> restricted
>
>
> exec ccode in environment
>
>
>   File 
> "/home/pvalleri/src/web2py/**applications/vtraffic/**controllers/default.py"
>  
> ,
>  line 6, in 
>
>
> start = db.record.with_alias('start_**point')
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7174, in 
> lazy_define_table
>
>
> table = table_class(self, tablename, *fields, **args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7594, in __init__
>
>
> field.requires = sqlhtml_validators(field)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 6338, in 
> sqlhtml_validators
>
>
> referenced = db[field_type[10:]]
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
> __getitem__
>
>
> return self.__getattr__(str(key))
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7177, in 
> lazy_define_table
>
>
> table._create_references() # must follow above line to handle self 
> references
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7663, in 
> _create_references
>
>
> rtable = db[rtablename]
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
> __getitem__
>
>
> return self.__getattr__(str(key))
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7189, in 
> lazy_define_table
>
>
> polymodel=polymodel)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 935, in 
> create_table
>
>
> self.create_sequence_and_**triggers(query,table)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 2483, in 
> create_sequence_and_triggers
>
>
> self.execute(query)
>
>
>   File "/home/pva

[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Anthony
First, note that sessions do not expire -- web2py will keep the session as 
long as the client keeps returning the session cookie, so it's up to the 
client when to terminate the session (typically when the browser is 
closed). auth.settings.expiration does not determine when the session 
expires but when the login expires (i.e., after a period of inactivity, the 
user will have to log in again). Note, in order to avoid excessive session 
writing, session.auth.last_visit does not actually get updated on every 
single request -- it only gets updated if the time between the last visit 
and the current request exceeds 10% of the auth.settings.expiration time 
(so, about every 6 minutes with a one hour expiration).

As for the @service.jsonrpc requests, are those requests accessing an 
action that requires authentication, and if so, are you authenticating via 
a session cookie? If not, then those calls would not affect the session or 
the Auth login expiration.

Anthony

On Tuesday, January 15, 2013 8:27:04 AM UTC-5, Daniel Gonzalez wrote:
>
> FYI:
>
> Regarding my last two questions: the expiration is set in auth.settings, 
> but since I was using the session in memcache and the default_time_expire 
> in memche is 300 seconds, what I think is happening is that the session in 
> memcache is expiring, even though the session in auth.settings is not.
>
> That means no data can be recovered from memcache for the session, and 
> thus the session expires.
>
> I see several problems here:
>
>- the memcache session does not get updated, even though I am doing 
>accesses (in this case @service.jsonrpc accesses). I mean, this key should 
>be refreshed in memcache since I am accessing it (its ttl must be reset). 
>Just reading the session is not enough: it must be updated too, otherwise 
>it will expire!
>- auth.settings.expiration is not useful if the memcache time_expire 
>is smaller
>- session.auth.last_visit does not get updated in @service.jsonrpc 
>accesses
>
> Or maybe I am misunderstanding the expiration concept: it could be that 
> only login actions are supposed to refresh the session.
>
> But this looks a bit strange to me: as long as the client is sending 
> requests, the session should remain active! Whenever an *inactivity* 
> (meaning, no requests at all) period longer than auth.settings.expiration 
> has passed, the session should expire. Is this how things should work with 
> the current implementation?
>
>
> On Tuesday, January 15, 2013 1:26:48 PM UTC+1, Daniel Gonzalez wrote:
>>
>> And even worse: I am setting, for testing:
>>
>> auth.settings.expiration = 3600 * 24 * 30  # one month
>>
>> But the session is expiring after 5 minutes anyway! What is happening 
>> here?
>>
>> On Tuesday, January 15, 2013 12:14:59 PM UTC+1, Daniel Gonzalez wrote:
>>>
>>> And a related question: my session is expiring after 5 minutes (300s). I 
>>> am not setting the expiration time, and the default in 
>>> Auth.default_settings.expiration is 3600. 
>>>
>>> Where is the 300 coming from!?!?
>>>
>>> On Tuesday, January 15, 2013 11:57:03 AM UTC+1, Daniel Gonzalez wrote:

 Thanks Niphlod,

 I am now using:

- session.auth.expiration
- session.auth.last_visit

 And I have realized about one (at least for me) unexpected thing: 
 accessing @service.jsonrpc controllers does not 
 reset session.auth.last_visit. Is this intended?

 On Tuesday, January 15, 2013 11:43:11 AM UTC+1, Niphlod wrote:
>
> session expiration is managed by auth.settings.expiration ... 
>


-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread paolo.vall...@gmail.com
One or an other is ok, they lead to the same thing! I am adding them to my
project :)
However, after I first test, i could see any difference, I will investigate
more asap


2013/1/15 Niphlod 

> I'd rather specify also that auth.define_tables(migrate=False) is the way
> to go to turn migrations off of all the auth_* tables
>
> Il giorno martedì 15 gennaio 2013 14:11:48 UTC+1, Paolo valleri ha scritto:
>>
>> Thanks for clarifying it.
>> So that, to speed up web2py, we must use migrate_enabled=False instead of
>> migrate=False at DAL definition. Otherwise for all the auth_* tables,
>> web2py will access the disk to verify if the relative file in
>> databases/hash_tablename.table exists and is updated, right?
>> If what I have said is correct I would suggest to update the book,
>> http://web2py.com/books/**default/chapter/29/13#**Efficiency-tricks
>> changing migrate=False with migrate_enabled=False
>>
>> Paolo
>>
>>
>> 2013/1/15 Anthony 
>>
>> DAL(..., migrate=False) does not completely turn off migrations but
>>> merely sets the default migrate value for each table to False if it is not
>>> set explicitly. The auth.define_tables() method, however, explicitly sets
>>> migrate to True for each Auth table unless otherwise specified, so you
>>> would have to do auth.define_tables(..., migrate=False). Another option is
>>> to completely disable all migrations, regardless of individual table
>>> settings, via:
>>>
>>> DAL(..., migrate_enabled=False)
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:

 is on the db definition.
 db = DAL('postgres://web2py:web2py@localhost:5432/traffic',
  migrate=False,
 lazy_tables=True,
 )

 Paolo

 On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:
>
> migrate=False is on the db or on Auth define_table() call ?
>
>
>
> Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha
> scritto:
>>
>> Hi all, I tried something odd.
>> I pulled a fresh copy of my code from git and I connected the app to
>> an already 'working' database. 'working' in the meaning that both tables
>> and data are already in the database. In web2py this approach
>> fails, because at the first run it tries to create all the tables, and 
>> the
>> db raises an exception like 'table already exist'.
>> In order to fix that I thought that migrate=False would help, however
>> it fails again. due to Auth that tries to create the tables. Ticket:
>>
>> Traceback (most recent call last):
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/restricted.py", line 212, in 
>> restricted
>>
>>
>>
>> exec ccode in environment
>>
>>
>>
>>   File 
>> "/home/pvalleri/src/web2py/**app**lications/vtraffic/**controllers**/default.py"
>>  
>> ,
>>  line 6, in 
>>
>>
>>
>> start = db.record.with_alias('start_**po**int')
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7221, in 
>> __getattr__
>>
>>
>>
>> return self.lazy_define_table(tablename,*fields,**args)
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7174, in 
>> lazy_define_table
>>
>>
>>
>> table = table_class(self, tablename, *fields, **args)
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7594, in 
>> __init__
>>
>>
>>
>> field.requires = sqlhtml_validators(field)
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 6338, in 
>> sqlhtml_validators
>>
>>
>>
>> referenced = db[field_type[10:]]
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7215, in 
>> __getitem__
>>
>>
>>
>> return self.__getattr__(str(key))
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7221, in 
>> __getattr__
>>
>>
>>
>> return self.lazy_define_table(tablename,*fields,**args)
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7177, in 
>> lazy_define_table
>>
>>
>>
>> table._create_references() # must follow above line to handle self 
>> references
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7663, in 
>> _create_references
>>
>>
>>
>> rtable = db[rtablename]
>>
>>
>>
>>   File "/home/pvalleri/src/web2py/**glu**on/dal.py", line 7215, in 
>> __getitem__
>>
>>
>>
>> return self.__getattr__(str(key))
>>
>>
>>
>>   File "/home/pvalleri/src/web2p

[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Daniel Gonzalez
FYI:

Regarding my last two questions: the expiration is set in auth.settings, 
but since I was using the session in memcache and the default_time_expire 
in memche is 300 seconds, what I think is happening is that the session in 
memcache is expiring, even though the session in auth.settings is not.

That means no data can be recovered from memcache for the session, and thus 
the session expires.

I see several problems here:

   - the memcache session does not get updated, even though I am doing 
   accesses (in this case @service.jsonrpc accesses). I mean, this key should 
   be refreshed in memcache since I am accessing it (its ttl must be reset). 
   Just reading the session is not enough: it must be updated too, otherwise 
   it will expire!
   - auth.settings.expiration is not useful if the memcache time_expire is 
   smaller
   - session.auth.last_visit does not get updated in @service.jsonrpc 
   accesses
   
Or maybe I am misunderstanding the expiration concept: it could be that 
only login actions are supposed to refresh the session.

But this looks a bit strange to me: as long as the client is sending 
requests, the session should remain active! Whenever an *inactivity* 
(meaning, no requests at all) period longer than auth.settings.expiration 
has passed, the session should expire. Is this how things should work with 
the current implementation?


On Tuesday, January 15, 2013 1:26:48 PM UTC+1, Daniel Gonzalez wrote:
>
> And even worse: I am setting, for testing:
>
> auth.settings.expiration = 3600 * 24 * 30  # one month
>
> But the session is expiring after 5 minutes anyway! What is happening here?
>
> On Tuesday, January 15, 2013 12:14:59 PM UTC+1, Daniel Gonzalez wrote:
>>
>> And a related question: my session is expiring after 5 minutes (300s). I 
>> am not setting the expiration time, and the default in 
>> Auth.default_settings.expiration is 3600. 
>>
>> Where is the 300 coming from!?!?
>>
>> On Tuesday, January 15, 2013 11:57:03 AM UTC+1, Daniel Gonzalez wrote:
>>>
>>> Thanks Niphlod,
>>>
>>> I am now using:
>>>
>>>- session.auth.expiration
>>>- session.auth.last_visit
>>>
>>> And I have realized about one (at least for me) unexpected thing: 
>>> accessing @service.jsonrpc controllers does not 
>>> reset session.auth.last_visit. Is this intended?
>>>
>>> On Tuesday, January 15, 2013 11:43:11 AM UTC+1, Niphlod wrote:

 session expiration is managed by auth.settings.expiration ... 

>>>

-- 





[web2py] Re: can't install v 2.3

2013-01-15 Thread Niphlod
using an extract of the latest version of the install script, this 
works. try to pin down the differences between this and your config


 /tmp/web2py.socket
 /home/www-data/web2py/
 /=wsgihandler:application
 
 4
 60
 8
 1
 /tmp/stats.socket
 2000
 512
 256
 192
 www-data
 www-data
 


The thing is ..

path = os.path.dirname(os.path.abspath(__file__))
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not p == path]

is at the top of wsgihandler.py , so it chdir's to the dir where 
wsgihandler is, and usually in that dir there's the gluon one holding all 
the modules of web2py.

Triple check and get back with your findings

Il giorno martedì 15 gennaio 2013 13:15:37 UTC+1, Lewis ha scritto:
>
> I tried to run the auto upgrade to the latest version.  Worked on 
> Windows/Rocket several times.  Would not work on my linode vps because of 
> various permissions problems.  Not a big deal.
>
> Uploaded and unzipped the zip file in /var/web2py.   Set permissions so 
> that www-data is the group for all files with rw access.
>
> My constant result is uWSGI Error Python Application not found.  Prior to 
> the update, this had never occurred. In the update, I did not modify my 
> uWSGI config at all.
>
> Here is the uWSGI log:
>
>
> *** Starting uWSGI 1.2.3 (32bit) on [Tue Jan 15 11:41:15 2013] ***
> compiled with version: 4.6.1 on 17 May 2012 23:33:21
> detected number of CPU cores: 4
> current working directory: /
> writing pidfile to /var/run/uwsgi.pid
> detected binary path: /usr/local/bin/uwsgi
> uWSGI running as root, you can use --uid/--gid/--chroot options
> setgid() to 33
> setuid() to 33
> your memory page size is 4096 bytes
> detected max file descriptor number: 1024
> lock engine: pthread robust mutexes
> uwsgi socket 0 bound to UNIX address /tmp/web2py.sock fd 3
> Python version: 2.7.2+ (default, Oct  4 2011, 20:29:37)  [GCC 4.6.1]
> *** Python threads support is disabled. You can enable it with 
> --enable-threads ***
> Python main interpreter initialized at 0x8d69538
> your server socket listen backlog is limited to 100 connections
> *** Operational MODE: preforking ***
> added /var/web2py/ to pythonpath.
> Traceback (most recent call last):
>   File "/var/web2py/wsgihandler.py", line 33, in 
> import gluon.main
> ImportError: No module named gluon.main
> unable to load app 0 (mountpoint='') (callable not found or import error)
> *** no app loaded. going in full dynamic mode ***
> *** uWSGI is running in multiple interpreter mode ***
> spawned uWSGI master process (pid: 23798)
> spawned uWSGI worker 1 (pid: 23799, cores: 1)
> spawned uWSGI worker 2 (pid: 23800, cores: 1)
> spawned uWSGI worker 3 (pid: 23801, cores: 1)
> spawned uWSGI worker 4 (pid: 23802, cores: 1)
>
>
> You can see in the log that the import of gluon.main fails.  I tried a 
> very old hint from Massimo to hard code the path to web2py in 
> wsgihandler.py.  This is what lines of wsgihandler.py up to that point look 
> like:
>
> login as: root
> ro...@96.126.123.83 's password:
> Welcome to Ubuntu 11.10 (GNU/Linux 3.0.18-linode43 i686)
>
>  * Documentation:  https://help.ubuntu.com/
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> """
> This file is part of the web2py Web Framework
> Copyrighted by Massimo Di Pierro >
> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
>
>
> This is a WSGI handler for Apache
> Requires apache+mod_wsgi.
>
> In httpd.conf put something like:
>
> LoadModule wsgi_module modules/mod_wsgi.so
> WSGIScriptAlias / /path/to/wsgihandler.py
>
> """
>
> # change these parameters as required
> LOGGING = False
> SOFTCRON = False
>
> import sys
> import os
>
> path = '/var/web2py'
> os.chdir(path)
> sys.path = [path] + [p for p in sys.path if not p == path]
>
> sys.stdout = sys.stderr
>
> import gluon.main
>
> if LOGGING:
> application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
> logfilename='httpserver.log',
> profilerfilename=None)
> else:
> application = gluon.main.wsgibase
>
> if SOFTCRON:
> from gluon.settings import global_settings
> global_settings.web2py_crontype = 'soft'
>
>
>
> I also set the sys.path for python to include both web2py and web2py/gluon 
> in my uwsgi init script:  PYTHONPATH=/var/web2py:/var/web2py/gluon.  After 
> doing this the uwsgi log reports added /var/web2py:/varweb2py/gluon to 
> pythonpath.  This resulted in a different import error--now it can't find 
> wsgihandler ("ImportError: No module named wsgihandler").
>
> This is very frustrating.  Everything worked perfectly with earlier 
> version of web2py.  Config is just massively fragile with so many moving 
> parts.
>
> Sorry for the long post.  Thanks for your help.
>
>
>
>
>

-- 





Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread Niphlod
I'd rather specify also that auth.define_tables(migrate=False) is the way 
to go to turn migrations off of all the auth_* tables

Il giorno martedì 15 gennaio 2013 14:11:48 UTC+1, Paolo valleri ha scritto:
>
> Thanks for clarifying it. 
> So that, to speed up web2py, we must use migrate_enabled=False instead of 
> migrate=False at DAL definition. Otherwise for all the auth_* tables, 
> web2py will access the disk to verify if the relative file in 
> databases/hash_tablename.table exists and is updated, right?
> If what I have said is correct I would suggest to update the book, 
> http://web2py.com/books/default/chapter/29/13#Efficiency-tricks
> changing migrate=False with migrate_enabled=False
>
> Paolo
>
>
> 2013/1/15 Anthony >
>
>> DAL(..., migrate=False) does not completely turn off migrations but 
>> merely sets the default migrate value for each table to False if it is not 
>> set explicitly. The auth.define_tables() method, however, explicitly sets 
>> migrate to True for each Auth table unless otherwise specified, so you 
>> would have to do auth.define_tables(..., migrate=False). Another option is 
>> to completely disable all migrations, regardless of individual table 
>> settings, via:
>>
>> DAL(..., migrate_enabled=False)
>>
>> Anthony
>>
>>
>> On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:
>>>
>>> is on the db definition. 
>>> db = DAL('postgres://web2py:web2py@**localhost:5432/traffic', 
>>>  migrate=False,
>>> lazy_tables=True,
>>> )
>>>
>>> Paolo
>>>
>>> On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:

 migrate=False is on the db or on Auth define_table() call ?



 Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha 
 scritto:
>
> Hi all, I tried something odd.
> I pulled a fresh copy of my code from git and I connected the app to 
> an already 'working' database. 'working' in the meaning that both tables 
> and data are already in the database. In web2py this approach 
> fails, because at the first run it tries to create all the tables, and 
> the 
> db raises an exception like 'table already exist'.
> In order to fix that I thought that migrate=False would help, however 
> it fails again. due to Auth that tries to create the tables. Ticket:
>
> Traceback (most recent call last):
>
>
>   File "/home/pvalleri/src/web2py/**gluon/restricted.py", line 212, in 
> restricted
>
>
> exec ccode in environment
>
>
>   File 
> "/home/pvalleri/src/web2py/**applications/vtraffic/**controllers/default.py"
>  
> ,
>  line 6, in 
>
>
> start = db.record.with_alias('start_**point')
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7174, in 
> lazy_define_table
>
>
> table = table_class(self, tablename, *fields, **args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7594, in __init__
>
>
> field.requires = sqlhtml_validators(field)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 6338, in 
> sqlhtml_validators
>
>
> referenced = db[field_type[10:]]
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
> __getitem__
>
>
> return self.__getattr__(str(key))
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7177, in 
> lazy_define_table
>
>
> table._create_references() # must follow above line to handle self 
> references
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7663, in 
> _create_references
>
>
> rtable = db[rtablename]
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
> __getitem__
>
>
> return self.__getattr__(str(key))
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
> __getattr__
>
>
> return self.lazy_define_table(tablena**me,*fields,**args)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7189, in 
> lazy_define_table
>
>
> polymodel=polymodel)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 935, in 
> create_table
>
>
> self.create_sequence_and_**triggers(query,table)
>
>
>   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 2483, in 
> create_sequence_and_triggers
>
>
>>>

Re: [web2py] Re: Auth with migrate=False

2013-01-15 Thread paolo.vall...@gmail.com
Thanks for clarifying it.
So that, to speed up web2py, we must use migrate_enabled=False instead of
migrate=False at DAL definition. Otherwise for all the auth_* tables,
web2py will access the disk to verify if the relative file in
databases/hash_tablename.table exists and is updated, right?
If what I have said is correct I would suggest to update the book,
http://web2py.com/books/default/chapter/29/13#Efficiency-tricks
changing migrate=False with migrate_enabled=False

Paolo


2013/1/15 Anthony 

> DAL(..., migrate=False) does not completely turn off migrations but merely
> sets the default migrate value for each table to False if it is not set
> explicitly. The auth.define_tables() method, however, explicitly sets
> migrate to True for each Auth table unless otherwise specified, so you
> would have to do auth.define_tables(..., migrate=False). Another option is
> to completely disable all migrations, regardless of individual table
> settings, via:
>
> DAL(..., migrate_enabled=False)
>
> Anthony
>
>
> On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:
>>
>> is on the db definition.
>> db = DAL('postgres://web2py:web2py@**localhost:5432/traffic',
>>  migrate=False,
>> lazy_tables=True,
>> )
>>
>> Paolo
>>
>> On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:
>>>
>>> migrate=False is on the db or on Auth define_table() call ?
>>>
>>>
>>>
>>> Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha
>>> scritto:

 Hi all, I tried something odd.
 I pulled a fresh copy of my code from git and I connected the app to an
 already 'working' database. 'working' in the meaning that both tables and
 data are already in the database. In web2py this approach fails, because at
 the first run it tries to create all the tables, and the db raises an
 exception like 'table already exist'.
 In order to fix that I thought that migrate=False would help, however
 it fails again. due to Auth that tries to create the tables. Ticket:

 Traceback (most recent call last):

   File "/home/pvalleri/src/web2py/**gluon/restricted.py", line 212, in 
 restricted

 exec ccode in environment

   File 
 "/home/pvalleri/src/web2py/**applications/vtraffic/**controllers/default.py"
  
 ,
  line 6, in 

 start = db.record.with_alias('start_**point')

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
 __getattr__

 return self.lazy_define_table(tablena**me,*fields,**args)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7174, in 
 lazy_define_table

 table = table_class(self, tablename, *fields, **args)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7594, in __init__

 field.requires = sqlhtml_validators(field)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 6338, in 
 sqlhtml_validators

 referenced = db[field_type[10:]]

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
 __getitem__

 return self.__getattr__(str(key))

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
 __getattr__

 return self.lazy_define_table(tablena**me,*fields,**args)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7177, in 
 lazy_define_table

 table._create_references() # must follow above line to handle self 
 references

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7663, in 
 _create_references

 rtable = db[rtablename]

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7215, in 
 __getitem__

 return self.__getattr__(str(key))

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7221, in 
 __getattr__

 return self.lazy_define_table(tablena**me,*fields,**args)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 7189, in 
 lazy_define_table

 polymodel=polymodel)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 935, in 
 create_table

 self.create_sequence_and_**triggers(query,table)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 2483, in 
 create_sequence_and_triggers

 self.execute(query)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 1709, in execute

 return self.log_execute(*a, **b)

   File "/home/pvalleri/src/web2py/**gluon/dal.py", line 1703, in 
 log_execute

 ret = self.cursor.execute(*a, **b)

   File "/home/pvalleri/src/web2py/**gluon/contrib/pg8000/dbapi.py"**, line 
 246, in _fn

 return fn(self, *args, **kwargs)

   File "/home/pvalleri/src/web2py/**gluon/contrib/pg8000/dbapi.py"**, line 
 317, in execute
>>>

[web2py] Re: SqlAlchemy and Web2py

2013-01-15 Thread Nico Zanferrari
Have you already read this 
topic ? 
I also have your needs, and the answers from Massimo were really 
inspiring...

Cheers,
Nico 

Il giorno martedì 15 gennaio 2013 13:47:45 UTC+1, puercoespin ha scritto:
>
> I need to access to a legacy and complex MS-SQLServer. And i decide to use 
> sqlAlchemy. What features of web2py am I missing?

-- 





[web2py] Re: Auth with migrate=False

2013-01-15 Thread Anthony
DAL(..., migrate=False) does not completely turn off migrations but merely 
sets the default migrate value for each table to False if it is not set 
explicitly. The auth.define_tables() method, however, explicitly sets 
migrate to True for each Auth table unless otherwise specified, so you 
would have to do auth.define_tables(..., migrate=False). Another option is 
to completely disable all migrations, regardless of individual table 
settings, via:

DAL(..., migrate_enabled=False)

Anthony

On Tuesday, January 15, 2013 7:35:14 AM UTC-5, Paolo valleri wrote:
>
> is on the db definition. 
> db = DAL('postgres://web2py:web2py@localhost:5432/traffic', 
> migrate=False,
> lazy_tables=True,
> )
>
> Paolo
>
> On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:
>>
>> migrate=False is on the db or on Auth define_table() call ?
>>
>>
>>
>> Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha 
>> scritto:
>>>
>>> Hi all, I tried something odd.
>>> I pulled a fresh copy of my code from git and I connected the app to an 
>>> already 'working' database. 'working' in the meaning that both tables and 
>>> data are already in the database. In web2py this approach fails, because at 
>>> the first run it tries to create all the tables, and the db raises an 
>>> exception like 'table already exist'.
>>> In order to fix that I thought that migrate=False would help, however it 
>>> fails again. due to Auth that tries to create the tables. Ticket:
>>>
>>> Traceback (most recent call last):
>>>   File "/home/pvalleri/src/web2py/gluon/restricted.py", line 212, in 
>>> restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/pvalleri/src/web2py/applications/vtraffic/controllers/default.py" 
>>> , 
>>> line 6, in 
>>> start = db.record.with_alias('start_point')
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>>> return self.lazy_define_table(tablename,*fields,**args)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7174, in 
>>> lazy_define_table
>>> table = table_class(self, tablename, *fields, **args)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7594, in __init__
>>> field.requires = sqlhtml_validators(field)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 6338, in 
>>> sqlhtml_validators
>>> referenced = db[field_type[10:]]
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
>>> return self.__getattr__(str(key))
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>>> return self.lazy_define_table(tablename,*fields,**args)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7177, in 
>>> lazy_define_table
>>> table._create_references() # must follow above line to handle self 
>>> references
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7663, in 
>>> _create_references
>>> rtable = db[rtablename]
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
>>> return self.__getattr__(str(key))
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>>> return self.lazy_define_table(tablename,*fields,**args)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7189, in 
>>> lazy_define_table
>>> polymodel=polymodel)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 935, in create_table
>>> self.create_sequence_and_triggers(query,table)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 2483, in 
>>> create_sequence_and_triggers
>>> self.execute(query)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1709, in execute
>>> return self.log_execute(*a, **b)
>>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1703, in log_execute
>>> ret = self.cursor.execute(*a, **b)
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 246, 
>>> in _fn
>>> return fn(self, *args, **kwargs)
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 317, 
>>> in execute
>>> self._execute(operation, args)
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 322, 
>>> in _execute
>>> self.cursor.execute(new_query, *new_args)
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
>>> 399, in execute
>>> self._stmt.execute(*args, **kwargs)
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
>>> 169, in execute
>>> self._row_desc, cmd = self.c.bind(self._portal_name, 
>>> self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
>>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/protocol.py", line 
>>> 943, in _fn
>>> return fn(self, *argshttps://groups.google.com/group/web2py/msg/64de6b8ababbd2a3?dmode=source&output=gplain&noredirect>
>>>
>>>

-- 





Re: [web2py] Online book typo on static asset management

2013-01-15 Thread Nico Zanferrari
Thank you António, but it's already fixed on the  GitHub version (
https://github.com/mdipierro/web2py-book).


Nico



2013/1/14 António Ramos 

> cahnge

-- 





[web2py] SqlAlchemy and Web2py

2013-01-15 Thread puercoespin
I need to access to a legacy and complex MS-SQLServer. And i decide to use 
sqlAlchemy. What features of web2py am I missing?

-- 





[web2py] Re: Burned by web2py.js ... again

2013-01-15 Thread weheh
On Tuesday, January 15, 2013 1:39:54 AM UTC+8, Massimo Di Pierro wrote:

> What did you upgrade from? What specifically changed that broke your code? 


Upgrade was from 2.1.x. I tried to trace down exactly what broke the code, 
but may have wiped out the tracks accidentally by changing some code in 
another place. Nonetheless, when I have some more time this week I'll go 
back and try to trace it through again.
 

>
> When you upgrade web2py we do not upgrade web2py.js in your applications.
>

Yes, I know. However, I try to keep web2py.js up to date as best as 
possible.
 

>
> The fact that form uploads is second citizen is not a web2py issue. It is 
> an Ajax issues. 
>

Yes, I am well aware of this.
 

> Ajax does not support multipart forms.
> I am not award of a satisfactory solution to this problem unless we 
> implement our own custom ajax data encoding. I do not think that would be a 
> good idea.
>

No, I am not suggesting this. I am suggesting, instead, that we package up 
a jquery single-file uploader and ship it with web2py so that it becomes a 
standard *tested* way of uploading files from a component. It seems like 
this has already been done with the menu system and possibly other stuff 
inside web2py. I don't think it would be inconsistent to make a component 
file uploader a standard part of the tool as well.

As for claiming this is the third time, I did hedge a little by saying it 
was "possibly" the 3rd time. I haven't kept good enough notes to be sure of 
this.

My action item is to trace things through and try to identify the web2py.js 
code that's causing the problems. 

-- 





[web2py] Re: Auth with migrate=False

2013-01-15 Thread Paolo valleri
is on the db definition. 
db = DAL('postgres://web2py:web2py@localhost:5432/traffic', 
migrate=False,
lazy_tables=True,
)

Paolo

On Tuesday, January 15, 2013 11:38:49 AM UTC+1, Niphlod wrote:
>
> migrate=False is on the db or on Auth define_table() call ?
>
>
>
> Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha scritto:
>>
>> Hi all, I tried something odd.
>> I pulled a fresh copy of my code from git and I connected the app to an 
>> already 'working' database. 'working' in the meaning that both tables and 
>> data are already in the database. In web2py this approach fails, because at 
>> the first run it tries to create all the tables, and the db raises an 
>> exception like 'table already exist'.
>> In order to fix that I thought that migrate=False would help, however it 
>> fails again. due to Auth that tries to create the tables. Ticket:
>>
>> Traceback (most recent call last):
>>   File "/home/pvalleri/src/web2py/gluon/restricted.py", line 212, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/pvalleri/src/web2py/applications/vtraffic/controllers/default.py" 
>> , 
>> line 6, in 
>> start = db.record.with_alias('start_point')
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>> return self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7174, in 
>> lazy_define_table
>> table = table_class(self, tablename, *fields, **args)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7594, in __init__
>> field.requires = sqlhtml_validators(field)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 6338, in 
>> sqlhtml_validators
>> referenced = db[field_type[10:]]
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
>> return self.__getattr__(str(key))
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>> return self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7177, in 
>> lazy_define_table
>> table._create_references() # must follow above line to handle self 
>> references
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7663, in 
>> _create_references
>> rtable = db[rtablename]
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
>> return self.__getattr__(str(key))
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
>> return self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7189, in 
>> lazy_define_table
>> polymodel=polymodel)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 935, in create_table
>> self.create_sequence_and_triggers(query,table)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 2483, in 
>> create_sequence_and_triggers
>> self.execute(query)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1709, in execute
>> return self.log_execute(*a, **b)
>>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1703, in log_execute
>> ret = self.cursor.execute(*a, **b)
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 246, 
>> in _fn
>> return fn(self, *args, **kwargs)
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 317, 
>> in execute
>> self._execute(operation, args)
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 322, 
>> in _execute
>> self.cursor.execute(new_query, *new_args)
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
>> 399, in execute
>> self._stmt.execute(*args, **kwargs)
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
>> 169, in execute
>> self._row_desc, cmd = self.c.bind(self._portal_name, 
>> self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
>>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/protocol.py", line 
>> 943, in _fn
>> return fn(self, *argshttps://groups.google.com/group/web2py/msg/64de6b8ababbd2a3?dmode=source&output=gplain&noredirect>
>>
>>

-- 





Re: [web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Daniel Gonzalez
I have not yet upgraded :(

On Tuesday, January 15, 2013 1:25:06 PM UTC+1, Richard Penman wrote:
>
> Already 2.7.3. 
>
> Did you find the problem fixed after upgrading? 
>
>
> On Tue, Jan 15, 2013 at 11:22 PM, Daniel Gonzalez 
> > 
> wrote: 
> > The links I sent are related to mod_wsgi / apache / python 2.7.2, but it 
> is 
> > a generic python 2.7.2 problem. The problems do not happen always. 
> > 
> > What python version are you using? 
> > 
> > 
> > On Tuesday, January 15, 2013 1:20:16 PM UTC+1, Richard Penman wrote: 
> >> 
> >> I used subprocesses on my previous server with uwsgi and had no 
> problem. 
> >> 
> >> 
> >> On Tue, Jan 15, 2013 at 9:51 PM, Niphlod  wrote: 
> >> > I may be out of line here, but the problem may lie in the fact that 
> if 
> >> > you 
> >> > want to start a subprocess usually subprocess.call uses a thread to 
> >> > communicate with it. uwsgi doesn't allow to spawn your own 
> threads 
> >> > as 
> >> > long as you don't supply the --enable-threads parameter. 
> >> > 
> >> > PS: spawning processes from a web-app poses always a lot of problems 
> >> > (concurrency, pipes, stderrs, inherited socket, and so on). Be sure 
> of 
> >> > what 
> >> > you're doing. 
> >> > 
> >> > Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha 
> >> > scritto: 
> >> >> 
> >> >> hello, 
> >> >> 
> >> >> I set up a uwsgi / nginx server using the 
> >> >> setup-web2py-nginx-uwsgi-ubuntu.sh script. 
> >> >> However I find when the app tries to start a sub-process I get this 
> >> >> error: 
> >> >> 
> >> >> Fatal Python error: Couldn't create autoTLSkey mapping 
> >> >> 
> >> >> I read around and apparently this can happen when lack of memory. 
> >> >> 
> >> >> Do you see any problems with these uwsgi settings: 
> >> >>  
> >> >> /tmp/web2py.socket 
> >> >> /var/www/web2py/ 
> >> >> /=wsgihandler:application 
> >> >>  
> >> >> 4 
> >> >> 60 
> >> >> 8 
> >> >> 1 
> >> >> /tmp/stats.socket 
> >> >> 2000 
> >> >> 512 
> >> >> 256 
> >> >> 192 
> >> >> www-data 
> >> >> www-data 
> >> >> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S 
> welcome 
> >> >> -M 
> >> >> -R scripts/sessions2trash.py -A -o 
> >> >>  
> >> >>  
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Daniel Gonzalez
And even worse: I am setting, for testing:

auth.settings.expiration = 3600 * 24 * 30  # one month

But the session is expiring after 5 minutes anyway! What is happening here?

On Tuesday, January 15, 2013 12:14:59 PM UTC+1, Daniel Gonzalez wrote:
>
> And a related question: my session is expiring after 5 minutes (300s). I 
> am not setting the expiration time, and the default in 
> Auth.default_settings.expiration is 3600. 
>
> Where is the 300 coming from!?!?
>
> On Tuesday, January 15, 2013 11:57:03 AM UTC+1, Daniel Gonzalez wrote:
>>
>> Thanks Niphlod,
>>
>> I am now using:
>>
>>- session.auth.expiration
>>- session.auth.last_visit
>>
>> And I have realized about one (at least for me) unexpected thing: 
>> accessing @service.jsonrpc controllers does not 
>> reset session.auth.last_visit. Is this intended?
>>
>> On Tuesday, January 15, 2013 11:43:11 AM UTC+1, Niphlod wrote:
>>>
>>> session expiration is managed by auth.settings.expiration ... 
>>>
>>

-- 





Re: [web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Richard Baron Penman
Already 2.7.3.

Did you find the problem fixed after upgrading?


On Tue, Jan 15, 2013 at 11:22 PM, Daniel Gonzalez  wrote:
> The links I sent are related to mod_wsgi / apache / python 2.7.2, but it is
> a generic python 2.7.2 problem. The problems do not happen always.
>
> What python version are you using?
>
>
> On Tuesday, January 15, 2013 1:20:16 PM UTC+1, Richard Penman wrote:
>>
>> I used subprocesses on my previous server with uwsgi and had no problem.
>>
>>
>> On Tue, Jan 15, 2013 at 9:51 PM, Niphlod  wrote:
>> > I may be out of line here, but the problem may lie in the fact that if
>> > you
>> > want to start a subprocess usually subprocess.call uses a thread to
>> > communicate with it. uwsgi doesn't allow to spawn your own threads
>> > as
>> > long as you don't supply the --enable-threads parameter.
>> >
>> > PS: spawning processes from a web-app poses always a lot of problems
>> > (concurrency, pipes, stderrs, inherited socket, and so on). Be sure of
>> > what
>> > you're doing.
>> >
>> > Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha
>> > scritto:
>> >>
>> >> hello,
>> >>
>> >> I set up a uwsgi / nginx server using the
>> >> setup-web2py-nginx-uwsgi-ubuntu.sh script.
>> >> However I find when the app tries to start a sub-process I get this
>> >> error:
>> >>
>> >> Fatal Python error: Couldn't create autoTLSkey mapping
>> >>
>> >> I read around and apparently this can happen when lack of memory.
>> >>
>> >> Do you see any problems with these uwsgi settings:
>> >> 
>> >> /tmp/web2py.socket
>> >> /var/www/web2py/
>> >> /=wsgihandler:application
>> >> 
>> >> 4
>> >> 60
>> >> 8
>> >> 1
>> >> /tmp/stats.socket
>> >> 2000
>> >> 512
>> >> 256
>> >> 192
>> >> www-data
>> >> www-data
>> >> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome
>> >> -M
>> >> -R scripts/sessions2trash.py -A -o
>> >> 
>> >> 
>> >
>> > --
>> >
>> >
>> >
>
> --
>
>
>

-- 





Re: [web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Daniel Gonzalez
The links I sent are related to mod_wsgi / apache / python 2.7.2, but it is 
a generic python 2.7.2 problem. The problems do not happen always.

What python version are you using?

On Tuesday, January 15, 2013 1:20:16 PM UTC+1, Richard Penman wrote:
>
> I used subprocesses on my previous server with uwsgi and had no problem. 
>
>
> On Tue, Jan 15, 2013 at 9:51 PM, Niphlod > 
> wrote: 
> > I may be out of line here, but the problem may lie in the fact that if 
> you 
> > want to start a subprocess usually subprocess.call uses a thread to 
> > communicate with it. uwsgi doesn't allow to spawn your own threads 
> as 
> > long as you don't supply the --enable-threads parameter. 
> > 
> > PS: spawning processes from a web-app poses always a lot of problems 
> > (concurrency, pipes, stderrs, inherited socket, and so on). Be sure of 
> what 
> > you're doing. 
> > 
> > Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha 
> scritto: 
> >> 
> >> hello, 
> >> 
> >> I set up a uwsgi / nginx server using the 
> >> setup-web2py-nginx-uwsgi-ubuntu.sh script. 
> >> However I find when the app tries to start a sub-process I get this 
> error: 
> >> 
> >> Fatal Python error: Couldn't create autoTLSkey mapping 
> >> 
> >> I read around and apparently this can happen when lack of memory. 
> >> 
> >> Do you see any problems with these uwsgi settings: 
> >>  
> >> /tmp/web2py.socket 
> >> /var/www/web2py/ 
> >> /=wsgihandler:application 
> >>  
> >> 4 
> >> 60 
> >> 8 
> >> 1 
> >> /tmp/stats.socket 
> >> 2000 
> >> 512 
> >> 256 
> >> 192 
> >> www-data 
> >> www-data 
> >> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome 
> -M 
> >> -R scripts/sessions2trash.py -A -o 
> >>  
> >>  
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Richard Baron Penman
hmm, that looked promising but unfortunately found I am already at 2.7.3:

$ python -V
Python 2.7.3


On Tue, Jan 15, 2013 at 10:00 PM, Daniel Gonzalez  wrote:
> I am actually researching the same problem. Please take a look here:
>
> https://groups.google.com/d/topic/modwsgi/DW-SlIb07rE/discussion
> http://bugs.python.org/issue13156
>
> This is a bug in python 2.7.2, and has been solved in 2.7.3. I am also
> affected, and will have to upgrade all my servers :(
>
>
> On Tuesday, January 15, 2013 11:51:44 AM UTC+1, Niphlod wrote:
>>
>> I may be out of line here, but the problem may lie in the fact that if you
>> want to start a subprocess usually subprocess.call uses a thread to
>> communicate with it. uwsgi doesn't allow to spawn your own threads as
>> long as you don't supply the --enable-threads parameter.
>>
>> PS: spawning processes from a web-app poses always a lot of problems
>> (concurrency, pipes, stderrs, inherited socket, and so on). Be sure of what
>> you're doing.
>>
>> Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha
>> scritto:
>>>
>>> hello,
>>>
>>> I set up a uwsgi / nginx server using the
>>> setup-web2py-nginx-uwsgi-ubuntu.sh script.
>>> However I find when the app tries to start a sub-process I get this
>>> error:
>>>
>>> Fatal Python error: Couldn't create autoTLSkey mapping
>>>
>>> I read around and apparently this can happen when lack of memory.
>>>
>>> Do you see any problems with these uwsgi settings:
>>> 
>>> /tmp/web2py.socket
>>> /var/www/web2py/
>>> /=wsgihandler:application
>>> 
>>> 4
>>> 60
>>> 8
>>> 1
>>> /tmp/stats.socket
>>> 2000
>>> 512
>>> 256
>>> 192
>>> www-data
>>> www-data
>>> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M
>>> -R scripts/sessions2trash.py -A -o
>>> 
>>> 
>
> --
>
>
>

-- 





Re: [web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Richard Baron Penman
I used subprocesses on my previous server with uwsgi and had no problem.


On Tue, Jan 15, 2013 at 9:51 PM, Niphlod  wrote:
> I may be out of line here, but the problem may lie in the fact that if you
> want to start a subprocess usually subprocess.call uses a thread to
> communicate with it. uwsgi doesn't allow to spawn your own threads as
> long as you don't supply the --enable-threads parameter.
>
> PS: spawning processes from a web-app poses always a lot of problems
> (concurrency, pipes, stderrs, inherited socket, and so on). Be sure of what
> you're doing.
>
> Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha scritto:
>>
>> hello,
>>
>> I set up a uwsgi / nginx server using the
>> setup-web2py-nginx-uwsgi-ubuntu.sh script.
>> However I find when the app tries to start a sub-process I get this error:
>>
>> Fatal Python error: Couldn't create autoTLSkey mapping
>>
>> I read around and apparently this can happen when lack of memory.
>>
>> Do you see any problems with these uwsgi settings:
>> 
>> /tmp/web2py.socket
>> /var/www/web2py/
>> /=wsgihandler:application
>> 
>> 4
>> 60
>> 8
>> 1
>> /tmp/stats.socket
>> 2000
>> 512
>> 256
>> 192
>> www-data
>> www-data
>> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M
>> -R scripts/sessions2trash.py -A -o
>> 
>> 
>
> --
>
>
>

-- 





[web2py] can't install v 2.3

2013-01-15 Thread Lewis
I tried to run the auto upgrade to the latest version.  Worked on 
Windows/Rocket several times.  Would not work on my linode vps because of 
various permissions problems.  Not a big deal.

Uploaded and unzipped the zip file in /var/web2py.   Set permissions so 
that www-data is the group for all files with rw access.

My constant result is uWSGI Error Python Application not found.  Prior to 
the update, this had never occurred. In the update, I did not modify my 
uWSGI config at all.

Here is the uWSGI log:


*** Starting uWSGI 1.2.3 (32bit) on [Tue Jan 15 11:41:15 2013] ***
compiled with version: 4.6.1 on 17 May 2012 23:33:21
detected number of CPU cores: 4
current working directory: /
writing pidfile to /var/run/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
setgid() to 33
setuid() to 33
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to UNIX address /tmp/web2py.sock fd 3
Python version: 2.7.2+ (default, Oct  4 2011, 20:29:37)  [GCC 4.6.1]
*** Python threads support is disabled. You can enable it with 
--enable-threads ***
Python main interpreter initialized at 0x8d69538
your server socket listen backlog is limited to 100 connections
*** Operational MODE: preforking ***
added /var/web2py/ to pythonpath.
Traceback (most recent call last):
  File "/var/web2py/wsgihandler.py", line 33, in 
import gluon.main
ImportError: No module named gluon.main
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 23798)
spawned uWSGI worker 1 (pid: 23799, cores: 1)
spawned uWSGI worker 2 (pid: 23800, cores: 1)
spawned uWSGI worker 3 (pid: 23801, cores: 1)
spawned uWSGI worker 4 (pid: 23802, cores: 1)


You can see in the log that the import of gluon.main fails.  I tried a very 
old hint from Massimo to hard code the path to web2py in wsgihandler.py. 
 This is what lines of wsgihandler.py up to that point look like:

login as: root
root@96.126.123.83's password:
Welcome to Ubuntu 11.10 (GNU/Linux 3.0.18-linode43 i686)

 * Documentation:  https://help.ubuntu.com/
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro 
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)


This is a WSGI handler for Apache
Requires apache+mod_wsgi.

In httpd.conf put something like:

LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /path/to/wsgihandler.py

"""

# change these parameters as required
LOGGING = False
SOFTCRON = False

import sys
import os

path = '/var/web2py'
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not p == path]

sys.stdout = sys.stderr

import gluon.main

if LOGGING:
application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
logfilename='httpserver.log',
profilerfilename=None)
else:
application = gluon.main.wsgibase

if SOFTCRON:
from gluon.settings import global_settings
global_settings.web2py_crontype = 'soft'



I also set the sys.path for python to include both web2py and web2py/gluon 
in my uwsgi init script:  PYTHONPATH=/var/web2py:/var/web2py/gluon.  After 
doing this the uwsgi log reports added /var/web2py:/varweb2py/gluon to 
pythonpath.  This resulted in a different import error--now it can't find 
wsgihandler ("ImportError: No module named wsgihandler").

This is very frustrating.  Everything worked perfectly with earlier version 
of web2py.  Config is just massively fragile with so many moving parts.

Sorry for the long post.  Thanks for your help.




-- 





[web2py] Re: Web2Py function to query the database...

2013-01-15 Thread Mihir Lade
Also, I am querying a local database that I created using the DAL. 
Yes, I am creating a custom HTML form and posting it to web2py to query the 
database.. 

On Sunday, January 13, 2013 9:45:11 AM UTC+10:30, Anthony wrote:
>
> Can you provide more details regarding what you have tried? How are you 
> creating the form and posting to web2py? Are you querying local databases 
> that you are modeling with the DAL, or are you querying some external API's?
>
> When you submit a form to web2py (via GET or POST), the variables will be 
> available in request.vars (also in request.get_vars if a GET request and 
> request.post_vars if a POST request). If you create the form via a web2py 
> FORM or SQLFORM, then once the form has been processed, the values will 
> also be in form.vars. From there it's up to you to use the values to 
> construct your query.
>
> Anthony
>
> On Saturday, January 12, 2013 6:10:05 PM UTC-5, Mihir Lade wrote:
>>
>> Hi Alan,
>>
>> I've read the chapters a few times however having difficulty 
>> understanding a HTML search page would pass the information to a function 
>> where it queries multiple databases to return the data?
>>
>> On Sunday, January 13, 2013 8:14:07 AM UTC+10:30, Alan Etkin wrote:
>>>
>>> The book has anything you are asking for and much more. For an 
>>> introduction to forms and controllers I think you could check the examples 
>>> at Overview:
>>>
>>> http://www.web2py.com/books/default/chapter/29/03#Overview
>>>
>>> Also, there are appliances available you can use as example:
>>>
>>> http://www.web2py.com/appliances
>>>
>>> Once you have learned using the basic API you can check for more 
>>> examples at:
>>>
>>> http://www.web2pyslices.com
>>>
>>>
>>> El sábado, 12 de enero de 2013 07:13:11 UTC-3, Mihir Lade escribió:

 Hi Guys,

 I am currently working on an assignment where I need to create a 
 function which would query the database to search flights available 
 according to the users input through the HTML form. I have attached a 
 picture of the HTML form.

 Basically the user, selects the origin, the destination, oneway/return, 
 departure date, arrival date, etc etc and than clicks submit.

 This should than return all the flights available in a different page, 
 however I am having difficulty actually writing the function that will 
 query the database to do this.

 I am not sure how the HTML form would pass the values to the 
 searchFlights() function and what the function may look like.. 

 Can some one please assist me with this? Any help with this would be 
 REALLY appreciated. 

 Thank you in advanced.

>>>

-- 





[web2py] OT -- PyCon registration open

2013-01-15 Thread Joe Barnhart
I'm disappointed there are no web2py talks... But I'm still going. 

It sold out pretty quickly last year so sign up now if you're going. 

-- Joe B. 

-- 





[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Daniel Gonzalez
And a related question: my session is expiring after 5 minutes (300s). I am 
not setting the expiration time, and the default in 
Auth.default_settings.expiration is 3600. 

Where is the 300 coming from!?!?

On Tuesday, January 15, 2013 11:57:03 AM UTC+1, Daniel Gonzalez wrote:
>
> Thanks Niphlod,
>
> I am now using:
>
>- session.auth.expiration
>- session.auth.last_visit
>
> And I have realized about one (at least for me) unexpected thing: 
> accessing @service.jsonrpc controllers does not 
> reset session.auth.last_visit. Is this intended?
>
> On Tuesday, January 15, 2013 11:43:11 AM UTC+1, Niphlod wrote:
>>
>> session expiration is managed by auth.settings.expiration ... 
>>
>

-- 





[web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Daniel Gonzalez
I am actually researching the same problem. Please take a look here:

https://groups.google.com/d/topic/modwsgi/DW-SlIb07rE/discussion
http://bugs.python.org/issue13156

This is a bug in python 2.7.2, and has been solved in 2.7.3. I am also 
affected, and will have to upgrade all my servers :(

On Tuesday, January 15, 2013 11:51:44 AM UTC+1, Niphlod wrote:
>
> I may be out of line here, but the problem may lie in the fact that if you 
> want to start a subprocess usually subprocess.call uses a thread to 
> communicate with it. uwsgi doesn't allow to spawn your own threads as 
> long as you don't supply the --enable-threads parameter.
>
> PS: spawning processes from a web-app poses always a lot of problems 
> (concurrency, pipes, stderrs, inherited socket, and so on). Be sure of what 
> you're doing.
>
> Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha 
> scritto:
>>
>> hello,
>>
>> I set up a uwsgi / nginx server using 
>> the setup-web2py-nginx-uwsgi-ubuntu.sh script.
>> However I find when the app tries to start a sub-process I get this error:
>>
>> Fatal Python error: Couldn't create autoTLSkey mapping
>>
>> I read around and apparently this can happen when lack of memory.
>>
>> Do you see any problems with these uwsgi settings:
>> 
>> /tmp/web2py.socket
>> /var/www/web2py/
>> /=wsgihandler:application
>> 
>> 4
>> 60
>> 8
>> 1
>> /tmp/stats.socket
>> 2000
>> 512
>> 256
>> 192
>> www-data
>> www-data
>> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M 
>> -R scripts/sessions2trash.py -A -o
>> 
>> 
>>
>

-- 





[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Daniel Gonzalez
Thanks Niphlod,

I am now using:

   - session.auth.expiration
   - session.auth.last_visit
   
And I have realized about one (at least for me) unexpected thing: 
accessing @service.jsonrpc controllers does not 
reset session.auth.last_visit. Is this intended?

On Tuesday, January 15, 2013 11:43:11 AM UTC+1, Niphlod wrote:
>
> session expiration is managed by auth.settings.expiration ... 
>

-- 





[web2py] Re: Fatal Python error: Couldn't create autoTLSkey mapping

2013-01-15 Thread Niphlod
I may be out of line here, but the problem may lie in the fact that if you 
want to start a subprocess usually subprocess.call uses a thread to 
communicate with it. uwsgi doesn't allow to spawn your own threads as 
long as you don't supply the --enable-threads parameter.

PS: spawning processes from a web-app poses always a lot of problems 
(concurrency, pipes, stderrs, inherited socket, and so on). Be sure of what 
you're doing.

Il giorno martedì 15 gennaio 2013 06:30:14 UTC+1, Richard Penman ha scritto:
>
> hello,
>
> I set up a uwsgi / nginx server using 
> the setup-web2py-nginx-uwsgi-ubuntu.sh script.
> However I find when the app tries to start a sub-process I get this error:
>
> Fatal Python error: Couldn't create autoTLSkey mapping
>
> I read around and apparently this can happen when lack of memory.
>
> Do you see any problems with these uwsgi settings:
> 
> /tmp/web2py.socket
> /var/www/web2py/
> /=wsgihandler:application
> 
> 4
> 60
> 8
> 1
> /tmp/stats.socket
> 2000
> 512
> 256
> 192
> www-data
> www-data
> 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M 
> -R scripts/sessions2trash.py -A -o
> 
> 
>

-- 





[web2py] Re: What is the timeout for the session?

2013-01-15 Thread Niphlod
session expiration is managed by auth.settings.expiration ... 

-- 





[web2py] Re: Auth with migrate=False

2013-01-15 Thread Niphlod
migrate=False is on the db or on Auth define_table() call ?



Il giorno martedì 15 gennaio 2013 11:07:49 UTC+1, Paolo valleri ha scritto:
>
> Hi all, I tried something odd.
> I pulled a fresh copy of my code from git and I connected the app to an 
> already 'working' database. 'working' in the meaning that both tables and 
> data are already in the database. In web2py this approach fails, because at 
> the first run it tries to create all the tables, and the db raises an 
> exception like 'table already exist'.
> In order to fix that I thought that migrate=False would help, however it 
> fails again. due to Auth that tries to create the tables. Ticket:
>
> Traceback (most recent call last):
>   File "/home/pvalleri/src/web2py/gluon/restricted.py", line 212, in 
> restricted
> exec ccode in environment
>   File 
> "/home/pvalleri/src/web2py/applications/vtraffic/controllers/default.py" 
> , 
> line 6, in 
> start = db.record.with_alias('start_point')
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
> return self.lazy_define_table(tablename,*fields,**args)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7174, in 
> lazy_define_table
> table = table_class(self, tablename, *fields, **args)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7594, in __init__
> field.requires = sqlhtml_validators(field)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 6338, in 
> sqlhtml_validators
> referenced = db[field_type[10:]]
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
> return self.__getattr__(str(key))
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
> return self.lazy_define_table(tablename,*fields,**args)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7177, in 
> lazy_define_table
> table._create_references() # must follow above line to handle self 
> references
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7663, in 
> _create_references
> rtable = db[rtablename]
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7215, in __getitem__
> return self.__getattr__(str(key))
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7221, in __getattr__
> return self.lazy_define_table(tablename,*fields,**args)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 7189, in 
> lazy_define_table
> polymodel=polymodel)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 935, in create_table
> self.create_sequence_and_triggers(query,table)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 2483, in 
> create_sequence_and_triggers
> self.execute(query)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1709, in execute
> return self.log_execute(*a, **b)
>   File "/home/pvalleri/src/web2py/gluon/dal.py", line 1703, in log_execute
> ret = self.cursor.execute(*a, **b)
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 246, 
> in _fn
> return fn(self, *args, **kwargs)
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 317, 
> in execute
> self._execute(operation, args)
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/dbapi.py", line 322, 
> in _execute
> self.cursor.execute(new_query, *new_args)
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
> 399, in execute
> self._stmt.execute(*args, **kwargs)
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/interface.py", line 
> 169, in execute
> self._row_desc, cmd = self.c.bind(self._portal_name, 
> self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
>   File "/home/pvalleri/src/web2py/gluon/contrib/pg8000/protocol.py", line 
> 943, in _fn
> return fn(self, *argshttps://groups.google.com/group/web2py/msg/64de6b8ababbd2a3?dmode=source&output=gplain&noredirect>
>
>

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread Paolo valleri
Try to add lazy_tables=True to DAL. Like:
db = DAL('sqlite://storage.sqlite', migrate=False, lazy_tables=True)


Paolo

On Tuesday, January 15, 2013 10:06:03 AM UTC+1, Daniel Gonzalez wrote:
>
> No imports in the code-area profiled. Also, I am testing some requests, 
> but the time I am measuring is the time spent in the code-area that I have 
> provided. That is, in the define tables code. The controllers are of course 
> making use of the table definitions later, but that is not what I am 
> measuring.
>
> I have put a "print time.time()" before and after the "define tables" 
> code. So no controller is involved in my measurements.
>
> On Tuesday, January 15, 2013 9:56:57 AM UTC+1, rochacbruno wrote:
>>
>> It will run only when called!
>>
>> But if he is testing a form, the problem maybe there.
>>
>> There are some imports?
>>
>

-- 





[web2py] What is the timeout for the session?

2013-01-15 Thread Daniel Gonzalez
Hi,

In one of my controllers I would to display:

   - what is the timeout for this session
   - how long has the current session still to stay active
   - a list of requests / timestamps (I guess this is not tracked in web2py)
   - when was the last request performed (unfortunately this will be the 
   current request, so it will be "now"?)
   
I have taken a look at the code and I found:

   - Session._last_timestamp

But I am unable to see where the timeout parameter is set for a 
session. Definitely not in Session.connect() ...

Thanks,
Daniel

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-15 Thread Kostas M
OK fine, then why, in continuation of the above example,

def test():
grid = SQLFORM.smartgrid(db.person, linked_tables=['dog'], ondelete=dict
( dog=ondelete_test ))
return dict(grid=grid)

def ondelete_test(table_involved, id_of_the_deleted_record):
print table_involved
print id_of_the_deleted_record


ondelete=dict( dog=ondelete_test ) doesn't fire  (nothing is printed, one 
dog row is removed but on refresh is back), 
while 
ondelete=ondelete_test   does fire, prints the values, and removes 
permantly the rows

ondelete doesn't belong to both grid and smartgrid? Or this is a bug?


On Tuesday, January 15, 2013 1:30:12 AM UTC, Massimo Di Pierro wrote:
>
> The rule is simple. All options that belong to both grid and smartgrid 
> (except args) can take a dictionary in smartgrid. If a dictionary is 
> passed, the value is passed the grid, in correspondance to a key == 
> tablename.
>
>
>

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread Daniel Gonzalez
No imports in the code-area profiled. Also, I am testing some requests, but 
the time I am measuring is the time spent in the code-area that I have 
provided. That is, in the define tables code. The controllers are of course 
making use of the table definitions later, but that is not what I am 
measuring.

I have put a "print time.time()" before and after the "define tables" code. 
So no controller is involved in my measurements.

On Tuesday, January 15, 2013 9:56:57 AM UTC+1, rochacbruno wrote:
>
> It will run only when called!
>
> But if he is testing a form, the problem maybe there.
>
> There are some imports?
>

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread Bruno Rocha
It will run only when called!

But if he is testing a form, the problem maybe there.

There are some imports?

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread David Marko
It really runs these validators during table definition, and not just in 
time when used? So its better to define this requires= ... in controller 
where this is used?

David

Dne úterý, 15. ledna 2013 9:23:43 UTC+1 rochacbruno napsal(a):
>
>
> On Tue, Jan 15, 2013 at 6:20 AM, Daniel Gonzalez 
> 
> > wrote:
>
>> IS_NOT_IN_DB(db, '%s.email' % (web2py_user_table))
>
>
> If you too many records on user table, the above code will take a long 
> time, because on every request it will "select email from auth_user"
>
>
>
>

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread Daniel Gonzalez
Very few records (around 10). I am testing still.

On Tuesday, January 15, 2013 9:23:43 AM UTC+1, rochacbruno wrote:
>
>
> On Tue, Jan 15, 2013 at 6:20 AM, Daniel Gonzalez 
> 
> > wrote:
>
>> IS_NOT_IN_DB(db, '%s.email' % (web2py_user_table))
>
>
> If you too many records on user table, the above code will take a long 
> time, because on every request it will "select email from auth_user"
>
>
>
>

-- 





[web2py] Re: how to embed a d3.js script in a view correctly?

2013-01-15 Thread Martina Gruber
Alan and Ramos, thnk you for the answers.
Based on your recommendations I did the following: 
1. Created a new app with the wizard (default layout, name: TestD3). Views: 
index,error and visualizations where I want to have the d3 stuff. 
2. Put the d3 javascript file in static/js 
3. In View TestD3/views/default/visualizations.html:
   
{{response.files.append(URL(r=request,c='static',f='/js/d3.js'))}}
   {{extend 'layout.html'}}

   Here we would like to have some d3.js plots
   
 
d3.select('body').append('svg').append('circle').style("stroke", 
"gray").style("fill", "red").attr("r", 40).attr("cx", 50).attr("cy", 50);
   

This produced a red circle but the circle below the copyright 2013-- 
powered by web2py line.
Of course I have to select properly because I want to have the circle 
inside:

  


I ll take some time to dive into web2py and then I will post whatever 
worked with d3.



-- 





[web2py] Postgres User-Defined Types?

2013-01-15 Thread pbreit
I'm trying to connect to a DB that has some user-defined types. Is this 
supported in Web2py? I get:

Traceback (most recent call last):
  File "/Users/pbreit/Sites/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File 
"/Users/pbreit/Sites/web2py/applications/balanced/controllers/default.py" 
, 
line 95, in 
  File "/Users/pbreit/Sites/web2py/gluon/globals.py", line 193, in 
self._caller = lambda f: f()
  File 
"/Users/pbreit/Sites/web2py/applications/balanced/controllers/default.py" 
, 
line 39, in holds
(db.holds.marketplace_guid.like('MP%'))).select()
  File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 8966, in select
return adapter.select(self.query,fields,attributes)
  File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1636, in select
return self._select_aux(sql,fields,attributes)
  File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1601, in _select_aux
self.execute(sql)
  File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1714, in execute
return self.log_execute(*a, **b)
  File "/Users/pbreit/Sites/web2py/gluon/dal.py", line 1708, in log_execute
ret = self.cursor.execute(*a, **b)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 246, in 
_fn
return fn(self, *args, **kwargs)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 317, in 
execute
self._execute(operation, args)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/dbapi.py", line 322, in 
_execute
self.cursor.execute(new_query, *new_args)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/interface.py", line 
399, in execute
self._stmt.execute(*args, **kwargs)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/interface.py", line 
169, in execute
self._row_desc, cmd = self.c.bind(self._portal_name, self._statement_name, 
args, self._parse_row_desc, kwargs.get("stream"))
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/protocol.py", line 943, 
in _fn
return fn(self, *args, **kwargs)
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/protocol.py", line 
1117, in bind
output_fc = [types.py_type_info(f) for f in row_desc.fields]
  File "/Users/pbreit/Sites/web2py/gluon/contrib/pg8000/types.py", line 162, in 
py_type_info
raise NotSupportedError("type oid %r not mapped to py type" % type_oid)
NotSupportedError: type oid 20716 not mapped to py type

-- 





Re: [web2py] Set up of db.py takes too long time

2013-01-15 Thread Bruno Rocha
On Tue, Jan 15, 2013 at 6:20 AM, Daniel Gonzalez  wrote:

> IS_NOT_IN_DB(db, '%s.email' % (web2py_user_table))


If you too many records on user table, the above code will take a long
time, because on every request it will "select email from auth_user"

-- 





[web2py] Set up of db.py takes too long time

2013-01-15 Thread Daniel Gonzalez
Hi,

My db.py takes a long time to run (around 40 ms). This means that just the 
overhead of db.py limits my throughput to 25 req/s (in a single process / 
single thread configuration). This seems to me quite low.

I have tried to take a look at where the time is spent. I have seen the 
following runtimes. These are average values:

 8 ms -> session.connect(request,response,db=MEMDB(cache.memcache))
 2 ms -> db = DAL('sqlite://storage.sqlite', migrate=False)
 5 ms -> auth = Auth(db)
20 ms -> define tables

My define tables is like this:

# Use the authorization table for users
web2py_user_table = auth.settings.table_user_name
# web2py_user_table = 'web2py_user'
db.define_table(
web2py_user_table,
Field('org_id',   type='integer', compute=set_org_id),
Field('email',unique=True),
Field('user_doc_id',  length=128, compute=create_new_user),
Field('password', length=512, compute=automatic_password
, type='password', readable=False, label='Password'), # TODO: use CRYPT
# These fields are needed for authorization
Field('registration_key', length=512, writable=False, readable=
False, default=''),
Field('reset_password_key',   length=512, writable=False, readable=
False, default=''),
Field('registration_id',  length=512, writable=False, readable=
False, default=''),
format = '%(email)s')

# Add constraints to the web2py_user table
web2py_user = db[web2py_user_table]
web2py_user.email.requires= [IS_EMAIL(error_message=auth.
messages.invalid_email), IS_NOT_IN_DB(db, '%s.email' % (web2py_user_table))]
# web2py_user.user_doc_id.requires = 
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
# web2py_user.password.requires = [IS_STRONG(min=5, special=0, 
upper=0), CRYPT()]

auth.define_tables()

Those run times look to me quite high. Maybe some of you can give me hints:

   - Is there anything I can do to speed this up?
   - Why is the define tables taking such a long time, even with 
   migrate=False?
   - Would moving to postgres improve things a lot?
   - Is sqlite the bottleneck here?
   
It is difficult for me to believe that sqlite is the cultprit here: I am 
using a single client in my tests, sending requests sequentially (no 
parallel requests).

Thanks,
Daniel

-- 





[web2py] Re: Web2Py function to query the database...

2013-01-15 Thread Mihir Lade
Hi Anthony, 

Thanks for your reply.

The code to searchFlights is as below:

def searchFlights():
return dict()

def show():
*receivedFlights = 
request.vars.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.vlassType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants
*
return dict(txt1=recievedflights, 
flights=db().select(db.Flight.request.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.classType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants))

However I am currently getting an error with this:-

receivedFlights = 
request.vars.originCity+','+request.vars.destCity+','+request.vars.type+','+request.vars.deptDate+','+request.vars.arrivalDate+','+request.vars.vlassType+','+request.vars.noOfAdults+','+request.vars.noOfChildren+','+request.vars.noOfInfants
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

The error is with the line being highlighted above.. 

I am not to sure as to how I can fix this error... 


--