[web2py] Beginner question about DAL

2012-08-10 Thread Spez
Hi All,
I am very new to web2py and in general to web framework. 
I am trying to read a db content from a remote machine, db is mysql, web2py 
version 1.99.7 stable.
I have created a new simple application and added a model db1.py with:

legacy_db = DAL('mysql://username:password@my_server:3306/timesheet', 
migrate_enabled=False, pool_size=20)
legacy_db.define_table('timesheet_client', 
Field('client_id', 'integer'),   
Field('organisation', 'string'), 
Field('description', 'string'),  
Field('address1', 'string'), 
Field('city', 'string'), 
Field('state', 'string'),
Field('country', 'string'),  
Field('postal_code', 'string'),  
Field('contact_first_name', 'string'),   
Field('contact_last_name', 'string'),
Field('username', 'string'), 
Field('contact_email', 'string'),
Field('phone_number', 'string'), 
Field('fax_number', 'string'),   
Field('gsm_number', 'string'),   
Field('http_url', 'string'), 
Field('address2', 'string'), 
migrate=False)

then I added to controller default.py:
def index():
  return locals()
  
def client():
  clients = 
legacy_db(legacy_db.timesheet_client).select(orderby=legacy_db.timesheet_client.client_id)
  return locals()

When I look at page ../my_application/default/client I receive an error:
 (1054, u"Unknown column 
'timesheet_client.id' in 'field list'")

but I do not have any timesheet_client.id filed in my legacy_db

Any suggestions?

-- 





[web2py] Re: Beginner question about DAL

2012-08-10 Thread Anthony
By default, db.define_table() automatically includes an auto-increment 
integer field called "id" to be used as the primary key. If your legacy 
table includes an auto-increment integer field with a different name, then 
you should specify that field as type "id", and the DAL will use that as 
the id field:

legacy_db.define_table('timesheet_client', 
Field('client_id', 'id'),   

If your legacy table does not include such a field, you need to specify an 
alternative primary key (which entails some limitations on DAL usage with 
the table). See 
http://web2py.com/books/default/chapter/29/6#Legacy-databases-and-keyed-tables 
for 
more details.

Anthony

On Friday, August 10, 2012 4:08:14 AM UTC-4, Spez wrote:
>
> Hi All,
> I am very new to web2py and in general to web framework. 
> I am trying to read a db content from a remote machine, db is mysql, 
> web2py version 1.99.7 stable.
> I have created a new simple application and added a model db1.py with:
>
> legacy_db = DAL('mysql://username:password@my_server:3306/timesheet', 
> migrate_enabled=False, pool_size=20)
> legacy_db.define_table('timesheet_client', 
> Field('client_id', 'integer'),   
> Field('organisation', 'string'), 
> Field('description', 'string'),  
> Field('address1', 'string'), 
> Field('city', 'string'), 
> Field('state', 'string'),
> Field('country', 'string'),  
> Field('postal_code', 'string'),  
> Field('contact_first_name', 'string'),   
> Field('contact_last_name', 'string'),
> Field('username', 'string'), 
> Field('contact_email', 'string'),
> Field('phone_number', 'string'), 
> Field('fax_number', 'string'),   
> Field('gsm_number', 'string'),   
> Field('http_url', 'string'), 
> Field('address2', 'string'), 
> migrate=False)
>
> then I added to controller default.py:
> def index():
>   return locals()
>   
> def client():
>   clients = 
> legacy_db(legacy_db.timesheet_client).select(orderby=legacy_db.timesheet_client.client_id)
>   return locals()
>
> When I look at page ../my_application/default/client I receive an error:
>  (1054, u"Unknown column '
> timesheet_client.id' in 'field list'")
>
> but I do not have any timesheet_client.id filed in my legacy_db
>
> Any suggestions?
>
>

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Anthony

>
> session[request.args(0)].id=request.args(0)
>

session[request.args(0)] doesn't exist yet, so you can't refer to an 
attribute of it (i.e., "id"). I assume you'd like it to be a Storage object:

from gluon.storage import Storage
session[request.args(0)] = Storage(id=request.args(0))
# now it's a Storage object, so you can start adding new keys
session[request.args(0)].otherkey = "other value"

Also, to clean up your code a bit:

from gluon.storage import Storage
session[request.args(0)] = Storage()
id = session[request.args(0)].id = request.args(0)

Then everywhere you currently refer to session[request.args(0)].id, you can 
simply use id (even without the above, you could just use 
request.args(0)itself, since it is equivalent to 
session[requests.args(0)].id).

Finally, do you even need the "id" key, given that it is the same as the 
name of its parent object? Couldn't you just do:

from gluon.storage import Storage
id = request.args(0)
session[id] = Storage()
session[id].somekey = 'some value'

Anthony

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Annet
Hi Anthony,

Thanks for your reply, I got the idea of the solution now. 
 

> Finally, do you even need the "id" key, given that it is the same as the 
> name of its parent object? Couldn't you just do:
>
> from gluon.storage import Storage
> id = request.args(0)
> session[id] = Storage()
> session[id].somekey = 'some value'
>

I think I can I'll give it a try.

In the book I read:

>  If you are storing sessions on filesystems and you have lots of them, 
the file system access may become a bottle-neck

I changed the expire_sessions.py file to clean up expired sessions, will it 
clean up the sessions created the way above as well?

EXPIRATION_MINUTES=60
DIGITS=('0','1','2','3','4','5','6','7','8','9')
import os, time, stat, logging
for app in ['admin','init']: # add your apps
path=os.path.join(request.folder,'sessions')
if not os.path.exists(path):
os.mkdir(path)
now=time.time()
for filename in os.listdir(path):
fullpath=os.path.join(path,filename)
try:
if os.path.isfile(fullpath):
t=os.stat(fullpath)[stat.ST_MTIME]
if now-t>EXPIRATION_MINUTES*60 and 
filename.startswith(DIGITS):
try:
os.unlink(fullpath)
except Exception,e:
logging.warn('failure to unlink %s: %s' % 
(fullpath,e))
   except Exception, e:
   logging.warn('failure to stat %s: %s' % (fullpath,e))

Does it make a difference whether you store session in the sessions folder 
or in a database?

Are there other ways to clean up these sessions?


Kind regards,

Annet.

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Annet
When request.args(0) is 628
 

> from gluon.storage import Storage
> session[request.args(0)] = Storage(id=request.args(0))
> # now it's a Storage object, so you can start adding new keys
> session[request.args(0)].otherkey = "other value"
>

Is this equivalent to session6 = {'id':6} or 6={'id':6}

I am asking this because the following:

from gluon.storage import Storage
> session[request.args(0)] = Storage()
> id = session[request.args(0)].id = request.args(0)
>
> Then everywhere you currently refer to session[request.args(0)].id, you 
> can simply use id (even without the above, you could just use 
> request.args(0) itself, since it is equivalent to 
> session[requests.args(0)].id).
>

 isn't completely clear to me, when I have created Storage object for 
node with id 6, node with id 28 and node with id 34 and have set every 
objects key to the corresponding values, then what you're saying is that 
6.menu renders node 6's menu and 28.menu renders node 28's menu?


Finally, do you even need the "id" key, given that it is the same as the 
> name of its parent object? Couldn't you just do:
>
> from gluon.storage import Storage
> id = request.args(0)
> session[id] = Storage()
> session[id].somekey = 'some value'
>

If I understood you correctly, I think I can.


Kind regards,

Annet
 
 

-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-10 Thread Michele Comitini
I agree the new behavior makes much more sense.  Maybe there should be
a backward compatibility flag in Auth?

mic


2012/8/8 Massimo Di Pierro :
> more issues have been addressed. In order to fix an issue I had to introduce
> a slight change of behavior and I am not sure what is the best way to handle
> it.
>
> If you login using a third party service (for example janrain using
> facebook) and the service sends info about you, if web2py has corresponding
> fields in auth_user, it stores them. If you edit your profile, logout,
> change your facebook profile, login again using janrain, should web2py keep
> the current local profile or update it? The bug report suggested that web2oy
> should always give preference to the local profile.
>
> I changed web2py accordingly. In practice this change will probably not
> affect anybody because none of the services sends any information stored by
> auth_user.
>
> Yet, please check it.
>
> Massimo
>
>
>
>
> On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
>>
>> Web2py 2.0 is almost done.
>> Please try the nightly build.
>> Let us know if it breaks anything.
>>
>> massimo
>
> --
>
>
>

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Anthony


On Friday, August 10, 2012 5:38:27 AM UTC-4, Annet wrote:
>
> When request.args(0) is 628
>  
>
>> from gluon.storage import Storage
>> session[request.args(0)] = Storage(id=request.args(0))
>> # now it's a Storage object, so you can start adding new keys
>> session[request.args(0)].otherkey = "other value"
>>
>
> Is this equivalent to session6 = {'id':6} or 6={'id':6}
>

It's equivalent to session[6].id = 6 or session[6]['id'] = 6. You can't do 
session.6 because Python identifiers can't start with a digit (if the node 
ID started with a letter or underscore, then you could use that notation as 
well).
 

> I am asking this because the following:
>
> from gluon.storage import Storage
>> session[request.args(0)] = Storage()
>> id = session[request.args(0)].id = request.args(0)
>>
>> Then everywhere you currently refer to session[request.args(0)].id, you 
>> can simply use id (even without the above, you could just use 
>> request.args(0) itself, since it is equivalent to 
>> session[requests.args(0)].id).
>>
>
>  isn't completely clear to me, when I have created Storage object for 
> node with id 6, node with id 28 and node with id 34 and have set every 
> objects key to the corresponding values, then what you're saying is that 
> 6.menu renders node 6's menu and 28.menu renders node 28's menu?
>

It would be session[6].menu, session[28].menu, etc.

Anthony

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Anthony

>
> I changed the expire_sessions.py file to clean up expired sessions, will 
> it clean up the sessions created the way above as well?
>

I don't see why not. Note, the above doesn't create the session (web2py 
does that) -- it simply adds variables to the session. From the framework 
perspective, the session works as usual.
 

> Does it make a difference whether you store session in the sessions folder 
> or in a database?
>

In terms of clean-up, yes -- the above code is for cleaning up file-based 
sessions only.

Anthony

-- 





[web2py] Re: Distinguish between session vars that belong to a node.

2012-08-10 Thread Annet
Hi Anthony.

Thanks for answering my questions, everything is clear now.

Best regards,

Annet

-- 





[web2py] Re: SQLFORM and Nyromodal

2012-08-10 Thread Christian Espinoza
Well, I fix it, pointing (action) to my controller from the form:

form = SQLFORM(db.table, request.vars.id[0], _class='formulario', 
_id='form_std', keepopts=['sede'], _action=URL())

Thanks 
Christian.

El jueves, 9 de agosto de 2012 17:35:23 UTC-4, Christian Espinoza escribió:
>
> Hi, I´m have working a custom SQLFORM in update mode, into a modal popup, 
> when I try to submit changes
> the popup disappear obviously, but it isn't make any changes.
> But if I try the code out from the modal, it's make the changes without 
> problems...
>
> Any Idea?
>
> Thanks in advance.
> Christian.
>

-- 





Re: [web2py] Problems with restful + PUT

2012-08-10 Thread Tito Garrido
Same error using locals()

:(

On Thu, Aug 9, 2012 at 5:23 PM, Bruno Rocha  wrote:

> try to replace  return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
> with return locals()
>
> I dont know, but maybe its the problem
>
> On Wed, Aug 8, 2012 at 10:49 PM, Tito Garrido wrote:
>
>> Hi folks,
>>
>> *I have a simple table:*
>>
>> *db.define_table('estadio',
>> Field('cod_estadio','id'),
>> Field('nome_estadio'),
>> Field('cidade'),migrate=False) *
>>
>> *A simple entry:*
>>
>> *estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A Definir
>> **A Definir*
>> and using Bruno's example in web2pyslice:
>>
>>
>>1. @request.restful()
>>
>>2. def api():
>>3. response.view = 'generic.'+request.extension
>>4. def GET(*args,**vars):
>>5. patterns = 'auto'
>>6. parser = db.parse_as_rest(patterns,args,vars)
>>
>>
>>
>>7. if parser.status == 200:
>>8. return dict(content=parser.response)
>>9. else:
>>10. raise HTTP(parser.status,parser.error)
>>
>>
>>
>>11. def POST(table_name,**vars):
>>12. return db[table_name].validate_and_insert(**vars)
>>13. def PUT(table_name,record_id,**vars):
>>14. return db(db[table_name]._id==record_id).update(**vars)
>>
>>
>>
>>15. def DELETE(table_name,record_id):
>>16. return db(db[table_name]._id==record_id).delete()
>>
>>
>>
>>17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>>
>>
>>
>>
>>
>> *but when I try to:*
>> *
>> curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste"
>> http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*
>>
>> *it returns:*
>>
>> HTTP/1.1 400 BAD REQUEST
>> Server: nginx
>> Date: Thu, 09 Aug 2012 01:41:44 GMT
>> Content-Type: text/html; charset=UTF-8
>> Connection: keep-alive
>> Set-Cookie:
>> session_id_ws=xx-65e0b712-7d93-4b21-a553-d06ce06af2a2; Path=/
>> Content-Length: 540
>>
>> invalid arguments
>>
>> *What am I missing here?
>>
>> Thanks in advance!*
>>
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>



-- 

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

-- 





Re: [web2py] web2py 2.0 almost done

2012-08-10 Thread Phyo Arkar
i haven't test that , i will test and report.
I have been using uwsgi + web2py , and large uploads / downloads all goes
fine. I haven't use Rocket for so long.

On Thu, Aug 9, 2012 at 7:54 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The corruption, as we could determine has to do with two issues:
>
> - SOCKET_TIMEOUT = 1 was too slow, we increased it to 10.
> - self.conn.sendall was timing out but socket.timeout was not being
> caught. Now it is.
>
> Since this fix we had no more reports of data corruption.
> Are there other problems that need fixing with rocket?
>
> Massimo
>
>
>
> On Thursday, 9 August 2012 08:17:57 UTC-5, Marin Pranjić wrote:
>
>> What about issues with rocket, is that fixed?
>>
>> (if I remember correctly it was about corruption of big-sized downloads)
>>
>> On Tue, Aug 7, 2012 at 6:33 AM, Massimo Di Pierro 
>> wrote:
>>
>>> Web2py 2.0 is almost done.
>>> Please try the nightly build.
>>> Let us know if it breaks anything.
>>>
>>> massimo
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





[web2py] Re: Initialize one-time configuration data in DB

2012-08-10 Thread Massimo Di Pierro
When you do

 python web2py.py -S yourapp -M -N -R yourscript.py

-M will import your models and run yourscript.py as if it were a controller.
yourscript.py must read the data from where it is (a file?), loop over it, 
and do db.table.insert(...)
For example

for name in ['a','b','c']:
db.person.insert(name=name)
db.commit()



On Thursday, 9 August 2012 22:47:51 UTC-5, mrtn wrote:
>
>
> If they must be in the database, use a script to import them and run it 
>> once 
>> python web2py.py -S yourapp -M -N -R yourscript.py
>
>
> Yes, the data must be in the db. By 'import them' in the script, do you 
> mean import the database abstraction layer stuff by web2py, and use it to 
> insert the data? Thanks!
>

-- 





Re: [web2py] Problems with restful + PUT

2012-08-10 Thread Massimo Di Pierro
Which web2py version?

On Friday, 10 August 2012 08:39:40 UTC-5, Tito Garrido wrote:
>
> Same error using locals()
>
> :(
>
> On Thu, Aug 9, 2012 at 5:23 PM, Bruno Rocha 
> > wrote:
>
>> try to replace  return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE) 
>> with return locals()
>>
>> I dont know, but maybe its the problem
>>
>> On Wed, Aug 8, 2012 at 10:49 PM, Tito Garrido 
>> 
>> > wrote:
>>
>>> Hi folks,
>>>
>>> *I have a simple table:*
>>>
>>> *db.define_table('estadio',
>>> Field('cod_estadio','id'),
>>> Field('nome_estadio'),
>>> Field('cidade'),migrate=False) *
>>>
>>> *A simple entry:*
>>>
>>> *estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A 
>>> Definir**A Definir*
>>> and using Bruno's example in web2pyslice:
>>>
>>>
>>>1. @request.restful()
>>>
>>>
>>>2. def api():
>>>3. response.view = 'generic.'+request.extension
>>>4. def GET(*args,**vars):
>>>5. patterns = 'auto'
>>>6. parser = db.parse_as_rest(patterns,args,vars)
>>>
>>>
>>>
>>>
>>>7. if parser.status == 200:
>>>8. return dict(content=parser.response)
>>>9. else:
>>>10. raise HTTP(parser.status,parser.error)
>>>
>>>
>>>
>>>
>>>11. def POST(table_name,**vars):
>>>12. return db[table_name].validate_and_insert(**vars)
>>>13. def PUT(table_name,record_id,**vars):
>>>14. return db(db[table_name]._id==record_id).update(**vars)
>>>
>>>
>>>
>>>
>>>15. def DELETE(table_name,record_id):
>>>16. return db(db[table_name]._id==record_id).delete()
>>>
>>>
>>>
>>>
>>>17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>>>
>>>
>>>
>>>
>>>
>>>
>>> *but when I try to:*
>>> *
>>> curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste" 
>>> http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*
>>>
>>> *it returns:*
>>>
>>> HTTP/1.1 400 BAD REQUEST
>>> Server: nginx
>>> Date: Thu, 09 Aug 2012 01:41:44 GMT
>>> Content-Type: text/html; charset=UTF-8
>>> Connection: keep-alive
>>> Set-Cookie: 
>>> session_id_ws=xx-65e0b712-7d93-4b21-a553-d06ce06af2a2; Path=/
>>> Content-Length: 540
>>>
>>> invalid arguments
>>>
>>> *What am I missing here?
>>>
>>> Thanks in advance!*
>>>
>>>
>>> -- 
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___
>>>
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





[web2py] Killer Web Development #7

2012-08-10 Thread Massimo Di Pierro
http://killer-web-development.com/section/7/0

Thanks Marco! Really nice.

-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-10 Thread lyn2py
Thank you AngeloC!

On Friday, August 10, 2012 1:50:03 PM UTC+8, AngeloC wrote:
>
> Hi Massimo,
>
> I'm writing it right now to fix ie issues! Please be patient until fixed!
>
> 2012/8/9 Massimo Di Pierro >
>
>> This may be ok but where do I get bootswatch_ie.css from?
>>
>>
>> On Thursday, 9 August 2012 11:43:28 UTC-5, AngeloC wrote:
>>
>>> Hi Massimo,
>>>
>>> I think I cannot complete the bootstrap/web2py css merging in time for 
>>> 2.0, it's really a lot of work and I'm a bit busy these days.
>>>
>>> Btw, i'm fixing the bug I introduced with issue 896 and I want to share 
>>> a thought with you.
>>>
>>> Actually, there is no way to maintain a mobile first approach and make 
>>> it working on IE other than add something like this to the scaffolding:
>>>
>>> 
>>> 
>>>
>>> This will make speedier the whole css on not IE browsers because we 
>>> remove IE specific rules (smaller css), but has the downside to require an 
>>> extra http get on IE.
>>>
>>> What do you think?
>>>
>>>
>>> 2012/8/9 Alec Taylor 
>>>
 It would be good to have OAuth working for web2py 2

 Facebook and LinkedIn still have some issues

 LinkedIn: https://groups.google.com/**forum/#!topic/web2py/**
 SbnQEnXEcOg

 Facebook: (will add bug report once I've gotten LinkedIn login to work)

 On Thu, Aug 9, 2012 at 11:25 PM, Massimo Di Pierro
  wrote:
 > Can you help us fix the CSS?
 >
 >
 > On Thursday, 9 August 2012 00:29:58 UTC-5, Andrew wrote:
 >>
 >> Just a note on IE7 navbar behaviour:
 >>
 >> The Menu has taken a turn for the worse:
 >> Initially the Welcome App Sub Menus dissapeared in :  "welcome css 
 pathc,
 >> issue 896, thanks Angelo"
 >> They then returned in "fixed issue qith clicking on toplevel menus" 
 except
 >> all of the submenus are displayed when the menu first appears and 
 they are
 >> all on top of each other.
 >>
 >> The login options are still blue, and the space between the navbar 
 and
 >> "Welcome" isn't there.
 >> See screen shot.
 >>
 >>
 >> On Thursday, August 9, 2012 9:17:17 AM UTC+12, Massimo Di Pierro 
 wrote:
 >>>
 >>> more issues have been addressed. In order to fix an issue I had to
 >>> introduce a slight change of behavior and I am not sure what is the 
 best way
 >>> to handle it.
 >>>
 >>> If you login using a third party service (for example janrain using
 >>> facebook) and the service sends info about you, if web2py has 
 corresponding
 >>> fields in auth_user, it stores them. If you edit your profile, 
 logout,
 >>> change your facebook profile, login again using janrain, should 
 web2py keep
 >>> the current local profile or update it? The bug report suggested 
 that web2oy
 >>> should always give preference to the local profile.
 >>>
 >>> I changed web2py accordingly. In practice this change will probably 
 not
 >>> affect anybody because none of the services sends any information 
 stored by
 >>> auth_user.
 >>>
 >>> Yet, please check it.
 >>>
 >>> Massimo
 >>>
 >>>
 >>>
 >>> On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
 
  Web2py 2.0 is almost done.
  Please try the nightly build.
  Let us know if it breaks anything.
 
  massimo
 >
 > --
 >
 >
 >

 --




>>>
>>>
>>> -- 
>>> Profile: 
>>> http://it.linkedin.com/in/**compagnucciangelo
>>>  
>>  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
> Profile: http://it.linkedin.com/in/compagnucciangelo
>  

-- 





[web2py] Re: Initialize one-time configuration data in DB

2012-08-10 Thread lyn2py
May I know if it can be done using Modules (constants.py) instead, and what 
would be the difference (performance / best practice etc) ?

Thanks Massimo. Learning along the way.

On Friday, August 10, 2012 9:57:59 PM UTC+8, Massimo Di Pierro wrote:
>
> When you do
>
>  python web2py.py -S yourapp -M -N -R yourscript.py
>
> -M will import your models and run yourscript.py as if it were a 
> controller.
> yourscript.py must read the data from where it is (a file?), loop over it, 
> and do db.table.insert(...)
> For example
>
> for name in ['a','b','c']:
> db.person.insert(name=name)
> db.commit()
>
>
>
> On Thursday, 9 August 2012 22:47:51 UTC-5, mrtn wrote:
>>
>>
>> If they must be in the database, use a script to import them and run it 
>>> once 
>>> python web2py.py -S yourapp -M -N -R yourscript.py
>>
>>
>> Yes, the data must be in the db. By 'import them' in the script, do you 
>> mean import the database abstraction layer stuff by web2py, and use it to 
>> insert the data? Thanks!
>>
>

-- 





Re: [web2py] Killer Web Development #7

2012-08-10 Thread Martín Mulone
+1

2012/8/10 Massimo Di Pierro 

> http://killer-web-development.com/section/7/0
>
> Thanks Marco! Really nice.
>
> --
>
>
>
>



-- 
 http://www.tecnodoc.com.ar

-- 





[web2py] Init Script in Web2Py

2012-08-10 Thread tommasot
I have a newbie question.

I need to create some record in db on application startup,like for example 
default user and other things..



Where is the right script/place to implement it



-- 





[web2py] Not loading static files when accessing default view in controller

2012-08-10 Thread Pepe C
I have a site with a URL like this: www.mydomain/init/foldername/viewname

When I type the URL like this *www.mydomain/init/foldername* I don't get 
the static files loaded. However, when I type *www.mydomain/init/foldername/ 
*(with a backlash at the very end) the static files are loaded OK. What can 
be the issue?

I tried to add this in my default.py:

def foldername():
redirect(URL(request.application,'foldername','index'))

but no luck...

-- 





[web2py] Triggering LOAD

2012-08-10 Thread Rob Goldsmith
Hi
Is it possible to trigger the LOAD component when a user clicks on 
something, or can it only be used when a page is first loaded?
I have been using the ajax function to do this but would prefer the extra 
flexibility of LOAD if it is possible.

thanks
Rob.

-- 





[web2py] RFC: web2py Google Code issues; defect vs. enhancement. Audience developers and users

2012-08-10 Thread Cliff Kachinske
Here is a quote from an earlier thread: 

*Looks like a large number of the issues are actually enhancements, but 
they're all labeled as defects*


(Here is a link to the full thread:  
https://groups.google.com/forum/?fromgroups#!topicsearchin/web2py/google$20code$20issues/web2py/OUoiAF6ERYs%5B1-25%5D
)

This is a problem because it reflects badly on code quality and because it 
may misdirect efforts.  In a world where defects take priority over 
enhancements, you want an accurate list of defects and a crisp definition 
of a defect.  Also it is not a good use of time to be reviewing issue 
reports that should have been labeled correctly in the first place.

So I'm posting this RFC to establish a consensus on defects vs. 
enhancements.  The purpose is to create a shared point of view, not to 
criticize or complain.

The first proposal is a reference to common sense.  Code crashes, hangs, 
and the like are defects when caused by the Web2py code.  Same for slow 
responses.  Also true for view issues like overlapping fields.  On the 
other hand, problems like these caused by user code are not Web2py defects. 
 

The second proposal is a reference to the manual.  An issue represents a 
defect only if the code returns results that do not conform to the manual. 
 Requests for changes in behavior where the code does what the manual says 
are enhancements.

After the manual come posts in this Google group, such as Massimo's initial 
announce of grid and smartgrid.  Though the initial announcement was more 
of an invitation to try out the new features, the thread quickly expanded 
into a discussion of what the new features would and would not do.

Thus the third proposal is to use this Google group as a criterion to 
distinguish between correct and incorrect code behavior.  Because to 
commitment to not break backward compatibility, the manual takes precedence 
over comments in this group unless the manual is incorrect.

Also it would be helpful to tag new feature announcements with something 
like "experimental feature."



-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-10 Thread Angelo Compagnucci
Hi Massimo,

I fixed compatibility with IE and reverted to a non mobile first approach.
I reverted because bootstrap is not mobile first (so we add too little) and
 for the sake of compatibility with IE.

Patch is attached to issue
http://code.google.com/p/web2py/issues/detail?id=896 which I cannot reopen.

Hope this helps!

Angelo

2012/8/10 Angelo Compagnucci 

> Hi Massimo,
>
> I'm writing it right now to fix ie issues! Please be patient until fixed!
>
>
> 2012/8/9 Massimo Di Pierro 
>
>> This may be ok but where do I get bootswatch_ie.css from?
>>
>>
>> On Thursday, 9 August 2012 11:43:28 UTC-5, AngeloC wrote:
>>
>>> Hi Massimo,
>>>
>>> I think I cannot complete the bootstrap/web2py css merging in time for
>>> 2.0, it's really a lot of work and I'm a bit busy these days.
>>>
>>> Btw, i'm fixing the bug I introduced with issue 896 and I want to share
>>> a thought with you.
>>>
>>> Actually, there is no way to maintain a mobile first approach and make
>>> it working on IE other than add something like this to the scaffolding:
>>>
>>> 
>>> 
>>>
>>> This will make speedier the whole css on not IE browsers because we
>>> remove IE specific rules (smaller css), but has the downside to require an
>>> extra http get on IE.
>>>
>>> What do you think?
>>>
>>>
>>> 2012/8/9 Alec Taylor 
>>>
 It would be good to have OAuth working for web2py 2

 Facebook and LinkedIn still have some issues

 LinkedIn: https://groups.google.com/**forum/#!topic/web2py/**
 SbnQEnXEcOg

 Facebook: (will add bug report once I've gotten LinkedIn login to work)

 On Thu, Aug 9, 2012 at 11:25 PM, Massimo Di Pierro
  wrote:
 > Can you help us fix the CSS?
 >
 >
 > On Thursday, 9 August 2012 00:29:58 UTC-5, Andrew wrote:
 >>
 >> Just a note on IE7 navbar behaviour:
 >>
 >> The Menu has taken a turn for the worse:
 >> Initially the Welcome App Sub Menus dissapeared in :  "welcome css
 pathc,
 >> issue 896, thanks Angelo"
 >> They then returned in "fixed issue qith clicking on toplevel menus"
 except
 >> all of the submenus are displayed when the menu first appears and
 they are
 >> all on top of each other.
 >>
 >> The login options are still blue, and the space between the navbar
 and
 >> "Welcome" isn't there.
 >> See screen shot.
 >>
 >>
 >> On Thursday, August 9, 2012 9:17:17 AM UTC+12, Massimo Di Pierro
 wrote:
 >>>
 >>> more issues have been addressed. In order to fix an issue I had to
 >>> introduce a slight change of behavior and I am not sure what is the
 best way
 >>> to handle it.
 >>>
 >>> If you login using a third party service (for example janrain using
 >>> facebook) and the service sends info about you, if web2py has
 corresponding
 >>> fields in auth_user, it stores them. If you edit your profile,
 logout,
 >>> change your facebook profile, login again using janrain, should
 web2py keep
 >>> the current local profile or update it? The bug report suggested
 that web2oy
 >>> should always give preference to the local profile.
 >>>
 >>> I changed web2py accordingly. In practice this change will probably
 not
 >>> affect anybody because none of the services sends any information
 stored by
 >>> auth_user.
 >>>
 >>> Yet, please check it.
 >>>
 >>> Massimo
 >>>
 >>>
 >>>
 >>> On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
 
  Web2py 2.0 is almost done.
  Please try the nightly build.
  Let us know if it breaks anything.
 
  massimo
 >
 > --
 >
 >
 >

 --




>>>
>>>
>>> --
>>> Profile: 
>>> http://it.linkedin.com/in/**compagnucciangelo
>>>
>>  --
>>
>>
>>
>>
>
>
>
> --
> Profile: http://it.linkedin.com/in/compagnucciangelo
>



-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 





Re: [web2py] Re: How do larger teams develop with Web2py?

2012-08-10 Thread Phyo Arkar
Thank you for your words!

This is what i believe and my team rolls too. (A bit of agile and that
combined).

We have 3 programmers and 1 UI designer and Architect (me) .

On Thu, Aug 9, 2012 at 8:18 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Listen everybody. This thread is hilarious but not very professional.
>
> I think most of the people on this thread are hardcore programmers and
> most of us came to some conclusions:
> 1) it is not the idea that has value, it is the execution
> 2) the success of a project is strongly correlated with the skills of the
> programmers who work on it, the time and love they put in it.
> 3) it does not really matter how much money is put into a project, if the
> programmers are not good, and if they do not care about the project, it
> will not succeed.
>
> Is there any value in management and or of software development methods? I
> think there is. I am not saying which method is best because there is not
> one size fits all but good programmers in my experience are self
> disciplined. They follow a methodology to keep track of bugs and
> systematically fix them. Their methodology may not exactly match named ones
> (agile or waterfall or other) but it is a methodology.
>
> Massimo
>
> --
>
>
>
>

-- 





[web2py] Looping thru form.vars

2012-08-10 Thread lyn2py
This is something simple, but I don't know why it doesn't work.

I want to loop thru form.vars, so
for key, val in form.vars.iteritems():
text += key+': '+val+"\n"

The ticket says val is a 'Reference'?

-- 





Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Jonathan Lundell
On 10 Aug 2012, at 8:42 AM, Rob_McC  wrote:
>  To make is same as google user name policy:
> They allow periods, but NOT as a first letter - I added to your RegEx
> I'm almost got it, I want to use exactly what Google uses, (see image 
> attached) - I bet this could be on RegEx, but won't have separate messages 
> then.
> 
> auth.settings.table_user.username.requires = [IS_NOT_IN_DB(db, 
> auth.settings.table_user.username),
> IS_LENGTH(30,6,'must be between 6-30 letters'),
> IS_MATCH('[.a-z].*', error_message='lower case only and periods only'),
> IS_EXPR("value[:1]<>'.'", error_message='User name can\'t start with 
> period'),
> IS_EXPR("value.find(' ') < 0", error_message='User name can\'t contain 
> spaces'),
> IS_EXPR("value.find('-') < 0", error_message='User name can\'t contain 
> dashes'),
> IS_EXPR("value.find('_') < 0", error_message='User name can\'t contain 
> underscores'),
> ]
> 
> I'll keep testing, thanks
> Rob
> 

'[.a-z].*' is probably too permissive, or the error message is wrong. Do you 
mean "User name must start with lower case or a period"?

(Does Google really forbid upper case?)

The message "lower case only and periods only" is confusing; it sounds like 
that's the rule for the entire name. Is that right? 

"User name can't contain hyphens": double quotes make the apostrophe 

-- 





Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Jonathan Lundell
On 10 Aug 2012, at 8:42 AM, Rob_McC  wrote:
> I'm almost got it, I want to use exactly what Google uses, (see image 
> attached) - I bet this could be on RegEx, but won't have separate messages 
> then.
> 

Do you really want separate messages? It's annoying to try different names and 
to run into a succession of different objections. Better, it seems to me, to 
show all the rules at once.

Alternatively, describe the rules elsewhere and then use your individual error 
messages.

-- 





[web2py] Re: Looping thru form.vars

2012-08-10 Thread Anthony
Once the data have been inserted into the db, the id of the inserted record 
is stored in form.vars.id, which is a DAL Reference object. Assuming you 
don't want that value, just add a condition testing for key != 'id'. If you 
do want the id included, then you can replace val with str(val) in your 
code.

Anthony

On Friday, August 10, 2012 11:24:38 AM UTC-4, lyn2py wrote:
>
> This is something simple, but I don't know why it doesn't work.
>
> I want to loop thru form.vars, so
> for key, val in form.vars.iteritems():
> text += key+': '+val+"\n"
>
> The ticket says val is a 'Reference'?
>

-- 





Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Rob_McC
Thanks Jonathan.

*Q1:*
*>(Does Google really forbid upper case?)*

. I wouldn't say forbid, but if your name google user name is jonlun, or 
jon.lun  you can sign in with JonLun, or JON.LUN  -
  But. I notice* in web2py,* I can have users like JSMITH, jSmith, smith - 
and I can't think of a reason I would want that.


*Q2:*
*> Do you mean "User name must start with lower case or a period"?*

. No, I want just like google, you can have periods, but NOT as first 
letter. (I have plans for first letter NOT being a period)
*   When you say: '[.a-z].*' is probably too permissive,*
   is that because someone could enter names like john..smith  ?


. I will work on making the messages more clear.
  I will have a comment, on the form,
   users will see,so they don't have to wait for the error box to learn 
what is acceptable

Thanks for very fast response, I'll keep testing it out...

Rob

-- 





[web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Anthony

>
> auth.define_tables(username=True)
> db.auth_user.username.requires.insert(0,IS_MATCH("[a-z].*"))
> *the .insert seemed to give me error. *
>

Hmm, it should work. By default, the username field has an IS_MATCH and and 
IS_NOT_IN_DB validator, so you should be able to insert into the beginning 
of the list. What error did you get? Is there some code you're not showing?
 

> *Important Note:*
>  I had to add, IS_NOT_IN_DB, or new registrations would *OVERWRITE*existing 
> ones,
>   which surprised me a lot.
>

Are you sure? That doesn't seem right. Anyway, they do need to be unique, 
so the IS_NOT_IN_DB is necessary, which is why the IS_MATCH was inserted 
above -- to preserve the existing IS_NOT_IN_DB validator.

Anthony

-- 





[web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Rob_McC
Anthony:

Didn't seem right to me either...

*>By default, the username field has an IS_MATCH and and IS_NOT_IN_DB 
validator, *
. I did see the web2py  regex for that somewhere. and noticed the 
appropriate validators.

*Here is what I tested: (using user names)*

0- start a blank web2py app with only this:

auth.define_tables(username=True)
## create all tables needed by auth if not custom tables
auth.define_tables()
auth.settings.table_user.username.requires=IS_MATCH('[a-z].*', error_message
='letters only')



1- sign up user: jsmith with email jsmith[at]gmail.com
 - examine user's profiile.. all is well.

2- Then, log out

3- Try to register him again, and it will not work because of the duplicate 
email address,
*but if I changed the email address to ,  jsmithxxx[at]gmail.com *
   and left user name *jsmith* -  AND enter a new password, not jsmith's 
 password, it lets me in
to jsmith's original account.

I just tried it again, and I believe that *without* the 
IS_NOT_IN_DB it behaves this way.

Maybe I'm doing something wrong... when I add the IS_NOT_IN_DB validator, 
it all behaves the way I want.

Hope that helps explain what I observed.

Thanks
Rob


-- 





[web2py] Not loading static files when accessing default view in controller

2012-08-10 Thread pbreit
Can you show us code for displaying the images?

-- 





[web2py] Re: Not loading static files when accessing default view in controller

2012-08-10 Thread Anthony

>
> I have a site with a URL like this: www.mydomain/init/foldername/viewname
>

I'm not sure what's going on here, but just for clarification, note that 
web2py does not interpret the last two items in the above URL as a view 
folder and view name. Rather, those are seen as a controller name and a 
function. By default, views are named after their functions and put in 
folders named after their controllers (though that can be overridden). The 
point is, having a view folder and a view without the corresponding 
controller and function won't work (though having a controller and function 
without the corresponding view will work if generic views are enabled).

Anthony

-- 





[web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Anthony

>
> 3- Try to register him again, and it will not work because of the 
> duplicate email address,
> *but if I changed the email address to ,  jsmithxxx[at]gmail.com *
>and left user name *jsmith* -  AND enter a new password, not jsmith's 
>  password, it lets me in
> to jsmith's original account.
>

Yes, but I don't think the new account is overwriting the old account. 
Rather, upon successful registration, the user is automatically logged in 
(unless registration requires verification or approval). The login happens 
by querying for the username and taking the first matching record, which 
will be the original account. Note, this should only happen at 
registration. If you logout and then try to log back in, the login should 
fail because the password for the new account will be compared to that of 
the old account and won't match. Anyway, this is why usernames have to be 
unique and you shouldn't overwrite the default validators as you did.

Anthony

-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-10 Thread Massimo Di Pierro
Can you explain the consequences of this line in your patch?

if (jQuery(document).width() >= 980) 

On Friday, 10 August 2012 10:11:39 UTC-5, AngeloC wrote:
>
> Hi Massimo,
>
> I fixed compatibility with IE and reverted to a non mobile first approach. 
> I reverted because bootstrap is not mobile first (so we add too little) and 
>  for the sake of compatibility with IE.
>
> Patch is attached to issue 
> http://code.google.com/p/web2py/issues/detail?id=896 which I cannot 
> reopen.
>
> Hope this helps!
>
> Angelo
>
> 2012/8/10 Angelo Compagnucci >
>
>> Hi Massimo,
>>
>> I'm writing it right now to fix ie issues! Please be patient until fixed!
>>
>>
>> 2012/8/9 Massimo Di Pierro >
>>
>>> This may be ok but where do I get bootswatch_ie.css from?
>>>
>>>
>>> On Thursday, 9 August 2012 11:43:28 UTC-5, AngeloC wrote:
>>>
 Hi Massimo,

 I think I cannot complete the bootstrap/web2py css merging in time for 
 2.0, it's really a lot of work and I'm a bit busy these days.

 Btw, i'm fixing the bug I introduced with issue 896 and I want to share 
 a thought with you.

 Actually, there is no way to maintain a mobile first approach and make 
 it working on IE other than add something like this to the scaffolding:

 
 

 This will make speedier the whole css on not IE browsers because we 
 remove IE specific rules (smaller css), but has the downside to require an 
 extra http get on IE.

 What do you think?


 2012/8/9 Alec Taylor 

> It would be good to have OAuth working for web2py 2
>
> Facebook and LinkedIn still have some issues
>
> LinkedIn: https://groups.google.com/**forum/#!topic/web2py/**
> SbnQEnXEcOg
>
> Facebook: (will add bug report once I've gotten LinkedIn login to work)
>
> On Thu, Aug 9, 2012 at 11:25 PM, Massimo Di Pierro
>  wrote:
> > Can you help us fix the CSS?
> >
> >
> > On Thursday, 9 August 2012 00:29:58 UTC-5, Andrew wrote:
> >>
> >> Just a note on IE7 navbar behaviour:
> >>
> >> The Menu has taken a turn for the worse:
> >> Initially the Welcome App Sub Menus dissapeared in :  "welcome css 
> pathc,
> >> issue 896, thanks Angelo"
> >> They then returned in "fixed issue qith clicking on toplevel menus" 
> except
> >> all of the submenus are displayed when the menu first appears and 
> they are
> >> all on top of each other.
> >>
> >> The login options are still blue, and the space between the navbar 
> and
> >> "Welcome" isn't there.
> >> See screen shot.
> >>
> >>
> >> On Thursday, August 9, 2012 9:17:17 AM UTC+12, Massimo Di Pierro 
> wrote:
> >>>
> >>> more issues have been addressed. In order to fix an issue I had to
> >>> introduce a slight change of behavior and I am not sure what is 
> the best way
> >>> to handle it.
> >>>
> >>> If you login using a third party service (for example janrain using
> >>> facebook) and the service sends info about you, if web2py has 
> corresponding
> >>> fields in auth_user, it stores them. If you edit your profile, 
> logout,
> >>> change your facebook profile, login again using janrain, should 
> web2py keep
> >>> the current local profile or update it? The bug report suggested 
> that web2oy
> >>> should always give preference to the local profile.
> >>>
> >>> I changed web2py accordingly. In practice this change will 
> probably not
> >>> affect anybody because none of the services sends any information 
> stored by
> >>> auth_user.
> >>>
> >>> Yet, please check it.
> >>>
> >>> Massimo
> >>>
> >>>
> >>>
> >>> On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
> 
>  Web2py 2.0 is almost done.
>  Please try the nightly build.
>  Let us know if it breaks anything.
> 
>  massimo
> >
> > --
> >
> >
> >
>
> --
>
>
>
>


 -- 
 Profile: 
 http://it.linkedin.com/in/**compagnucciangelo
  
>>>  -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Profile: http://it.linkedin.com/in/compagnucciangelo
>>  
>
>
>
> -- 
> Profile: http://it.linkedin.com/in/compagnucciangelo
>  

-- 





[web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Rob_McC
Anthony:

You're correct about log gin out and back in, but I did gain access to 
jsmith's account upon registration,
 and* I could (and did)*
* change his password in profile, and now I control his account *- 
locking smith out.

I did assume that the "old validator" *would still fire,* and not be 
replaced
with just my validator.- but used WITH my validator.

Anyhow, should work just fine, but something to be aware of I think.

Maybe a note in the documentation would be in order - I stumbled upon this 
only by chance
trying dozens of combinations for not allowing capital letter etc.  and if 
I never changed the email address,
I would have thought everything was just fine.

Be happy to do any testing of this issue.

Thanks again, I'm learning a lot ..

Rob




-- 





Re: [web2py] Problems with restful + PUT

2012-08-10 Thread Tito Garrido
Version 1.99.4 (2011-12-14 14:46:14) stableRunning on Apache/2.2.17 (Unix)
mod_wsgi/3.3 Python/2.7.3

On Fri, Aug 10, 2012 at 11:00 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Which web2py version?
>
>
> On Friday, 10 August 2012 08:39:40 UTC-5, Tito Garrido wrote:
>
>> Same error using locals()
>>
>> :(
>>
>> On Thu, Aug 9, 2012 at 5:23 PM, Bruno Rocha  wrote:
>>
>>> try to replace  return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>>> with return locals()
>>>
>>> I dont know, but maybe its the problem
>>>
>>> On Wed, Aug 8, 2012 at 10:49 PM, Tito Garrido wrote:
>>>
 Hi folks,

 *I have a simple table:*

 *db.define_table('estadio',
 Field('cod_estadio','id'),
 Field('nome_estadio'),
 Field('cidade'),migrate=False) *

 *A simple entry:*

 *estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A
 Definir**A Definir*
 and using Bruno's example in web2pyslice:


1. @request.restful()



2. def api():
3. response.view = 'generic.'+request.extension
4. def GET(*args,**vars):
5. patterns = 'auto'
6. parser = db.parse_as_rest(patterns,args**,vars)





7. if parser.status == 200:
8. return dict(content=parser.response)
9. else:
10. raise HTTP(parser.status,parser.erro**r)





11. def POST(table_name,**vars):
12. return db[table_name].validate_and_**insert(**vars)
13. def PUT(table_name,record_id,**var**s):
14. return db(db[table_name]._id==record_**id).update(**vars)





15. def DELETE(table_name,record_id):
16. return db(db[table_name]._id==record_**id).delete()





17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)







 *but when I try to:*
 *
 curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste"
 http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*

 *it returns:*

 HTTP/1.1 400 BAD REQUEST
 Server: nginx
 Date: Thu, 09 Aug 2012 01:41:44 GMT
 Content-Type: text/html; charset=UTF-8
 Connection: keep-alive
 Set-Cookie: 
 session_id_ws=xx-**65e0b712-7d93-4b21-a553-**d06ce06af2a2;
 Path=/
 Content-Length: 540

 invalid arguments

 *What am I missing here?

 Thanks in advance!*


 --

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

 --




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



-- 

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

-- 





Re: [web2py] Problems with restful + PUT

2012-08-10 Thread Bruno Rocha
Dirk posted this on web2pyslices...

To PUT (=update) something, you need to call:

curl -i -H "Accept: application/json" -X PUT --user user:pass -d
"f_entry=something newest"
http://127.0.0.1:8000/RT/default/api/entries/1.json

with id=1 being an existing entry.

So of course, PUT works as update... the 1.json refers to an existing
record...

If you want to create a new record you need to use POST, I think...


On Fri, Aug 10, 2012 at 3:21 PM, Tito Garrido  wrote:

> Version 1.99.4 (2011-12-14 14:46:14) stableRunning on Apache/2.2.17
> (Unix) mod_wsgi/3.3 Python/2.7.3
>
> On Fri, Aug 10, 2012 at 11:00 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Which web2py version?
>>
>>
>> On Friday, 10 August 2012 08:39:40 UTC-5, Tito Garrido wrote:
>>
>>> Same error using locals()
>>>
>>> :(
>>>
>>> On Thu, Aug 9, 2012 at 5:23 PM, Bruno Rocha  wrote:
>>>
 try to replace  return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
 with return locals()

 I dont know, but maybe its the problem

 On Wed, Aug 8, 2012 at 10:49 PM, Tito Garrido wrote:

> Hi folks,
>
> *I have a simple table:*
>
> *db.define_table('estadio',
> Field('cod_estadio','id'),
> Field('nome_estadio'),
> Field('cidade'),migrate=False) *
>
> *A simple entry:*
>
> *estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A
> Definir**A Definir*
> and using Bruno's example in web2pyslice:
>
>
>1. @request.restful()
>
>
>
>
>
>2. def api():
>3. response.view = 'generic.'+request.extension
>4. def GET(*args,**vars):
>5. patterns = 'auto'
>6. parser = db.parse_as_rest(patterns,args**,vars)
>
>
>
>
>
>
>
>7. if parser.status == 200:
>8. return dict(content=parser.response)
>9. else:
>10. raise HTTP(parser.status,parser.erro**r)
>
>
>
>
>
>
>
>11. def POST(table_name,**vars):
>12. return db[table_name].validate_and_**insert(**vars)
>13. def PUT(table_name,record_id,**var**s):
>14. return db(db[table_name]._id==record_**id).update(**vars)
>
>
>
>
>
>
>
>15. def DELETE(table_name,record_id):
>16. return db(db[table_name]._id==record_**id).delete()
>
>
>
>
>
>
>
>17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>
>
>
>
>
>
>
>
>
> *but when I try to:*
> *
> curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste"
> http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*
>
> *it returns:*
>
> HTTP/1.1 400 BAD REQUEST
> Server: nginx
> Date: Thu, 09 Aug 2012 01:41:44 GMT
> Content-Type: text/html; charset=UTF-8
> Connection: keep-alive
> Set-Cookie: 
> session_id_ws=xx-**65e0b712-7d93-4b21-a553-**d06ce06af2a2;
> Path=/
> Content-Length: 540
>
> invalid arguments
>
> *What am I missing here?
>
> Thanks in advance!*
>
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>
> --
>
>
>
>

  --




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

-- 





[web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.

2012-08-10 Thread Anthony
On Friday, August 10, 2012 2:12:54 PM UTC-4, Rob_McC wrote:
>
> Anthony:
>
> You're correct about log gin out and back in, but I did gain access to 
> jsmith's account upon registration,
>  and* I could (and did)*
> * change his password in profile, and now I control his account *- 
> locking smith out.
>
> I did assume that the "old validator" *would still fire,* and not be 
> replaced
> with just my validator.- but used WITH my validator.
>

db.auth_user.username.requires = [list, of, validators]
db.auth_user.username.requires = IS_MATCH(...)

The above replaces a list with a single validator. In Python, if you assign 
a new value to an object that was a list, it does not get appended to the 
list -- it replaces the list (as it would replace any other type of 
object). If you want to mutate an existing list, you have to use .insert(), 
.append(), .extend(), +, etc., which is what Massimo originally instructed. 
Also, the book section on customizing Auth says the following:

If you add a field called "username", it will be used in place of "email" 
for login. If you do, you will need to add a validator as well:

1.

auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)


I suppose we could add a sterner warning, though. Perhaps we should force 
an IS_NOT_IN_DB validator on username/email when registration is processed 
in case there isn't one.

Anthony

-- 





Re: [web2py] raspberry pi

2012-08-10 Thread Stef Mientki

I just did it, within 5  minutes.
Python is already installed on the Raspberry-pi.

- download the sources to the Raspberry
- unpack the zip file
- open a terminal window and go to the directory where it is unpacked
- python web2py.py

that's all.

cheers,
Stef

On 13-03-2012 11:04, António Ramos wrote:

it would be nice to be able to install web2py in raspberry pi

http://www.raspberrypi.org/


--





[web2py] Get result set back as list?

2012-08-10 Thread Toby Shepard


I'm in a situation where I just want a single column back from
a table.  I'd like it as a list so I could just pass it on
to the next function.

All I can think of is something like:

temp = []

for thing in db(db.mytable).select(db.mytable.myfield):
temp.append(thing)

return temp

I was hoping for something like:

return db(db.mytable).select(db.mytable.myfield).as_list()

Or something like that.

As an aside, I have a python dbi that has four central ways to get
data back.  I call them:

atom()  scalar as in'select first from person where id = 1'
row()   dict as in  'select * from person' where id = 1'
column()list as in  'select first from person'
world() list of dict:   'select * from person'

They end up being uite convenient and result in concise syntax.

Thanks,

Tobiah

--





[web2py] Re: Get result set back as list?

2012-08-10 Thread Anthony
mylist = [r.myfield for r in db().select(db.mytable.myfield)]

Anthony

On Friday, August 10, 2012 4:34:01 PM UTC-4, Toby Shepard wrote:
>
>
> I'm in a situation where I just want a single column back from 
> a table.  I'd like it as a list so I could just pass it on 
> to the next function. 
>
> All I can think of is something like: 
>
> temp = [] 
>
> for thing in db(db.mytable).select(db.mytable.myfield): 
> temp.append(thing) 
>
> return temp 
>
> I was hoping for something like: 
>
> return db(db.mytable).select(db.mytable.myfield).as_list() 
>
> Or something like that. 
>
> As an aside, I have a python dbi that has four central ways to get 
> data back.  I call them: 
>
> atom()scalar as in 'select first from person where 
> id = 1' 
> row()dict as in'select * from person' where id 
> = 1' 
> column()list as in 'select first from person' 
> world()list of dict:'select * from person' 
>
> They end up being uite convenient and result in concise syntax. 
>
> Thanks, 
>
> Tobiah 
>

-- 





[web2py] Re: Looping thru form.vars

2012-08-10 Thread lyn2py
Thanks Anthony, that worked!

On Saturday, August 11, 2012 12:04:58 AM UTC+8, Anthony wrote:
>
> Once the data have been inserted into the db, the id of the inserted 
> record is stored in form.vars.id, which is a DAL Reference object. 
> Assuming you don't want that value, just add a condition testing for key 
> != 'id'. If you do want the id included, then you can replace val with 
> str(val) in your code.
>
> Anthony
>
> On Friday, August 10, 2012 11:24:38 AM UTC-4, lyn2py wrote:
>>
>> This is something simple, but I don't know why it doesn't work.
>>
>> I want to loop thru form.vars, so
>> for key, val in form.vars.iteritems():
>> text += key+': '+val+"\n"
>>
>> The ticket says val is a 'Reference'?
>>
>

-- 





[web2py] Electronic voting anybody?

2012-08-10 Thread Massimo Di Pierro
Demo service:

   https://tests.web2py.com/evote/default/index

Source:

   https://github.com/mdipierro/evote

I could use some help checking it. Specifically usability and security.

Massimo

-- 





[web2py] Re: Problem with Field display in SQLForm.Smartgrid

2012-08-10 Thread Massimo Di Pierro
How did you populate the Star field?

On Wednesday, 8 August 2012 21:39:42 UTC-5, Mike Girard wrote:
>
> Hello:
>
> I am building a movie database site with web2py. I have a movies table 
> which has a many-to-many relationship with several other items: stars, 
> directors and genres. I am using a SQLForm.Smartgrid declared in my 
> controller like so: 
>
> def manage_movies():
> grid = SQLFORM.smartgrid(db.movie)
> return locals()
>
> Everything seems to be working fine -- all of the reference tables are 
> showing up. However, when I click on, say 'Stars', which is the reference 
> table joining db.movie with db.person, the Movie ID and Star Fields are 
> oddly populated. Attached is a screenshot which should make this clear. 
>
>
> 
>
> If I click edit for a Star record, everything is fine. There are dropdowns 
> with the appropriate movie and star selected. 
>
> I realize I haven't provided any of my model code. Was hoping someone 
> might be able to quickly id the problem without all that.
>
> Thanks for your help. 
>
>
>
>

-- 





Re: [web2py] Re: GAE Cloud SQL local dev server problem

2012-08-10 Thread Massimo Di Pierro
can you please open a ticket?

On Wednesday, 8 August 2012 18:11:04 UTC-5, Alexei Vinidiktov wrote:
>
> Ok. I've managed to connect to MySQL from GAE local dev server on Windows 
> if I change line 3845 in dal.py to this:
>
> self.folder = ""
>
> instead of (self.folder = folder or 
> '$HOME/'+thread.folder.split('/applications/',1)[1])
>
> I don't know if it breaks anything though.
>
> On Thu, Aug 9, 2012 at 6:03 AM, Alexei Vinidiktov 
> 
> > wrote:
>
>> The problem is still not resolved in trunk.
>>
>>
>> On Mon, Aug 6, 2012 at 12:56 PM, Alexei Vinidiktov 
>> 
>> > wrote:
>>
>>> Here it is: db = DAL('google:sql://vocabilisproject:vocabilis/vocabilis')
>>>
>>> I pass the password and the user name via App Launcher parameters as 
>>> suggested in the GAE SDK docs: --mysql_user=root --mysql_password=xx 
>>> --mysql_host=localhost --mysql_port=3306 
>>>
>>>
>>> On Mon, Aug 6, 2012 at 7:59 AM, Massimo Di Pierro 
>>> 
>>> > wrote:
>>>
 Can you show your complete connection string (masking any password of 
 course)?


 On Saturday, 4 August 2012 02:11:30 UTC-5, Alexei Vinidiktov wrote:
>
>
>
> On Sat, Aug 4, 2012 at 1:56 PM, Alexei Vinidiktov <
> alexei.v...@gmail.com > wrote:
>
>> Hello,
>>
>> I'm need hep figuring out how to set up a local GAE development 
>> server with MySQL.
>>
>> MySQL connection parameters are specified via App Launcher 
>> application settings: --mysql_user=root --mysql_password=xx 
>> --mysql_host=localhost --mysql_port=3306 
>>
>> When I launch my web2py app with GAE Launcher on my local Windows 
>> box I get this erorr message:
>>
>> 
>> ERROR2012-08-04 06:28:43,515 dal.py:5962] DEBUG: connect attempt 
>> 0, connection error:
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
>>  
>> line 5955, in __init__
>> self._adapter = ADAPTERS[self._dbname](*args)
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
>>  
>> line 3310, in __init__
>> self.folder = folder or '$HOME/'+thread.folder.split('**
>> /applications/',1)[1]
>> IndexError: list index out of range
>> #
>>
>> What does the following line do? 
>>
>> self.folder = folder or '$HOME/'+thread.folder.split('**
>> /applications/',1)[1]
>>
>> If I comment out "or 
>> '$HOME/'+thread.folder.split('**/applications/',1)[1]" 
>> in DAL.py and relaunch the dev server, the application appears to be 
>> able 
>> to connect to MySQL but then I get a different error message:
>>
>> 
>> INFO 2012-08-04 06:42:35,142 rdbms_mysqldb.py:102] Connecting to 
>> MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host': 
>> 'localhost', 'port': 3306, 'user': 'root'}
>> ERROR2012-08-04 06:42:35,153 warnings.py:29] 
>> C:\Users\alexei\Dev\web2py\voc**abilis.net 
>> \gluon\dal.py:1386: 
>> Warning: Can't create database 'vocabilis'; database exists
>>   ret = self.cursor.execute(*a, **b)
>>
>> ERROR2012-08-04 06:42:35,575 restricted.py:155] Traceback (most 
>> recent call last):
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py",
>>  
>> line 510, in wsgibase
>> session._try_store_in_db(**request, response)
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\globals.py",
>>  
>> line 561, in _try_store_in_db
>> record_id = table.insert(**dd)
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
>>  
>> line 6829, in insert
>> return self._db._adapter.insert(self,**self._listify(fields))
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
>>  
>> line 928, in insert
>> raise e
>> ProgrammingError: (1146, "Table 'vocabilis.web2py_session_**vocabilis' 
>> doesn't exist")
>> #
>>
>> The vocabilis database does exist. It was created earlier when I 
>> connected to MySQL from a non GAE environment.
>>
>> If I specify a different non-existent database in the connection 
>> string, then after relaunching the application vith the GAE Launcher I 
>> get 
>> this error message:
>>
>> ###
>> INFO 2012-08-04 06:44:45,415 rdbms_mysqldb.py:102] Connecting to 
>> MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host': 
>> 'localhost', 'port': 3306, 'user': 'root'}
>> ERROR2012-08-04 06:44:45,828 restricted.py:155] Traceback (most 
>> recent call last):
>>   File 
>> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py

[web2py] Re: KeyError: 'name' when inserting/updating via appadmin

2012-08-10 Thread Massimo Di Pierro
Can you please open a ticket?

On Wednesday, 8 August 2012 12:08:53 UTC-5, Mandar Vaze wrote:
>
> I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev
>
> I have tables defined as follows : 
>
> name = db.Table(db, 'name',   
>
> Field('name', 'string', length=128, notnull=True, unique=True))
>   
> name_desc = db.Table(db, 'base',
> name,
> Field('description', 'text', default='')) 
>   
> db.define_table('mother', 
> name_desc,
> format='%(name)s')
> db.define_table('father', 
> name_desc,
> format='%(name)s')
> db.define_table('child',   
>
> name_desc, 
>  
> Field('mother', db.mother),   
> 
> Field('father', db.father),   
>
> format='%(name)s')
>
> I am able to insert data in "mother" table via script (like 
> db.mother.insert(name="Alice"))
> But when I use appadmin to insert new record into mother table, I get the 
> following error :
>
> Traceback (most recent call last):
>   File "/home/mandar/web2py/gluon/restricted.py", line 205, in restricted
> exec ccode in environment
>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
> line 432, in 
>   File "/home/mandar/web2py/gluon/globals.py", line 182, in 
> self._caller = lambda f: f()
>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
> line 127, in insert
> if form.accepts(request.vars, session):
>   File "/home/mandar/web2py/gluon/sqlhtml.py", line 1146, in accepts
> hideerror=hideerror,
>   File "/home/mandar/web2py/gluon/html.py", line 1870, in accepts
> status = self._traverse(status,hideerror)
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 800, in _traverse
> newstatus = self._validate()
>   File "/home/mandar/web2py/gluon/html.py", line 1625, in _validate
> (value, errors) = validator(value)
>   File "/home/mandar/web2py/gluon/validators.py", line 554, in __call__
> table = self.dbset.db[tablename]
>   File "/home/mandar/web2py/gluon/dal.py", line 6877, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: 'name'
>
> Similarly, after populating mother/father and child tables via script when 
> I try to update "child" record - In the dropdown I see mother's names 
> instead of ID (as expected) but when I select different "mother" and submit 
> I get same error (traceback may be slightly different - but same 
> KeyError:'name' )
>
> What is wrong with the table definitions ?
>
> Thanks,
> -Mandar
>
>

-- 





Re: [web2py] Init Script in Web2Py

2012-08-10 Thread Richard Vézina
if db(db.state.id>0).count() == 0:
db.state.truncate()
db.city.truncate()
db.zipcode.truncate()
db.areacode.truncate()
db.state.insert(name='Texas')
db.state.insert(name='Illinois')
db.state.insert(name='California')

db.city.insert(name='Austin',state=1)
db.city.insert(name='Dallas',state=1)
db.city.insert(name='Chicago',state=2)
db.city.insert(name='Aurora',state=2)
db.city.insert(name='Los Angeles',state=3)
db.city.insert(name='San Diego',state=3)

db.zipcode.insert(value='78704',city=1)
db.zipcode.insert(value='78745',city=1)
db.zipcode.insert(value='75001',city=2)
db.zipcode.insert(value='75038',city=2)
db.zipcode.insert(value='60606',city=3)
db.zipcode.insert(value='60607',city=3)
db.zipcode.insert(value='60504',city=4)
db.zipcode.insert(value='60505',city=4)
db.zipcode.insert(value='90005',city=5)
db.zipcode.insert(value='90006',city=5)
db.zipcode.insert(value='92101',city=6)
db.zipcode.insert(value='92102',city=6)

db.areacode.insert(value='512',zipcode=1)
db.areacode.insert(value='511',zipcode=1)
db.areacode.insert(value='345',zipcode=2)
db.areacode.insert(value='456',zipcode=2)
db.areacode.insert(value='567',zipcode=3)
db.areacode.insert(value='678',zipcode=3)
db.areacode.insert(value='789',zipcode=4)
db.areacode.insert(value='890',zipcode=4)
db.areacode.insert(value='901',zipcode=5)
db.areacode.insert(value='321',zipcode=5)
db.areacode.insert(value='432',zipcode=6)
db.areacode.insert(value='534',zipcode=6)
db.areacode.insert(value='645',zipcode=7)
db.areacode.insert(value='765',zipcode=7)
db.areacode.insert(value='876',zipcode=8)
db.areacode.insert(value='987',zipcode=8)
db.areacode.insert(value='141',zipcode=9)
db.areacode.insert(value='252',zipcode=9)
db.areacode.insert(value='363',zipcode=10)
db.areacode.insert(value='474',zipcode=10)
db.areacode.insert(value='585',zipcode=11)
db.areacode.insert(value='686',zipcode=11)
db.areacode.insert(value='797',zipcode=12)
db.areacode.insert(value='898',zipcode=12)


You can put something like that in models somewhere.

You just need to adapt for you particular table and the records you want to
create and verify the presence of.

Just wrote the proper db request with the proper where attribute :

Let's say you have create user1 in auth_user so you can write this :

if db(db.auth_user.first_name = 'user1').count() != 1:
db.auth_user.insert(first_name='user1')

Hope it what you were searching for.

Richard

On Fri, Aug 10, 2012 at 5:56 AM, tommasot  wrote:

> I have a newbie question.
>
> I need to create some record in db on application startup,like for example
> default user and other things..
>
>
>
> Where is the right script/place to implement it
>
>
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Suggestion - a pickled DAL field

2012-08-10 Thread Derek
You could monkey patch it in 0.py in models, perhaps.

On Thursday, July 26, 2012 1:10:43 AM UTC-7, Omri Har-Shemesh wrote:
>
> I use the pickled field to store a dictionary. Since dictionary
> is not defined as a serializable type for the as_dict function,
> it is not returned when calling to as_dict. 
> Adding it (dal.py line 6183) solved my problem, but I would
> like to keep this change when I update my web2py next. Is
> there a different way (without changing the dal) to achieve this?
> Could you add it to the dal.py? Is it without risks?
>
> Thanks,
> Omri
>
> On Thu, Jul 26, 2012 at 9:46 AM, Omri >wrote:
>
>> So I tried it out, and it works great, except for one thing - when I try 
>> to use record.as_dict() to get
>> the structure which I can return to a JSON-RPC call which I normally use 
>> to communicate with my
>> client, it simply does not return the field. 
>> I tried to print it out and I see very clearly that as long as it is a 
>> Row object there is no problem, but
>> as soon as I run .as_dict() it disappears.
>> My definitions are as follows:
>>
>> from gluon.dal import SQLCustomType
>> pickled = SQLCustomType(
>> type = 'text',
>> native = 'text',
>> encoder = (lambda x: pickle.dumps(x)),
>> decoder = (lambda x: pickle.loads(x))
>> )
>>
>> then I use
>> db.define_table("my_table",
>> Field("pickled_field", type=pickled)
>> )
>>
>> but when I fetch the record it does not go to as_dict() (actually I use 
>> as_list() but both don't work).
>>
>> Any suggestions? Is there a way to teach as_dict to interpret this field 
>> type?
>>
>> Best wishes,
>> Omri
>>
>>
>> On Wed, Jul 25, 2012 at 9:20 PM, howesc > >wrote:
>>
>>> For what it is worth i have used custom fields for this type of thing 
>>> with great success!
>>>
>>>
>>> On Tuesday, July 24, 2012 8:20:03 AM UTC-7, Anthony wrote:

 You could use a SQLCustomType field: http://web2py.com/**
 books/default/chapter/29/6#**Custom-Field-types-(**experimental)
 .

 Anthony

 On Tuesday, July 24, 2012 8:34:07 AM UTC-4, Omri Har-Shemesh wrote:
>
>
> Hi web2pyers,
>
> very often, I have a field in the table which has to hold a complicated
> value (most often numpy arrays). The way I implement it is that I use
> "text" as the type of field, and then simply pickle.dumps(my_value) 
> when
> I save the field, and then pickle.loads(value_from_db) to access the 
> field
> again. 
>
> My suggestion is simple - create field that automatically pickles the 
> values
> it gets and unpickles them on extraction. Is this already implemented? 
> Do you have other suggestions on how to implement this so that I won't 
> need
> to pickle every time I access the table?
>
> Best wishes,
> Omri
>
  -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>

-- 





[web2py] Store DB connection information in private/ folder

2012-08-10 Thread Gian Luca Decurtins
Hi all

How do I store the DB connection information (db = DAL(...)) in the 
private/ folder?

I would like to sync the application using Mercurial. The local DB 
information should not be shared.
The .hgignore file already includes "private/*".

Cheers
-Luca.

-- 





Re: [web2py] Re: Suggestion - a pickled DAL field

2012-08-10 Thread Omri
Hi Derek,

thanks! the as_dict method has already been fixed in trunk to handle
my use-case.

best wishes,
Omri

On Sat, Aug 11, 2012 at 12:26 AM, Derek  wrote:

> You could monkey patch it in 0.py in models, perhaps.
>
>
> On Thursday, July 26, 2012 1:10:43 AM UTC-7, Omri Har-Shemesh wrote:
>
>> I use the pickled field to store a dictionary. Since dictionary
>> is not defined as a serializable type for the as_dict function,
>> it is not returned when calling to as_dict.
>> Adding it (dal.py line 6183) solved my problem, but I would
>> like to keep this change when I update my web2py next. Is
>> there a different way (without changing the dal) to achieve this?
>> Could you add it to the dal.py? Is it without risks?
>>
>> Thanks,
>> Omri
>>
>> On Thu, Jul 26, 2012 at 9:46 AM, Omri  wrote:
>>
>>> So I tried it out, and it works great, except for one thing - when I try
>>> to use record.as_dict() to get
>>> the structure which I can return to a JSON-RPC call which I normally use
>>> to communicate with my
>>> client, it simply does not return the field.
>>> I tried to print it out and I see very clearly that as long as it is a
>>> Row object there is no problem, but
>>> as soon as I run .as_dict() it disappears.
>>> My definitions are as follows:
>>>
>>> from gluon.dal import SQLCustomType
>>> pickled = SQLCustomType(
>>> type = 'text',
>>> native = 'text',
>>> encoder = (lambda x: pickle.dumps(x)),
>>> decoder = (lambda x: pickle.loads(x))
>>> )
>>>
>>> then I use
>>> db.define_table("my_table",
>>> Field("pickled_field", type=pickled)
>>> )
>>>
>>> but when I fetch the record it does not go to as_dict() (actually I use
>>> as_list() but both don't work).
>>>
>>> Any suggestions? Is there a way to teach as_dict to interpret this field
>>> type?
>>>
>>> Best wishes,
>>> Omri
>>>
>>>
>>> On Wed, Jul 25, 2012 at 9:20 PM, howesc  wrote:
>>>
 For what it is worth i have used custom fields for this type of thing
 with great success!


 On Tuesday, July 24, 2012 8:20:03 AM UTC-7, Anthony wrote:
>
> You could use a SQLCustomType field: http://web2py.com/**books**
> /default/chapter/29/6#**Custom-**Field-types-(**experimental)
> .
>
> Anthony
>
> On Tuesday, July 24, 2012 8:34:07 AM UTC-4, Omri Har-Shemesh wrote:
>>
>>
>> Hi web2pyers,
>>
>> very often, I have a field in the table which has to hold a
>> complicated
>> value (most often numpy arrays). The way I implement it is that I use
>> "text" as the type of field, and then simply pickle.dumps(my_value)
>> when
>> I save the field, and then pickle.loads(value_from_db) to access the
>> field
>> again.
>>
>> My suggestion is simple - create field that automatically pickles the
>> values
>> it gets and unpickles them on extraction. Is this already
>> implemented?
>> Do you have other suggestions on how to implement this so that I
>> won't need
>> to pickle every time I access the table?
>>
>> Best wishes,
>> Omri
>>
>  --




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

-- 





Re: [web2py] Re: Suggestion - a pickled DAL field

2012-08-10 Thread Derek
aww, I love to see a cute monkey patch.

On Friday, August 10, 2012 3:28:03 PM UTC-7, Omri Har-Shemesh wrote:
>
> Hi Derek,
>
> thanks! the as_dict method has already been fixed in trunk to handle
> my use-case.
>
> best wishes,
> Omri
>
> On Sat, Aug 11, 2012 at 12:26 AM, Derek >wrote:
>
>> You could monkey patch it in 0.py in models, perhaps.
>>
>>
>> On Thursday, July 26, 2012 1:10:43 AM UTC-7, Omri Har-Shemesh wrote:
>>
>>> I use the pickled field to store a dictionary. Since dictionary
>>> is not defined as a serializable type for the as_dict function,
>>> it is not returned when calling to as_dict. 
>>> Adding it (dal.py line 6183) solved my problem, but I would
>>> like to keep this change when I update my web2py next. Is
>>> there a different way (without changing the dal) to achieve this?
>>> Could you add it to the dal.py? Is it without risks?
>>>
>>> Thanks,
>>> Omri
>>>
>>> On Thu, Jul 26, 2012 at 9:46 AM, Omri  wrote:
>>>
 So I tried it out, and it works great, except for one thing - when I 
 try to use record.as_dict() to get
 the structure which I can return to a JSON-RPC call which I normally 
 use to communicate with my
 client, it simply does not return the field. 
 I tried to print it out and I see very clearly that as long as it is a 
 Row object there is no problem, but
 as soon as I run .as_dict() it disappears.
 My definitions are as follows:

 from gluon.dal import SQLCustomType
 pickled = SQLCustomType(
 type = 'text',
 native = 'text',
 encoder = (lambda x: pickle.dumps(x)),
 decoder = (lambda x: pickle.loads(x))
 )

 then I use
 db.define_table("my_table",
 Field("pickled_field", type=pickled)
 )

 but when I fetch the record it does not go to as_dict() (actually I use 
 as_list() but both don't work).

 Any suggestions? Is there a way to teach as_dict to interpret this 
 field type?

 Best wishes,
 Omri


 On Wed, Jul 25, 2012 at 9:20 PM, howesc  wrote:

> For what it is worth i have used custom fields for this type of thing 
> with great success!
>
>
> On Tuesday, July 24, 2012 8:20:03 AM UTC-7, Anthony wrote:
>>
>> You could use a SQLCustomType field: http://web2py.com/**books**
>> /default/chapter/29/6#**Custom-**Field-types-(**experimental)
>> .
>>
>> Anthony
>>
>> On Tuesday, July 24, 2012 8:34:07 AM UTC-4, Omri Har-Shemesh wrote:
>>>
>>>
>>> Hi web2pyers,
>>>
>>> very often, I have a field in the table which has to hold a 
>>> complicated
>>> value (most often numpy arrays). The way I implement it is that I use
>>> "text" as the type of field, and then simply pickle.dumps(my_value) 
>>> when
>>> I save the field, and then pickle.loads(value_from_db) to access the 
>>> field
>>> again. 
>>>
>>> My suggestion is simple - create field that automatically pickles 
>>> the values
>>> it gets and unpickles them on extraction. Is this already 
>>> implemented? 
>>> Do you have other suggestions on how to implement this so that I 
>>> won't need
>>> to pickle every time I access the table?
>>>
>>> Best wishes,
>>> Omri
>>>
>>  -- 
>  
>  
>  
>


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

-- 





[web2py] Batch upload of media?

2012-08-10 Thread lyn2py
Hi,

I want to give the user the option to perform a batch upload of their image 
files and/or video files.

How should I go about that in web2py?
Must video and image uploads be performed separately?

Thanks!

-- 





Re: [web2py] Batch upload of media?

2012-08-10 Thread Vasile Ermicioi
http://blueimp.github.com/jQuery-File-Upload/

-- 





Re: [web2py] Batch upload of media?

2012-08-10 Thread Bruno Rocha
https://github.com/mdipierro/web2py-recipes-source/raw/master/apps/04_advanced_forms/web2py.app.fileuploader.w2p

https://github.com/mdipierro/web2py-recipes-source/raw/master/apps/04_advanced_forms/web2py.app.upload.w2p

https://github.com/mdipierro/web2py-recipes-source/raw/master/apps/04_advanced_forms/web2py.app.monitoring_upload.w2p



On Fri, Aug 10, 2012 at 7:43 PM, lyn2py  wrote:

> Hi,
>
> I want to give the user the option to perform a batch upload of their
> image files and/or video files.
>
> How should I go about that in web2py?
> Must video and image uploads be performed separately?
>
> Thanks!
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Get result set back as list?

2012-08-10 Thread Vasile Ermicioi
for me that works

alist = db(db.auth_user).select().as_list()

-- 





[web2py] Re: KeyError: 'name' when inserting/updating via appadmin

2012-08-10 Thread Derek
That definitely looks like a problem. Still though, I think you are taking 
3NF a bit too far, no?

On Wednesday, August 8, 2012 10:08:53 AM UTC-7, Mandar Vaze wrote:
>
> I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev
>
> I have tables defined as follows : 
>
> name = db.Table(db, 'name',   
>
> Field('name', 'string', length=128, notnull=True, unique=True))
>   
> name_desc = db.Table(db, 'base',
> name,
> Field('description', 'text', default='')) 
>   
> db.define_table('mother', 
> name_desc,
> format='%(name)s')
> db.define_table('father', 
> name_desc,
> format='%(name)s')
> db.define_table('child',   
>
> name_desc, 
>  
> Field('mother', db.mother),   
> 
> Field('father', db.father),   
>
> format='%(name)s')
>
> I am able to insert data in "mother" table via script (like 
> db.mother.insert(name="Alice"))
> But when I use appadmin to insert new record into mother table, I get the 
> following error :
>
> Traceback (most recent call last):
>   File "/home/mandar/web2py/gluon/restricted.py", line 205, in restricted
> exec ccode in environment
>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
> line 432, in 
>   File "/home/mandar/web2py/gluon/globals.py", line 182, in 
> self._caller = lambda f: f()
>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
> line 127, in insert
> if form.accepts(request.vars, session):
>   File "/home/mandar/web2py/gluon/sqlhtml.py", line 1146, in accepts
> hideerror=hideerror,
>   File "/home/mandar/web2py/gluon/html.py", line 1870, in accepts
> status = self._traverse(status,hideerror)
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/home/mandar/web2py/gluon/html.py", line 800, in _traverse
> newstatus = self._validate()
>   File "/home/mandar/web2py/gluon/html.py", line 1625, in _validate
> (value, errors) = validator(value)
>   File "/home/mandar/web2py/gluon/validators.py", line 554, in __call__
> table = self.dbset.db[tablename]
>   File "/home/mandar/web2py/gluon/dal.py", line 6877, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: 'name'
>
> Similarly, after populating mother/father and child tables via script when 
> I try to update "child" record - In the dropdown I see mother's names 
> instead of ID (as expected) but when I select different "mother" and submit 
> I get same error (traceback may be slightly different - but same 
> KeyError:'name' )
>
> What is wrong with the table definitions ?
>
> Thanks,
> -Mandar
>
>

-- 





Re: [web2py] Re: Get result set back as list?

2012-08-10 Thread Derek
works for me too.

db(db.customers).select(db.customers.name).as_list()


On Friday, August 10, 2012 3:58:08 PM UTC-7, Vasile Ermicioi wrote:
>
> for me that works
>
> alist = db(db.auth_user).select().as_list()
>

-- 





[web2py] Re: Electronic voting anybody?

2012-08-10 Thread Cliff Kachinske
On the demo, after creating an election I was redirected to the home page 
rather than to the index.  I would think the index would make more sense, 
since that is where you find the create button.

This is a cool idea, though.

On Friday, August 10, 2012 5:24:10 PM UTC-4, Massimo Di Pierro wrote:
>
> Demo service:
>
>https://tests.web2py.com/evote/default/index
>
> Source:
>
>https://github.com/mdipierro/evote
>
> I could use some help checking it. Specifically usability and security.
>
> Massimo
>

-- 





[web2py] LinkedIn documentation out-of-date?

2012-08-10 Thread Alec Taylor
Unfortunately I was unable to get login with LinkedIn working.

Here are my troubleshooting steps:
https://groups.google.com/forum/#!topic/web2py/SbnQEnXEcOg

Any ideas on how I can get login with LinkedIn working?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] Problems with restful + PUT

2012-08-10 Thread Tito Garrido
Hi Bruno,

I am not creating, I am trying to update...
The example record:

*A simple entry:*

*estadio.cod_estadio* *estadio.nome_estadio* *estadio.cidade**1**A Definir**A
Definir*

On Fri, Aug 10, 2012 at 3:25 PM, Bruno Rocha  wrote:

> Dirk posted this on web2pyslices...
>
> To PUT (=update) something, you need to call:
>
> curl -i -H "Accept: application/json" -X PUT --user user:pass -d
> "f_entry=something newest"
> http://127.0.0.1:8000/RT/default/api/entries/1.json
>
> with id=1 being an existing entry.
>
> So of course, PUT works as update... the 1.json refers to an existing
> record...
>
> If you want to create a new record you need to use POST, I think...
>
>
> On Fri, Aug 10, 2012 at 3:21 PM, Tito Garrido wrote:
>
>> Version 1.99.4 (2011-12-14 14:46:14) stableRunning on Apache/2.2.17
>> (Unix) mod_wsgi/3.3 Python/2.7.3
>>
>> On Fri, Aug 10, 2012 at 11:00 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Which web2py version?
>>>
>>>
>>> On Friday, 10 August 2012 08:39:40 UTC-5, Tito Garrido wrote:
>>>
 Same error using locals()

 :(

 On Thu, Aug 9, 2012 at 5:23 PM, Bruno Rocha  wrote:

> try to replace  return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
> with return locals()
>
> I dont know, but maybe its the problem
>
> On Wed, Aug 8, 2012 at 10:49 PM, Tito Garrido wrote:
>
>> Hi folks,
>>
>> *I have a simple table:*
>>
>> *db.define_table('estadio',
>> Field('cod_estadio','id'),
>> Field('nome_estadio'),
>> Field('cidade'),migrate=False) *
>>
>> *A simple entry:*
>>
>> *estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A
>> Definir**A Definir*
>> and using Bruno's example in web2pyslice:
>>
>>
>>1. @request.restful()
>>
>>
>>
>>
>>
>>
>>
>>2. def api():
>>3. response.view = 'generic.'+request.extension
>>4. def GET(*args,**vars):
>>5. patterns = 'auto'
>>6. parser = db.parse_as_rest(patterns,args**,vars)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>7. if parser.status == 200:
>>8. return dict(content=parser.response)
>>9. else:
>>10. raise HTTP(parser.status,parser.erro**r)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>11. def POST(table_name,**vars):
>>12. return db[table_name].validate_and_**insert(**vars)
>>13. def PUT(table_name,record_id,**var**s):
>>14. return db(db[table_name]._id==record_**id).update(**vars)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>15. def DELETE(table_name,record_id):
>>16. return db(db[table_name]._id==record_**id).delete()
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *but when I try to:*
>> *
>> curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste"
>> http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*
>>
>> *it returns:*
>>
>> HTTP/1.1 400 BAD REQUEST
>> Server: nginx
>> Date: Thu, 09 Aug 2012 01:41:44 GMT
>> Content-Type: text/html; charset=UTF-8
>> Connection: keep-alive
>> Set-Cookie: 
>> session_id_ws=xx-**65e0b712-7d93-4b21-a553-**d06ce06af2a2;
>> Path=/
>> Content-Length: 540
>>
>> invalid arguments
>>
>> *What am I missing here?
>>
>> Thanks in advance!*
>>
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>



 --

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

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



-- 

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

-- 





[web2py] Re: Get result set back as list?

2012-08-10 Thread Cliff Kachinske
I use Anthony's method because it returns a true list.

as_list() returns a list of dictionaries, and you still have to iterate 
over the dictionaries in the list to extract the values.

On Friday, August 10, 2012 4:34:01 PM UTC-4, Toby Shepard wrote:
>
>
> I'm in a situation where I just want a single column back from 
> a table.  I'd like it as a list so I could just pass it on 
> to the next function. 
>
> All I can think of is something like: 
>
> temp = [] 
>
> for thing in db(db.mytable).select(db.mytable.myfield): 
> temp.append(thing) 
>
> return temp 
>
> I was hoping for something like: 
>
> return db(db.mytable).select(db.mytable.myfield).as_list() 
>
> Or something like that. 
>
> As an aside, I have a python dbi that has four central ways to get 
> data back.  I call them: 
>
> atom()scalar as in 'select first from person where 
> id = 1' 
> row()dict as in'select * from person' where id 
> = 1' 
> column()list as in 'select first from person' 
> world()list of dict:'select * from person' 
>
> They end up being uite convenient and result in concise syntax. 
>
> Thanks, 
>
> Tobiah 
>

-- 





[web2py] Re: updating added computed fields

2012-08-10 Thread Ben
Is there a way to update all computed fields via appadmin's db interface?  


On Saturday, July 28, 2012 2:45:28 PM UTC-7, Massimo Di Pierro wrote:
>
> It depends. If it is computed based on other fields, you should do an 
> update of those fields. Else you can update it by expliticly calling the 
> update method:
>
> db.thing[id].update_record(field=db.thing.field.compute({}))
>
> On Saturday, 28 July 2012 13:40:52 UTC-5, Jonathan Lundell wrote:
>>
>> If I add a computed field to an existing table, what's a good way to get 
>> it updated? Do a dummy (no-change) update of another field?
>
>

-- 





Re: [web2py] Re: Get result set back as list?

2012-08-10 Thread Anthony
On Friday, August 10, 2012 6:58:08 PM UTC-4, Vasile Ermicioi wrote:
>
> for me that works
>
> alist = db(db.auth_user).select().as_list()
>

That returns a list of dictionaries, like [{'myfield': 'value 1'}, 
{'myfield': 'value 2}]. I assumed he was looking for a list of the 
individual field values given that it's just a single column of data.

Anthony

-- 





Re: [web2py] Init Script in Web2Py

2012-08-10 Thread Massimo Di Pierro
Yes but replace

if db(db.state.id>0).count() == 0:


with


if cache.ram('init',lambda:db(db.state.id>0).count(),None) == 0:


So that is executed once and then cached forever.

On Friday, 10 August 2012 16:57:45 UTC-5, Richard wrote:
>
> if db(db.state.id>0).count() == 0:
> db.state.truncate()
> db.city.truncate()
> db.zipcode.truncate()
> db.areacode.truncate()
> db.state.insert(name='Texas')
> db.state.insert(name='Illinois')
> db.state.insert(name='California')
>
> db.city.insert(name='Austin',state=1)
> db.city.insert(name='Dallas',state=1)
> db.city.insert(name='Chicago',state=2)
> db.city.insert(name='Aurora',state=2)
> db.city.insert(name='Los Angeles',state=3)
> db.city.insert(name='San Diego',state=3)
>
> db.zipcode.insert(value='78704',city=1)
> db.zipcode.insert(value='78745',city=1)
> db.zipcode.insert(value='75001',city=2)
> db.zipcode.insert(value='75038',city=2)
> db.zipcode.insert(value='60606',city=3)
> db.zipcode.insert(value='60607',city=3)
> db.zipcode.insert(value='60504',city=4)
> db.zipcode.insert(value='60505',city=4)
> db.zipcode.insert(value='90005',city=5)
> db.zipcode.insert(value='90006',city=5)
> db.zipcode.insert(value='92101',city=6)
> db.zipcode.insert(value='92102',city=6)
>
> db.areacode.insert(value='512',zipcode=1)
> db.areacode.insert(value='511',zipcode=1)
> db.areacode.insert(value='345',zipcode=2)
> db.areacode.insert(value='456',zipcode=2)
> db.areacode.insert(value='567',zipcode=3)
> db.areacode.insert(value='678',zipcode=3)
> db.areacode.insert(value='789',zipcode=4)
> db.areacode.insert(value='890',zipcode=4)
> db.areacode.insert(value='901',zipcode=5)
> db.areacode.insert(value='321',zipcode=5)
> db.areacode.insert(value='432',zipcode=6)
> db.areacode.insert(value='534',zipcode=6)
> db.areacode.insert(value='645',zipcode=7)
> db.areacode.insert(value='765',zipcode=7)
> db.areacode.insert(value='876',zipcode=8)
> db.areacode.insert(value='987',zipcode=8)
> db.areacode.insert(value='141',zipcode=9)
> db.areacode.insert(value='252',zipcode=9)
> db.areacode.insert(value='363',zipcode=10)
> db.areacode.insert(value='474',zipcode=10)
> db.areacode.insert(value='585',zipcode=11)
> db.areacode.insert(value='686',zipcode=11)
> db.areacode.insert(value='797',zipcode=12)
> db.areacode.insert(value='898',zipcode=12)
>
>
> You can put something like that in models somewhere.
>
> You just need to adapt for you particular table and the records you want 
> to create and verify the presence of.
>
> Just wrote the proper db request with the proper where attribute :
>
> Let's say you have create user1 in auth_user so you can write this :
>
> if db(db.auth_user.first_name = 'user1').count() != 1:
> db.auth_user.insert(first_name='user1')
>
> Hope it what you were searching for.
>
> Richard
>
> On Fri, Aug 10, 2012 at 5:56 AM, tommasot 
> > wrote:
>
>> I have a newbie question.
>>
>> I need to create some record in db on application startup,like for 
>> example default user and other things..
>>
>>
>>
>> Where is the right script/place to implement it
>>
>>
>>
>> --
>>
>>
>>
>>
>

-- 





Re: [web2py] Init Script in Web2Py

2012-08-10 Thread Anthony
On Friday, August 10, 2012 5:57:45 PM UTC-4, Richard wrote:
>
> if db(db.state.id>0).count() == 0:
>
>
FYI, now you can do:

if db(db.mytable).isempty():

Note, db(db.mytable) is equivalent to db(db.mytable.id > 0).

Anthony 

-- 





Re: [web2py] Init Script in Web2Py

2012-08-10 Thread Massimo Di Pierro
you stil want to cache that

if cache.ram('init',lambda:db(db.mytable).isempty(),None):

On Friday, 10 August 2012 21:42:09 UTC-5, Anthony wrote:
>
> On Friday, August 10, 2012 5:57:45 PM UTC-4, Richard wrote:
>>
>> if db(db.state.id>0).count() == 0:
>>
>>
> FYI, now you can do:
>
> if db(db.mytable).isempty():
>
> Note, db(db.mytable) is equivalent to db(db.mytable.id > 0).
>
> Anthony 
>

--