[web2py] Problem with SQLFORM.grid

2011-09-05 Thread brushek
Hello,

I have following table with custom type (database: postgres):
from gluon.sql import SQLCustomType
inet = SQLCustomType ( type='string', native='inet', encoder=lambda x:
repr(str(x)))
db.define_table("serwery",
Field("id_klienci",db.klienci),
Field("ip_serwera",type=inet,requires = IS_IPV4()))

When I try to use SQLFORM.grid, like this:

@auth.requires_login()
def dodajserwer():
response.flash = T('Serwery')
form=SQLFORM.grid(db.serwery)

if form.accepts(request.vars, session):
response.flash='Serwer dodany'
elif form.errors:
response.flash = 'popraw'

return dict(form=form)

I get following error:
Traceback (most recent call last):
  File "/home/users/brushek/web2py/gluon/restricted.py", line 194, in
restricted
exec ccode in environment
  File "/home/users/brushek/web2py/applications/welcome/controllers/
default.py", line 138, in 
  File "/home/users/brushek/web2py/gluon/globals.py", line 145, in

self._caller = lambda f: f()
  File "/home/users/brushek/web2py/gluon/tools.py", line 2510, in f
return action(*a, **b)
  File "/home/users/brushek/web2py/applications/welcome/controllers/
default.py", line 60, in dodajserwer
form=SQLFORM.grid(db.serwery)
  File "/home/users/brushek/web2py/gluon/sqlhtml.py", line 1430, in
grid
T = current.T
TypeError: reduce() of empty sequence with no initial value

Where can be problem ?

regards
brushek


Re: [web2py] Compile from command line

2011-09-05 Thread Thomas Bellembois

Le 29/08/2011 04:40, Mike Veltman a écrit :

here: http://thadeusb.com/weblog/2010/4/21/compile_web2py_apps_externally

python -c "import gluon.compileapp;
gluon.compileapp.compile_application('applications/')"

On Sun, Aug 28, 2011 at 10:05 PM, Mike Veltman

wrote:

Its pretty annoying because I did know it before.

Does anybody know what the command is to compile from the command line ?

Also is there are website or part of the book that will collect this so I
can
add it ?

Thanks in advance.



With regards,
Mike Veltman


That was it ! thanks :)

With regards,
Mike Veltman


Sorry for this basic question about compiled apps: do we have to run 
web2py in a different way with a compiled app ? or does web2py detect 
that there is a compiled version ?


Regards,

Thomas


[web2py] help setting up web2py on a shared host

2011-09-05 Thread Brenty
I would really appreciate some help setting up web2py on a shared
host.

I have followed the "Shared Hosting with mod_python" part of The Book.
When I try to access the application, the webpage displays "[an error
occurred while processing this directive]".  The URLs 
http://www.lisjac.com/web2py2,
http://www.lisjac.com/web2py2/myapp, 
http://www.lisjac.com/web2py2/application/myapp
all return the same error.

Put the web2py folder in www/ (htdocs) folder.  Created
web2py_modpython.py and .htaccess as instructed and put it in the www/
web2py/ folder.

Was I supposed to do anything else?

I also used the script in this post,
http://groups.google.com/group/web2py/browse_thread/thread/bc29ddd40d441a6d/99da85a9db041b2b?lnk=gst&q=shared#99da85a9db041b2b.
The script ran without errors, but when i access the pages it just
shows the file structure of the contents of the files.

I'm a complete noob to this, so if you have a technical answer, please
try to dumb it down :p

Thank
Brent


[web2py] uploading my web2py website

2011-09-05 Thread Web2Py Freak
hey guys ,

anyone can tell me how to upload my website online  , what file do i
pick ?? helppp


[web2py] Facebook Auth & password cleanup

2011-09-05 Thread Bruno Rocha
Hi,

I am using Michele's Facebook API, works like a charm (with few
modifications)

But, every time an existing user signin-in the password is cleaned, I would
like to keep the password unchanged because my users will login via facebook
and normal auth.

I changed a littlem included more permissions and changed from username to
email for auth, just need to know how to keep email. somebody knows about
it?

(I also found that it is impossible to get offline_access permission due to
'expires' KeyError in contrib/Oauth20...)




http://code.google.com/r/michelecomitini-facebookaccess/source/browse/
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] DAL reserved keywords (Inherited method from dictionary)

2011-09-05 Thread max
Hi web2py users,

