[web2py] Re: Get the ID of the just inserted row

2011-12-23 Thread lyn2py
Use form.vars.id to get the id of the new record inserted More about it here: http://web2py.com/books/default/chapter/29/7#SQLFORM (search form.vars.id to get to the paragraph concerned) On Dec 23, 3:01 pm, Thomas Dall'Agnese wrote: > Hi, > > Let say I have 2 tables: > > db.define_table('post',

Re: [web2py] Re: Get the ID of the just inserted row

2011-12-23 Thread Thomas Dall'Agnese
Thanks for your prompt response. Best Regards, Thomas Sent from Android On Dec 23, 2011 5:02 PM, "lyn2py" wrote: > Use form.vars.id to get the id of the new record inserted > > More about it here: > http://web2py.com/books/default/chapter/29/7#SQLFORM > (search form.vars.id to get to the parag

[web2py] Re: Development of the Framework

2011-12-23 Thread Simon Lukell
I also did Python first, web second and was fortunate enough to have the time to compare pretty much every single framework out there. The main reasons web2py is my preferred framework: - it is lean and easy to understand 'all the way down' - this means you are not forced into doing anything the

Re: [web2py] Re: ssl certificate?

2011-12-23 Thread nils
Hi, Ive used go daddy, works perfect for me and they are cheap Regards, Nils On Dec 23, 2011 4:49 a.m., "guruyaya" wrote: > I've used it myself, but note this certificate is not insured in any > way, and it allows a pretty weak protection, in the free edition. It > also fails to work with wg

Re: [web2py] web2py sitting behind load balancer showing lb IP not client IP

2011-12-23 Thread nils
Hi, what load balancer are you using? Regards, Nils On Dec 23, 2011 5:17 a.m., "Dave" wrote: > Since I've moved my installation behind a load balancer all my session > IP addresses show as the back-side IP of the load balancer, not the > real client IP. > > Have any of you figured out a way to pu

[web2py] format parameter not working?

2011-12-23 Thread Thomas Dall'Agnese
Hi, I set the format of a table to a given field, and reference it in another table. Unfortunately, the format seems to be ignored and instead of a combobox there is a textfield where I can input manually the id of the referenced table. I am using the trunk version. Do I need to set up anything

[web2py] Re: ssl certificate?

2011-12-23 Thread LightDot
What do you mean by "it's not insured"? Do you refer to the sign up checks or to the lack of actual insurance provided by some insurance company? As I see it, the sign up process is not much different than with any other budget certificate issuer. The difference is only the price. Regards On F

[web2py] best way to create a cert for web2py server?

2011-12-23 Thread António Ramos
hello i´m having some errors with a cert i created with openssl i have a lot of SSL3_READ_BYTES: tlsv1 alert unknown ca I dont know if this is a problem. The users connect with no problem to we2py but it hapens 2 or 3 times a week that i have to restart web2py because no one can access it. I

Re: [web2py] How do I aggregate accounts using OAuth & web2py?

2011-12-23 Thread Matthew
Thank you, Mic!

[web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Thomas Dall'Agnese
Hi, Is it possible to get the ID of a row in a virtual field? I tried the following piece of code to virtually get the number of comments of a given post (assuming two tables "post" and "comment" where a "comment" entry can have a "post", so a post as many comments): db.post.virtual_comments_nb

[web2py] Re: Get the ID of the just inserted row

2011-12-23 Thread Anthony
You have two options -- you can let the .process() method handle the insert, in which case the record id will be in form.vars.id after that, or you can do the insert manually, in which case the id will be returned by the .insert() method (i.e., id = db.post.insert(**dict(form.vars))). Note, I d

[web2py] Re: format parameter not working?

2011-12-23 Thread Anthony
Can you show your code? On Friday, December 23, 2011 6:08:25 AM UTC-5, Thomas Dall'Agnese wrote: > > Hi, > > I set the format of a table to a given field, and reference it in another > table. > Unfortunately, the format seems to be ignored and instead of a combobox > there is a textfield where I

[web2py] Re: Get the ID of the just inserted row

2011-12-23 Thread Thomas Dall'Agnese
Hi Anthony, Thanks for your answer. I used the form.vars.id way. And indeed, I had to change my process because the form.process().acceptedwas false after doing a form.validate(). So I changed the form.validate() with form.process().accepted and delete the inserted post if an exception is rais

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Marin Pranjić
Instead of row.id, try: row.post.id :-) Marin On Fri, Dec 23, 2011 at 2:34 PM, Thomas Dall'Agnese < thomas.dallagn...@gmail.com> wrote: > Hi, > > Is it possible to get the ID of a row in a virtual field? > > I tried the following piece of code to virtually get the number of > comments of a give

