[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/tim

[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

[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)) #

[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

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

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 ha

[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 = "o

[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

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

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

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

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

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 kn

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

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

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

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

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

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 hila

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

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

[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

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

[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

[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

[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

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

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

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

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

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.

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

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

[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(th

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

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

[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

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/'+thre

[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', > >

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

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_d

[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

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 co

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

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

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:

[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) som

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

[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

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 value

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(

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