currently i am working with the newest version of dal with an existing (and 
currently in use by other users) database structure (Postgres), so i can't 
change any field-name or something like that. In this Database is the field 
'values' defined. But if I try to connect via psycopg2 driver und dal.py i 
get an error:

Traceback (most recent call last):
  File "test.py", line 87, in 
db = DB('bi_2302').get_db()
  File "test.py", line 59, in get_db
converted.append(Field(str(field)))
  File "/home/mao/dal.py", line 5307, in __init__
raise SyntaxError, 'Field: invalid field name: %s' % fieldname
SyntaxError: Field: invalid field name: values

 The simple reason (it took me a long time thinking about that) is that the 
DAL class has an Inherited method from dict called values. So i cant call 
the field:

db = DAL('postgres://testuser:testpassword@testhost/testdb')
db.define_table('testtab', Field('test'), Field('values'))
db(db.testtab.values).select()

Do you have any ideas for a workaround or is there a possibility avoid this 
problem.

Greets Max


[web2py] Re: testing scheduler in windows

2011-09-05 Thread Niphlod
same thing happened here, but only the second time I ran web2py -K it
was able to load pending scheduled tasks.
it definitely spans a new subprocess every few seconds until task
manager is clobbered .


Re: [web2py] Problem with SQLFORM.grid

2011-09-05 Thread Johann Spies
Hallo Brushek,

I am also trying out SQLFORM.grid/smartgrid and learn as I go.

@auth.requires_login()
> def dodajserwer():
>response.flash = T('Serwery')
>form=SQLFORM.grid(db.serwery)
>
>
Apparently the usage is either SQLFORM.smartgrid(table) or
SQLFORM.grid(query)

Try   'form = SQLFORM.smartgrid(db.serwery)'

or'form = SQLFRORM.grid(db(db.serwery.id > 0))'

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: uploading my web2py website

2011-09-05 Thread annet
Hi,

> anyone can tell me how to upload my website online, what file do i
> pick??

At http://127.0.0.1:8000/admin/default/site: you simply click your
app's 'pack all' link.


At https://www.yourdomain.com/admin/default/site

In the upload and install form browse to e.g.: /Users/you/downloads/
web2py.app.appname.w2p and rename it (required) appname. Click
install.


Otherwise have a look at: http://www.web2py.com/book/default/chapter/11


Kind regards,

Annet


Re: [web2py] Re: uploading my web2py website

2011-09-05 Thread António Ramos
Do we have a woman here?
We are not alone :)

Best regards
António


2011/9/5 annet 

> Hi,
>
> > anyone can tell me how to upload my website online, what file do i
> > pick??
>
> At http://127.0.0.1:8000/admin/default/site: you simply click your
> app's 'pack all' link.
>
>
> At https://www.yourdomain.com/admin/default/site
>
> In the upload and install form browse to e.g.: /Users/you/downloads/
> web2py.app.appname.w2p and rename it (required) appname. Click
> install.
>
>
> Otherwise have a look at: http://www.web2py.com/book/default/chapter/11
>
>
> Kind regards,
>
> Annet
>


[web2py] Re: Problem with SQLFORM.grid

2011-09-05 Thread brushek


On 5 Wrz, 15:55, Johann Spies  wrote:
> Hallo Brushek,
>
> I am also trying out SQLFORM.grid/smartgrid and learn as I go.
>
> @auth.requires_login()> def dodajserwer():
> >    response.flash = T('Serwery')
> >    form=SQLFORM.grid(db.serwery)
>
> Apparently the usage is either SQLFORM.smartgrid(table) or
> SQLFORM.grid(query)
>
> Try   'form = SQLFORM.smartgrid(db.serwery)'

I tried this one before posting...

>
> or    'form = SQLFRORM.grid(db(db.serwery.id > 0))'
>

... and this one doesn't change the situtaion, the error is the same.

regards
Brushek


[web2py] Re: uploading my web2py website

2011-09-05 Thread Web2Py Freak
Annet ,
i meent to take it online to a host , i packed everything and uploaded
it to a python server  it didnt work  , i really dont know what to
do  .. now i have a domain and i want to use my site in it  , tell me
how to do that  please ?   Thank you alot


[web2py] upload/post of semi-large files

2011-09-05 Thread Carlos
Hi,

My production environment is ubuntu, postgresql, uwsgi and nginx.

The issue I'm having is when posting a form with a semi-large file (~2 mb), 
where it keeps 'resetting' the % uploaded every 30 seconds up to 2 to 3 
times, and finally failing (with no specific error that I could see).