Re: [web2py] Routes help for wordpress style urls

2011-12-23 Thread Anthony
> > No. The problem is that the router doesn't introspect the controller, and > it doesn't know what its function names are. So it assumes that 2011 is a > function in the default controller. > > For this to work, it's necessary to provide the router with a list of > valid functions in the defa

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Thomas Dall'Agnese
It works, thanks! In the examples, they can call directly row.field_name. Why do I have to specify the table name as well in my case? (row.tablename.fieldbame) Is it a mistake in the book or is my case different than the examples? Book example: http://www.web2py.com/book/default/chapter/06#New

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Thomas Dall'Agnese
Another question: the virtual field is not displayed in the SQLTABLE() html rendering but is correctly displayed in the JSON rendering, is it normal?

[web2py] Re: newbie: How to match REST URL and extract path params

2011-12-23 Thread Anthony
All the elements of the URL after the controller and function are request.args (except the query string, of course). You could have a function called company(), and then companyid and storeid would be in request.args(0) and request.args(2), respectively. Or you might want a more general functio

[web2py] Re: format parameter not working?

2011-12-23 Thread Thomas Dall'Agnese
Sure. db.define_table('comment', Field('user', type='reference auth_user', label=T('User')), Field('date_added', type='datetime', label=T('Date Added')), Field('error_type', type='reference error_type', label=T('Error Type')), Field('balise', type='ref

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
I am guessing from the lack of responses this is not possible with Web2py's current admin? On Wed, Dec 21, 2011 at 4:49 PM, Bruce Wade wrote: > Hello, I know django has this ability so I am assuming web2py also does. > (Here is to hoping :D) > > First the models: > db.define_table('adreports', >

Re: [web2py] Re: ssl certificate?

2011-12-23 Thread Angelo Compagnucci
I used it in production, it not differs from any other certification. Startssl CA is included in all modern browsers and operating system, so the certs they issues are valid ones. 2011/12/23 LightDot > What do you mean by "it's not insured"? Do you refer to the sign up checks > or to the lack of

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Richard Vézina
Maybe an error in the book... Table_name has to be present for disambiguation in case there the same field name is present in many table... Imagine you use viritual field in the context of a join where your other table having the same field name is joint into that request... Richard On Fri, Dec 2

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Alvaro Lizama Molina
The web2py admin works diferently to the django admin. The web2py admin is for install apps and manage instances. 2011/12/23 Bruce Wade > I am guessing from the lack of responses this is not possible with > Web2py's current admin? > > > On Wed, Dec 21, 2011 at 4:49 PM, Bruce Wade wrote: > >> H

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Thomas Dall'Agnese
I see, thanks for your explanation. Cheers, Thomas On Sat, Dec 24, 2011 at 12:06 AM, Richard Vézina < ml.richard.vez...@gmail.com> wrote: > Maybe an error in the book... Table_name has to be present for > disambiguation in case there the same field name is present in many > table... Imagine yo

Re: [web2py] Get the ID of a row in a virtual field?

2011-12-23 Thread Richard Vézina
I think that SQLTABLE need you to specify the columns you want to expose... So it should need that you specify the virtual field in the "columns=" parameter under that format tablename.fieldname. I read also that columns will be replace by fields so have a look to the doc about that... Richard On

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
I understand that, but you can also use the database portion to create new data. That is mainly the part I am talking about. When clicking database then insert in a table, it would be nice if the relationships could be linked on that insert. This would make performing inserts more efficiently. An

[web2py] Parsing of username field during register

2011-12-23 Thread greenguerilla
Hi, I noticed something strange when testing the registration of users. If I attempt to register as user: 'My Name' (note the space), the form validation passes and I get an 'email sent' message. What actually happens though, is the the username gets inserted into the db as 'my'. I'm fine with th

Re: [web2py] best way to create a cert for web2py server?

2011-12-23 Thread Richard Vézina
You can have a look into the web2py/scripts folder. There is web2py setup scripts for different distros... You maybe read the command related to SSL certificate creation and configuration with web2py and try to do the same thing manually... Or you can just use the setup script... I never have probl

[web2py] Re: format parameter not working?

2011-12-23 Thread Anthony
In order for the validators for a reference field to be created automatically, I think the referenced tables have to be defined first (otherwise the validators cannot be defined because they refer to the referenced table). So, try defining db.comment after the other tables that it references.

Re: [web2py] Re: format parameter not working?

2011-12-23 Thread Thomas Dall'Agnese
Correct! It works now, thanks! [image: Screenshot at 2011-12-24 00:29:10.png] Best Regards, Thomas On Sat, Dec 24, 2011 at 12:26 AM, Anthony wrote: > In order for the validators for a reference field to be created > automatically, I think the referenced tables have to be defined first > (ot

[web2py] Re: Many-to-many admin form

2011-12-23 Thread DenesL
On Dec 23, 10:11 am, Bruce Wade wrote: > Anyway which files should I start looking at to see how I can implement > this functionality for myself and anyone else who wants it? Look for controller appadmin under your or any other app folder.

Re: [web2py] Routes help for wordpress style urls

2011-12-23 Thread Jonathan Lundell
On Dec 23, 2011, at 6:04 AM, Anthony wrote: > No. The problem is that the router doesn't introspect the controller, and it > doesn't know what its function names are. So it assumes that 2011 is a > function in the default controller. > > For this to work, it's necessary to provide the router wi

[web2py] Re: Parsing of username field during register

2011-12-23 Thread Anthony
By default, the 'username' field gets the following validators: (IS_MATCH('[\w\.\-]+'), IS_NOT_IN_DB(db, table.username)) The IS_MATCH is doing the truncating. Actually, I think that's a bug -- IS_MATCH isn't supposed to transform the input, only check the regex pattern. For now, though, I supp

[web2py] Re: Parsing of username field during register

2011-12-23 Thread DenesL
IS_MATCH is using the default strict=False parameter in this case, so it returns the part that matches. Using strict=True it won't match: >>> IS_MATCH('[\w\.\-]+', strict=True)('my name') ('my name', 'invalid expression') Anyways, userids are not supposed to have blanks. On Dec 23, 10:46 am,

[web2py] Re: best way to create a cert for web2py server?

2011-12-23 Thread Mirek Zvolský
Here good article, how to create certificates itselves, better than selfsigned: http://www.garex.net/apache Or StartSSL.

[web2py] Re: How to make a function to download a file?

2011-12-23 Thread DenesL
Look at the code samples under http://web2py.com/books/default/chapter/29/10#CSV On Dec 22, 10:09 pm, thstart wrote: > I want the visitors to be able to download a CSV file. > > here is my code: > def download(): >         response.headers['Content-Type'] = 'text/csv' >         attachment = 'at

Re: [web2py] Routes help for wordpress style urls

2011-12-23 Thread Joseph Jude
routers = dict( BASE = dict(default_application = 'init', default_controller = 'default', default_function = 'index', functions = ['index'], ), ) With the above routes, admin doesn't work. i.e: localhost:8080/admin/index throws a password pg but after that the control goes to /admin/site and it

[web2py] Re: How to make smartgrid redirect to edit after creating new record?

2011-12-23 Thread Cliff
Hmm... doesn't seem to work. Controller below. As you can see, I've solved the puzzle to my satisfaction, but I would like to know why the call to oncreate misfires. def handle_create(form): # never happens print 'hello, world' def index(): fields = [db.owner.name, db.dog.id] db

[web2py] Re: ssl certificate?

2011-12-23 Thread Massimo Di Pierro
I have bought a certificate from GKG.net sine I have tried some of the other suggested solutions and asked lots of questions and the process was very convoluted. Eventually got stuck because web2py.com does not run an email server and I could not verify ownership. Since I bought the domain from GKG

Re: [web2py] Routes help for wordpress style urls

2011-12-23 Thread Jonathan Lundell
On Dec 23, 2011, at 9:14 AM, Joseph Jude wrote: > routers = dict( > BASE= dict(default_application = 'init', > default_controller = 'default', > default_function = 'index', > functions = ['index'], > ), > ) > > With the above routes, admin doesn

Re: [web2py] Routes help for wordpress style urls

2011-12-23 Thread Anthony
On Friday, December 23, 2011 12:14:32 PM UTC-5, Joseph Jude wrote: > > routers = dict( > BASE = dict(default_application = 'init', > default_controller = 'default', > default_function = 'index', > functions = ['index'], > ), > ) > > With the above routes, admin doesn't work. i.e: localhost:8080/a

[web2py] Re: How to make smartgrid redirect to edit after creating new record?

2011-12-23 Thread Adi
this works: grid=SQLFORM.smartgrid(db.purchase_order, details=False, links_in_grid=True, maxtextlengths={'purchase_order.po_number':15,}, maxtextlength=30, paginate=20, sortable=True,

[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-23 Thread Dave
I can't make changes to the load balancer. The x-forwarded-for is populated but I can not change the config so the source up is kept the same. If I could, that would have been my first choice. The network between the lb and web server isn't routed so the ip source must be the local LAN RFC1018 add

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Cliff
Bruce, you are more brave than me ;) I always like to get the parent record committed in the database before adding child records. that way you know the ID of the parent record and it has the minimal required fieldset safely saved away. If there's a session interruption you don't have some poten

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Bruce Wade
I have solved these kinds of concerns with pyramid based applications using sqlalchemy. However I need to look into the core of how Web2py handles things to figure out the best way. Sqlachemy allows you to put everything in: 1) Transactions 2) Sessions So on submit you first create the parent rec

Re: [web2py] Re: Many-to-many admin form

2011-12-23 Thread Anthony
web2py wraps each request in a single transaction by default, so if you make multiple inserts during a request and the request ultimately fails due to an error, the inserts should be rolled back automatically. See http://web2py.com/books/default/chapter/29/4#Workflow and http://web2py.com/books

[web2py] Re: How to make smartgrid redirect to edit after creating new record?

2011-12-23 Thread Cliff
Adi, Is this 1.99.4? Is your controller named 'purchase_order'? Thanks, Cliff On Dec 23, 12:44 pm, Adi wrote: > this works: > >     grid=SQLFORM.smartgrid(db.purchase_order, details=False, > links_in_grid=True, >                         maxtextlengths={'purchase_order.po_number':15,}, >      

[web2py] question about onvalidation function

2011-12-23 Thread Richard
Hello, In the book there is this example : db.define_table('numbers', Field('a', 'integer'), Field('b', 'integer'), Field('c', 'integer', readable=False, writable=False)) def my_form_processing(form): c = form.vars.a * form.vars.b if c < 0: form.errors.b = 'a*b cannot

[web2py] Re: How to make smartgrid redirect to edit after creating new record?

2011-12-23 Thread Adi
Hi Cliff, No. The name of the controller is "default", but the table, on which smartgrid is operating is called "purchase_order". Yes, it is the latest version. 1.99.4

[web2py] Re: How to make smartgrid redirect to edit after creating new record?

2011-12-23 Thread Adi
Hi Cliff, No. The name of the controller is "default", but the table, on which smartgrid is operating is called "purchase_order". Yes, it is the latest version. 1.99.4

[web2py] Re: question about onvalidation function

2011-12-23 Thread Massimo Di Pierro
onvalidation = my_form_processing registers a callback (called after validation and before accepting). This does not work def my_form_processing(table_name, form):     form.vars.field1 = table_name # I know useless, it just because the callback function must take a single parameter, the form. Yo

Re: [web2py] Re: question about onvalidation function

2011-12-23 Thread Richard Vézina
Thanks for explanation... But I am unable to do what you explain because I try to make a kind of virtual table to form submission... So I need the "virtual table name" I pass by request.args(0) to access some dict that I build to make my virtual table to work... May I request "request.args(0)" fo

[web2py] Re: new book now available in HTML (english, japanese, italian)

2011-12-23 Thread Brian M
Looking good Massimo - thank you so much for making the book available online! I did come across one bug: http://web2py.com/books/default/reference/29/ReportLab results in "invalid function (default/reference)"

[web2py] Re: new book now available in HTML (english, japanese, italian)

2011-12-23 Thread Massimo Di Pierro
That URL does not exist, is there a link to it somewhere? On Dec 23, 3:46 pm, Brian M wrote: > Looking good Massimo - thank you so much for making the book available > online! > > I did come across one bug: > > http://web2py.com/books/default/reference/29/ReportLabresults in "invalid > function (

Re: [web2py] Edit / Update Database

2011-12-23 Thread Richard Vézina
I think what you try to do is a kind of bulk insert or bulk update... I write my own bulk update function with a SQLTABLE table displaying the rows that will be update and a SQLFORM.factory form for handling the submission... Then you just manually process records base on the id of the rows you ha

[web2py] Edit / Update Database

2011-12-23 Thread Anthony
Have you seen http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables?

Re: [web2py] Re: question about onvalidation function

2011-12-23 Thread Anthony
If my_form_processing is defined in your controller or a model, it should have access to the request object.

[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-23 Thread pbreit
What web server are you running? On Nginx there's a module to take the x-forwarded-for and make it the client ip. http://wiki.nginx.org/HttpRealIpModule

[web2py] Re: best way to create a cert for web2py server?

2011-12-23 Thread pbreit
If you create your own cert with OpenSSL, many or most browsers are going to warn the user that it's not a "real" cert. You can get an SSL cert from most domain registers or hosting companies (ie, GoDaddy, NameCheap, Enom, etc). Also, there is one free provider: http://www.startssl.com/?app=1

Re: [web2py] Re: best way to create a cert for web2py server?

2011-12-23 Thread Michele Comitini
If you want to create your own certs with your own ca you can use this simple web2py app: https://simpatica.googlecode.com mic 2011/12/24 pbreit : > If you create your own cert with OpenSSL, many or most browsers are going to > warn the user that it's not a "real" cert. > > You can get an SSL c

[web2py] Re: Edit / Update Database

2011-12-23 Thread lyn2py
You are right there's no easy way to do it. Turns out to stick with SQLFORM instead. SQLFORM.factory for inserts are great, but not updates. Thanks Richard! On Dec 24, 6:30 am, Richard Vézina wrote: > I think what you try to do is a kind of bulk insert or bulk update... > > I write my own bulk

[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the ad1 table from appadmin, a message is displayed "Invalid Query 'name'" and the table isn't displayed. No exceptions or tickets are generated. If I comment out the virtual field, it works fine. What is wrong in my virtual field definition below? geo.define_table('country'

[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the ad1 table from appadmin, a message is displayed "Invalid Query 'name'" and the table isn't displayed. No exceptions or tickets are generated. If I comment out the virtual field, it works fine. What is wrong in my virtual field definition below? geo.define_table('country'

[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the ad1 table from appadmin, a message is displayed "Invalid Query 'name'" and the table isn't displayed. No exceptions or tickets are generated. If I comment out the virtual field, it works fine. What is wrong in my virtual field definition below? geo.define_table('country'

[web2py] Re: Many-to-many admin form

2011-12-23 Thread Vincent
This something I would definitely be interested in seeing, as well as input forms for many-to-many in general (not just admin). Thanks Vincent On Dec 23, 12:50 pm, Anthony wrote: > web2py wraps each request in a single transaction by default, so if you > make multiple inserts during a request an

[web2py] Janrain auth not working

2011-12-23 Thread Chux
Just downloaded and installed web2py version 1.99.4 (2011-12-14 14:4614) .. I created a new app, and Janrain auth was enabled as standard, but required creating a private/janrain.key file, and inserting the ID within .. Later had to add the domain upon seeing errors .. So, now in that file, I ha

[web2py] Re: Janrain auth not working

2011-12-23 Thread Chux
This seems even more significant than I realized .. It seems after getting in by manually editing the URL, after janrain auth, I am unable to use the admin application .. it now claims, admin interface is disabled because password file was not found. I have now disabled janrain by deleting the

Re: [web2py] Web2Py on Kubuntu 11.10

2011-12-23 Thread Miroslav Gojic
This is very nice, I was presently surprise when during setup my system when I discovered package web2py. Thanks for link, I will make update of my web2py... Regards - - Miroslav Gojic - - 2011/12/23 José Luis Redrejo Rodríguez > > > 2011/12/22 miroslavgojic > >> Today I make installation

Re: [web2py] Re: Janrain auth not working

2011-12-23 Thread Marin Pranjić
Do you have parameters_81.py file in web2py folder? On Sat, Dec 24, 2011 at 5:01 AM, Chux wrote: > This seems even more significant than I realized .. > > It seems after getting in by manually editing the URL, after janrain auth, > I am unable to use the admin application .. it now claims, admin