I thought this could be fixed by setting a big number for uwsgi's harakiri 
option (which defaults to 60 secs), but that doesn't seem to help.

What should I do to fix this and allow posting forms with semi-large files 
that take about a minute or so to upload?.

Thanks!,

   Carlos



[web2py] appadmin and db.Table definition

2011-09-05 Thread Manuele

Hi,

if you simply cut & paste the following code in a model of a generic app 
maybe you'll get a table called layers_wms in your database without any 
problem but if you try to insert a record in it you'll get the traceback 
reported after.


Can you help me to understand why I get this traceback?

from gluon.storage import Storage
class OpenLayers(object):
basic = db.Table(db, '_basic_',
Field('name', required=True, unique=True, label=T('Name'), 
comment=T('Layer Name'))

)
WMS = Storage(dict(
options = db.Table(db, '_options_',
Field('layers', required=True, unique=True, 
label=T('workspace:name'), comment=T('Layer\'s workspace and name')),
#Field('projection', miscdb.locations, default=1, 
required=True, notnull=True,

#requires=IS_IN_DB(miscdb, 'locations.id', '%(name)s')),
Field('format', default='image/png'),
Field('transparent', 'boolean', default=True),
Field('opacity', 'decimal(4,2)', default=1.0),
Field('visibility', 'boolean', default=True,
#requires=JS_BOOLEAN(), 
widget=SQLFORM.widgets.boolean.widget

),
))
)
WMS['Layer'] = db.Table(db, '_wms_',
basic,
Field('url', label=T('Url'), comment=T(''), requires=IS_URL()),
WMS.options,
# {Boolean} Default is true for WMS layer
Field('isBaseLayer', 'boolean', default=False)
# {Boolean} Should the BBOX commas be encoded?
#   Field('encodeBBOX'),
# {Boolean} If true, the image format will not be 
automagicaly switched
# from image/jpeg to image/png or image/gif when using 
TRANSPARENT=TRUE.

#   Field('noMagic'),
)

db.define_table('layers_wms',
OpenLayers.WMS.Layer
)

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.



Traceback(most recent call last):
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/restricted.py",line192,inrestricted
execccodeinenvironment
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
  
,line410,in
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/globals.py",line145,in
self._caller=lambdaf:f()
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
  
,line127,ininsert
ifform.accepts(request.vars,session):
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/sqlhtml.py",line1043,inaccepts
hideerror=hideerror,
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1765,inaccepts
status=self._traverse(status,hideerror)
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line733,in_traverse
newstatus=self._validate()
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1538,in_validate
(value,errors) =validator(value)
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/validators.py",line515,in__call__
field=self.dbset.db[tablename][fieldname]
  
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/dal.py",line4325,in__getitem__
returndict.__getitem__(self,str(key))
KeyError:'_basic_'







[web2py] Re: uploading my web2py website

2011-09-05 Thread annet
Hi Antonio,

> Do we have a woman here?
> We are not alone :)

Yes, you do.


Kind regards,

Annet.


[web2py] Re: uploading my web2py website

2011-09-05 Thread Web2Py Freak
guys ,
 what is the best web2py host and what to do when i have a domin  , i
packed everythin  so what now ???


Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Martín Mulone
The new version is completely broke in linux too, I confirm this.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python26\lib\threading.py", line 525, in __bootstrap_inner
self.run()
  File "C:\Users\Brian\Documents\development\web2py\google hg
repo\trunk\gluon\s
cheduler.py", line 196, in run
self.send_heartbeat(counter)
  File "C:\Users\Brian\Documents\development\web2py\google hg
repo\trunk\gluon\s
cheduler.py", line 425, in send_heartbeat
self.define_tables(self.db_thread,migrate=False)
  File "C:\Users\Brian\Documents\development\web2py\google hg
repo\trunk\gluon\s
cheduler.py", line 289, in define_tables
default=current.request.application,writable=False),
AttributeError: 'thread._local' object has no attribute 'request'

2011/9/4 Massimo Di Pierro 

> Can you try delete everything in yourapp/databases
> Do not schedule any task.
> In scheduler.py replace
> default=current.request.application
> with
> default=None
> run
>
> python web2py.py -K yourapp
>
> What output do you get?
>
> Massimo
>
> On Sep 3, 11:12 pm, Brian M  wrote:
> > OK, finally managed to pull new trunk off of google code. :)  Still
> doesn't
> > seem to be working on Windows. :(
> >
> >1. The necessary DB tables don't ever seem to get created without user
> >intervention.  I had to temporarily edit gluon/scheduler.py to have
> >migrate=True in the __init__ of the scheduler class.  Looks like if
> you run
> >scheduler.py directly it is supposed to do it automatically, but that
> just
> >fails (see #4)
> >2. Once I got the DB tables defined I was able to insert
> scheduler_task
> >records OK.
> >3. Running python web2py.py -K scheduler resulted in a TON of new
> python
> >processes starting - about one a second or so.
> >   1. Hitting ctrl+c seemed to result in as least one of the workers
> >   trying to do its thing - it checked for and found my demo1 task and
> said it
> >   was starting it...but the task doesn't seem to have actually run.
> (Output of
> >   test run is at bottom of this message)
> >4. Trying to run python gluon/scheduler.py still dies because it can't
> >find DAL.  Not sure if this is currently intended to work though.
> >
> > Console output of test run of scheduler (rev2362) on Windows 7 with
> Python
> > 2.6.4
> >
> ---
> ---
> > C:\Users\Brian\Documents\development\web2py\google hg repo\trunk>python
> > web2py.py -K scheduler
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2011
> > Version 1.98.2 (2011-09-03 22:19:50)
> > Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> > starting scheduler for "scheduler"...
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2011
> > Version 1.98.2 (2011-09-03 22:19:50)
> > Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> > starting scheduler for "scheduler"...
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2011
> > Version 1.98.2 (2011-09-03 22:19:50)
> > Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> > starting scheduler for "scheduler"...
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2011
> > Version 1.98.2 (2011-09-03 22:19:50)
> > Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> > starting scheduler for "scheduler"...
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "C:\Python26\lib\multiprocessing\forking.py", line 341, in main
> > prepare(preparation_data)
> >   File "C:\Python26\lib\multiprocessing\forking.py", line 456, in prepare
> > '__parents_main__', file, path_name, etc
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\web2py.
> > py", line 16, in 
> > import gluon.widget
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\_
> > _init__.py", line 15, in 
> > from globals import current
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\g
> > lobals.py", line 21, in 
> > from html import xmlescape, TABLE, TR, PRE
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\h
> > tml.py", line 17, in 
> > import sanitizer
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\s
> > anitizer.py", line 21, in 
> > from xml.sax.saxutils import quoteattr
> >   File "C:\Python26\lib\xml\sax\__init__.py", line 61, in 
> > import os, sys
> > KeyboardInterrupt Because I hit ctrl+c after the 4th time web2py loaded
> > itself.
> > DEBUG:root:defining tables (migrate=False)
> > DEBUG:root:thread building own DAL object
> > DEBUG:root:defining tables (migrate=False)
> > DEBUG:root:looping...
> > Exception in thread Thread-1:
> > Traceback (most recent call last):
> >   Fil

[web2py] Re: uploading my web2py website

2011-09-05 Thread annet
Hi,

I deploy my apps on Mac OS X Leopard Server ... I guess it won't be of
much help to tell you how to set up an deployment environment on it.


Did you have a look at Denes his post on web2py hosting?

http://groups.google.com/group/web2py/browse_thread/thread/7b648be5588e84be


Also, isn't this part of the book of any help?

http://www.web2py.com/book/default/chapter/11#Shared-Hosting-with-mod_python



Kind regards,

Annet.


[web2py] Re: appadmin and db.Table definition

2011-09-05 Thread Manuele
ok everything goes fine without specifying "unique=True" option... but 
it why?

anyway the traceback didn't help in any way... could it be a sort of bug??

thankyou

Manuele

On 05/09/2011 18:31, Manuele wrote:

Hi,

if you simply cut & paste the following code in a model of a generic 
app maybe you'll get a table called layers_wms in your database 
without any problem but if you try to insert a record in it you'll get 
the traceback reported after.


Can you help me to understand why I get this traceback?

from gluon.storage import Storage
class OpenLayers(object):
basic = db.Table(db, '_basic_',
Field('name', required=True, unique=True, label=T('Name'), 
comment=T('Layer Name'))

)
WMS = Storage(dict(
options = db.Table(db, '_options_',
Field('layers', required=True, unique=True, 
label=T('workspace:name'), comment=T('Layer\'s workspace and name')),
#Field('projection', miscdb.locations, default=1, 
required=True, notnull=True,

#requires=IS_IN_DB(miscdb, 'locations.id', '%(name)s')),
Field('format', default='image/png'),
Field('transparent', 'boolean', default=True),
Field('opacity', 'decimal(4,2)', default=1.0),
Field('visibility', 'boolean', default=True,
#requires=JS_BOOLEAN(), 
widget=SQLFORM.widgets.boolean.widget

),
))
)
WMS['Layer'] = db.Table(db, '_wms_',
basic,
Field('url', label=T('Url'), comment=T(''), 
requires=IS_URL()),

WMS.options,
# {Boolean} Default is true for WMS layer
Field('isBaseLayer', 'boolean', default=False)
# {Boolean} Should the BBOX commas be encoded?
#   Field('encodeBBOX'),
# {Boolean} If true, the image format will not be 
automagicaly switched
# from image/jpeg to image/png or image/gif when using 
TRANSPARENT=TRUE.

#   Field('noMagic'),
)

db.define_table('layers_wms',
OpenLayers.WMS.Layer
)

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.

Traceback(most recent call last):
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/restricted.py",line192,inrestricted
 execccodeinenvironment
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
  
,line410,in
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/globals.py",line145,in
 self._caller=lambdaf:f()
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
  
,line127,ininsert
 ifform.accepts(request.vars,session):
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/sqlhtml.py",line1043,inaccepts
 hideerror=hideerror,
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1765,inaccepts
 status=self._traverse(status,hideerror)
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
 newstatus=c._traverse(status,hideerror)andnewstatus
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
 newstatus=c._traverse(status,hideerror)andnewstatus
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
 newstatus=c._traverse(status,hideerror)andnewstatus
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
 newstatus=c._traverse(status,hideerror)andnewstatus
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line733,in_traverse
 newstatus=self._validate()
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1538,in_validate
 (value,errors) =validator(value)
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/validators.py",line515,in__call__
 field=self.dbset.db[tablename][fieldname]
   
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/dal.py",line4325,in__getitem__
 returndict.__getitem__(self,str(key))
KeyError:'_basic_'









[web2py] Re: uploading my web2py website

2011-09-05 Thread Web2Py Freak
what is shared hosting ?? and when i finish my website do i need to
add somthing  so my website will work online am realu confused now am
reading stuff   sgi and things i dont understand  .. please help


Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Brian M
I just put together an Ubuntu VM to test in and yeah, the scheduler doesn't 
work quite right there either.  First off it appears that the DB tables 
don't get defined there either without intervention -- I changed 
migrate=False to migrate=True on line 265 and then running *python web2py.py 
-K scheduler* worked better.  At least under linux only one web2py process 
gets started.  The scheduler also spotted my task and attempted to run it 
... and failed.  But at least in Linux the scheduler actually recognizes and 
records that the task failed.  Also, hitting ctrl+c only once successfully 
kills off the scheduler unlike under Windows where you've got to do it over 
and over again.

It looks like the task fails because os.environ['WEB2PY_PATH'] is not 
defined.  I thought that adding the -f option to web2py.py was supposed to 
set this but that doesn't work either (as in *python web2py.py -K scheduler 
-f */full/path/to/web2py/).

Below is a (truncated) record of a scheduler run under linux:
---
brian@brian-Ubuntu1104:~/web2py/trunk/web2py$ python web2py.py -K scheduler
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.98.2 (2011-09-03 22:30:05)
Database drivers available: SQLite3, pymysql
starting scheduler for "scheduler"...
DEBUG:root:defining tables (migrate=True)
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:thread building own DAL object
DEBUG:root:defining tables (migrate=False)
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
DEBUG:root:recording heartbeat
DEBUG:root:freeing workers that have not sent heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
...
DEBUG:root:recording heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 1 tasks
DEBUG:root:   releasing all but one (running)
DEBUG:root:new scheduler_run record
INFO:root:new task 1 "demo1" scheduler.demo1
DEBUG:root: new task allocated: scheduler.demo1
DEBUG:root:   task starting
DEBUG:root:task started
DEBUG:root:new task report: FAILED
DEBUG:root:   traceback: Traceback (most recent call last):
  File "/home/brian/web2py/trunk/web2py/gluon/scheduler.py", line 119, in 
executor
os.chdir(os.environ['WEB2PY_PATH'])
  File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'WEB2PY_PATH'

DEBUG:root:  task completed or failed
DEBUG:root: recording task report in db (FAILED)
INFO:root:task completed (FAILED)
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
DEBUG:root:recording heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
...
DEBUG:root:recording heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
DEBUG:root:recording heartbeat
DEBUG:root:freeing workers that have not sent heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
..
DEBUG:root:recording heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
DEBUG:root:recording heartbeat
DEBUG:root:looping...
DEBUG:root: grabbing all queued tasks
DEBUG:root:  grabbed 0 tasks
DEBUG:root:sleeping...
^CINFO:root:die!
brian@brian-Ubuntu1104:~/web2py/trunk/web2py$ 



Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Brian M
I found that under linux I was able to get the scheduler to successfully run 
a task by making sure os.environ['WEB2PY-PATH'] was defined.  What I did was 
edit gluon/scheduler.py and change lines 61-62 from
if 'WEB2PY_PATH' in os.environ:
sys.path.append(os.environ['WEB2PY_PATH'])
to
if 'WEB2PY_PATH' in os.environ:
sys.path.append(os.environ['WEB2PY_PATH'])
else:
os.environ['WEB2PY_PATH'] = os.environ['PWD']

Of course that'll only work if you're launching web2py from its own folder. 
(i.e. *python web2py.py -K scheduler* will work but *python web2py/web2py.py 
-K scheduler* will not).  So a better patch than mine is definitely in 
order, but at least we know the scheduler can actually work :)

~Brian


[web2py] how to avoid shell in the admin

2011-09-05 Thread António Ramos
hello, i dont like the shell in the admin because in windows i cannot repeat
last command also the pythonwin is way more friendly...

1 - in windows how can i do the shame as the admin shell using pythonwin or
just command line python?
2 - in windows in command line python how do i execute a function in a
controller?


thank you
António


[web2py] Re: Problem with SQLFORM.grid

2011-09-05 Thread brushek
Can anybody help ? or grid and smartgrid shouldn't be used with custom
fields ?

Regards
brushek

On 5 Wrz, 16:22, brushek  wrote:
> On 5 Wrz, 15:55, Johann Spies  wrote:
>
> > Hallo Brushek,
>
> > I am also trying out SQLFORM.grid/smartgrid and learn as I go.
>
> > @auth.requires_login()> def dodajserwer():
> > >    response.flash = T('Serwery')
> > >    form=SQLFORM.grid(db.serwery)
>
> > Apparently the usage is either SQLFORM.smartgrid(table) or
> > SQLFORM.grid(query)
>
> > Try   'form = SQLFORM.smartgrid(db.serwery)'
>
> I tried this one before posting...
>
>
>
> > or    'form = SQLFRORM.grid(db(db.serwery.id > 0))'
>
> ... and this one doesn't change the situtaion, the error is the same.
>
> regards
> Brushek


Re: [web2py] upload/post of semi-large files

2011-09-05 Thread Roberto De Ioris

> Hi,
>
> My production environment is ubuntu, postgresql, uwsgi and nginx.
>
> The issue I'm having is when posting a form with a semi-large file (~2
> mb),
> where it keeps 'resetting' the % uploaded every 30 seconds up to 2 to 3
> times, and finally failing (with no specific error that I could see).
>
> I thought this could be fixed by setting a big number for uwsgi's harakiri
> option (which defaults to 60 secs), but that doesn't seem to help.
>
> What should I do to fix this and allow posting forms with semi-large files
> that take about a minute or so to upload?.
>
> Thanks!,
>
>Carlos
>
>

Check your nginx error log, you are probably receiving a 413 error (entity
too large). By default the limit is 1 mb

http://wiki.nginx.org/HttpCoreModule#client_max_body_size

-- 
Roberto De Ioris
http://unbit.it


Re: [web2py] upload/post of semi-large files

2011-09-05 Thread Carlos
Hi Roberto,

I was just about to post the solution I found: precisely what you mention 
:-)

   client_max_body_size 10M;

Thanks!,

   Carlos



[web2py] appadmin and db.Table definition

2011-09-05 Thread pbreit
Is there some reason your table definitions depart so significantly from what 
is shown in the docs?


[web2py] button calling a action

2011-09-05 Thread Fabiano Faver
I'm tryng to put a button thaat calls a action which in the end will 
redirect to another page. but its like the function is not known.

I've tryed in view:

and:


in controller:
   def atualizar():
#add some code here later
redirect(URL('index'))

butthis is what I got:
Uncaught ReferenceError: atualizar is not defined

I'm still learning web2py and web-programming, so what i'm not seeing here?


Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Brian M
OK, I've got the scheduler reliably (I think) working now under Linux - I 
just changed my patch mentioned above a bit to make it so that WEB2PY_PATH 
would work even if you didn't launch from the same folder as web2py is in.

At line 61, replace:

if 'WEB2PY_PATH' in os.environ:
sys.path.append(os.environ['WEB2PY_PATH'])


with:

if 'WEB2PY_PATH' in os.environ:
sys.path.append(os.environ['WEB2PY_PATH'])
else:
os.environ['WEB2PY_PATH'] = os.getcwd()

Unfortunately, this doesn't seem to do it for Windows, will have to 
experiment a bit more there.

~Brian


Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Brian M
OK, I've managed get the scheduler to partially work under windows.  I had 
to add if __name__ == '__main__': to web2py.py right before actually 
starting web2py (line 19). This appears to have solved the problem of web2py 
starting over and over again, now when I run python web2py.py -K 
schedulerweb2py only starts up once. :)  (likely due 
to http://docs.python.org/library/multiprocessing.html#windows)

But, now that the scheduler is running under windows, it appears that none 
of the debug output gets send to the windows console :(  However, it does 
look like the scheduler is actually doing its thing and checking for tasks 
and actually running them :)  I've been able to schedule the demo1 function 
and get it to run ... as long as I only assign it args, for whatever reason 
if I give it some vars too then it fails.  But hey, this is a lot farther 
that I've managed to get with the scheduler under Windows that previously!

*My scheduled task*
def demo1(*args,**vars):
print 'you passed args=%s and vars=%s' % (args, vars)
return 'done!'

*When trying to run with vars = {"foo":"bar"}, which worked fine under Linux
*
Traceback (most recent call last):
  File "C:\Users\Brian\Documents\development\web2py\google hg 
repo\trunk\gluon\scheduler.py", line 133, in executor
result = dumps(_function(*loads(task.args),**loads(task.vars)))
TypeError: demo1() keywords must be strings

Other findings, if you edit a scheduler_task, it appears to lead to the 
scheduler crashing:

Traceback (most recent call last):
  File "C:\Users\Brian\Documents\development\web2py\google hg 
repo\trunk\gluon\s
hell.py", line 214, in run
exec(python_code, _env)
  File "", line 1, in 
  File "C:\Users\Brian\Documents\development\web2py\google hg 
repo\trunk\gluon\s
cheduler.py", line 334, in loop
MetaScheduler.loop(self)
  File "C:\Users\Brian\Documents\development\web2py\google hg 
repo\trunk\gluon\s
cheduler.py", line 228, in loop
task = self.pop_task()
  File "C:\Users\Brian\Documents\development\web2py\google hg 
repo\trunk\gluon\s
cheduler.py", line 353, in pop_task
logging.debug('  grabbed %s tasks' % number_grabbed)
UnboundLocalError: local variable 'number_grabbed' referenced before 
assignment



Massimo, hopefully all this will help you get the new Scheduler sorted out.
~Brian


[web2py] request.args inconsistent behaviour and ignoring URI valid characters

2011-09-05 Thread Noel Villamor
I am trying to pass a '.' and a '*' as parameters to a controller
function.

controller: test.py
def t():
arr = request.args
return 'alert("%s");' % repr(arr)

url: /myapp/test/t/1/2/3
alert: ['1', '2', '3']

With one dot in between 1 and 3
url: /myapp/test/t/1/./3
alert: ['1', '3']

With two dots in between 1 and 3
url: /myapp/test/t/1/../3
alert: ['3']

And why am I getting a 400 Bad Request on this one (note the * between
1 and 3)?
url: /myapp/test/t/1/*/3

According to the post below, '.' and '*' appears to be in the set of
URI valid characters.

http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid





[web2py] Re: button calling a action

2011-09-05 Thread Noel Villamor

I found this for you:
http://www.plus2net.com/html_tutorial/button-linking.php

Try this:


Noel


On Sep 6, 7:07 am, Fabiano Faver  wrote:
> I'm tryng to put a button thaat calls a action which in the end will
> redirect to another page. but its like the function is not known.
>
> I've tryed in view:
>      onclick="{{=URL(r=request,f='atualizar')}}"/>
> and:
>      onclick="document.location={{=URL(r=request,f='atualizar')}}"/>
>
> in controller:
>    def atualizar():
>         #add some code here later
>         redirect(URL('index'))
>
> butthis is what I got:
> Uncaught ReferenceError: atualizar is not defined
>
> I'm still learning web2py and web-programming, so what i'm not seeing here?


Re: [web2py] Re: testing scheduler in windows

2011-09-05 Thread Brian M
I think I've got the scheduler sorted out for windows (other than a lack of 
debug messages from the workers, suspect it's due to a lack of os.fork()). 
 My TypeError: demo1() keywords must be strings was fixed 
with 
http://stackoverflow.com/questions/956867/how-to-get-string-objects-instead-unicode-ones-from-json-in-python
 

I'll be sending Massimo a patch.

~Brian


[web2py] button calling a action

2011-09-05 Thread pbreit
Shouldn't you just be using a normal web2py form?


[web2py] request.args inconsistent behaviour and ignoring URI valid characters

2011-09-05 Thread pbreit
It's hard to say exactly what is allowed but according to my reading of 
http://tools.ietf.org/html/rfc3986 * is definitely not allowed and . and .. may 
not be allowed in the path (since they have meaning in a file system).


[web2py] Re: request.args inconsistent behaviour and ignoring URI valid characters

2011-09-05 Thread Noel Villamor

I see. So that explains the backtracking when two dots are in the URL
(similar behaviour to cd .. at the command line).


[web2py] Re: button calling a action

2011-09-05 Thread Anthony
I think that's a Javascript error, not a web2py error. You probably need to 
put the URL in quotes, so:

onclick="document.location='{{=URL(r=request,f='atualizar')}}'"


Anthony


On Monday, September 5, 2011 3:07:11 PM UTC-4, Fabiano Faver wrote:
>
> I'm tryng to put a button thaat calls a action which in the end will 
> redirect to another page. but its like the function is not known.
>
> I've tryed in view:
>  onclick="{{=URL(r=request,f='atualizar')}}"/>
> and:
>  onclick="document.location={{=URL(r=request,f='atualizar')}}"/>
>
> in controller:
>def atualizar():
> #add some code here later
> redirect(URL('index'))
>
> butthis is what I got:
> Uncaught ReferenceError: atualizar is not defined
>
> I'm still learning web2py and web-programming, so what i'm not seeing here?
>


[web2py] Re: how to avoid shell in the admin

2011-09-05 Thread Anthony
On Monday, September 5, 2011 12:18:28 PM UTC-4, Ramos wrote:
>
> hello, i dont like the shell in the admin because in windows i cannot 
> repeat last command also the pythonwin is way more friendly...
>
> 1 - in windows how can i do the shame as the admin shell using pythonwin or 
> just command line python?
>

I'm not sure you can use PythonWin, but open a command window (cmd.exe), 
change directory to your \web2py folder, and enter:

python web2py -S your_app -N -M

You'll get the web2py environment (including the models for your app) in a 
Python shell. Note, -N tells it to turn off cron, and -M tells it to run the 
models from your app. 
See http://web2py.com/book/default/chapter/04#Command-Line-Options.

 

> 2 - in windows in command line python how do i execute a function in a 
> controller?
>

When you run the web2py shell (as described above), you can tell it to run a 
particular controller and function:

python web2py -S your_app/your_controller/your_function -N -M

Note, you could also just do your_app/your_controller, and once you're in 
the shell, you can run any function within the controller.

Here's a simple batch file you can adapt -- when you click it, it will 
prompt you for an app (which can include app/controller/function), and it 
will change to the web2py folder and start the shell for you:

@echo off
set /P app="Enter web2py app/controller/function to run in the shell 
(controller/function optional): "
cd c:\path\to\web2py
python web2py.py -S %app% -M -N


If you want a nicer command window in Windows, in any command window, click 
the icon in the upper left, and select Defaults from the menu. There you can 
change the window size and position, colors, etc., and the changes will 
affect all command windows.

Anthony



Re: [web2py] Compile from command line

2011-09-05 Thread Anthony
On Monday, September 5, 2011 5:15:51 AM UTC-4, Thomas Bellembois wrote:
>
>
> Sorry for this basic question about compiled apps: do we have to run 
> web2py in a different way with a compiled app ? or does web2py detect 
> that there is a compiled version ?


No, just run as usual -- web2py will figure it out.

Side note: One thing that doesn't work with compiling is an {{include var}} 
statement in a view, where 'var' is a variable. When views are compiled, all 
the includes are handled at compile time, and because the value of 'var' 
isn't known at compile time, the view cannot be compiled properly.

Anthony