Re: [web2py] Re: Database design

2012-04-19 Thread Chris Rowson
h = 'form accepted' >> elif form.errors: >> response.flash = 'form has errors' >> else: >> response.flash = 'please fill out the form' >> return dict(form=form) >> >> Strange thing is though that th

Re: [web2py] Re: Database design

2012-04-18 Thread Chris Rowson
is though that the property_type field still appears on the form. Any ideas why? Thank you, Chris On Wed, Apr 18, 2012 at 3:43 PM, Chris Rowson wrote: > Thanks for confirming this for me, this did seem to be the most sensible > way to approach the problem :-) > > Chris > > &

Re: [web2py] Re: Database design

2012-04-18 Thread Chris Rowson
Thanks for confirming this for me, this did seem to be the most sensible way to approach the problem :-) Chris On Wed, Apr 18, 2012 at 1:04 AM, simon wrote: > You can do this with a single form. At the top of the controller set > readable=false, writable=false for the fields you do not want on

[web2py] Database design

2012-04-17 Thread Chris Rowson
I'm a new adopter of web2py and I'm trying to learn the framework by building a simple property site. I have two types of properties, new or old. New properties have a few core attributes, let's say name, price, location, bedrooms Old properties have the same core attributes with a few more adde

Re: [web2py] Re: Multiselect form and many-to-many relationship

2012-04-15 Thread Chris Rowson
Heh, no worries. :-) I wonder, just out of interest, is there any great performance difference between searching for records containing region.id 'x' (as below) rather than returning all rows with region.id 'x' from a junction table? Chris On Sat, Apr 14, 2012 at 11:34 PM, villas wrote: > Oops

Re: [web2py] Re: Multiselect form and many-to-many relationship

2012-04-14 Thread Chris Rowson
Thank you again David, I shall give it a go. Chris On Sat, Apr 14, 2012 at 10:29 PM, villas wrote: > Yes, it would store the ids of the regions between vertical bars, > something like this: |4|7|23|. So say you are looking for the house-types > in China (which is id = 7). It would be someth

Re: [web2py] Re: Multiselect form and many-to-many relationship

2012-04-14 Thread Chris Rowson
Hi David, Thanks for your reply. I did come across the list:reference option while trying to figure this out. I couldn't figure this out though: Say I add the following to my house-type table: Field('regions', 'list:reference region') If I generate a form using SQLFORM, it presents me with

[web2py] Multiselect form and many-to-many relationship

2012-04-14 Thread Chris Rowson
Hi all, I'm pretty new to web2py and web app development and I've spend some time trying to figure out the best way to do this. I have two tables, house-types and regions. A house-type can exist in many regions, and a region can have many house types: db.define_table( 'region', Field('na

Re: [web2py] Re: Check to establish whether or not a record exists

2011-10-10 Thread Chris Rowson
ss # do nothing > > On Oct 10, 8:22 am, Chris Rowson wrote: >> Hi list, >> >> I have a database table which looks like this: >> >> postcode_cache >> >> postcode (UNIQUE) >> lat >> lon >> nearest >> >&g

[web2py] Check to establish whether or not a record exists

2011-10-10 Thread Chris Rowson
Hi list, I have a database table which looks like this: postcode_cache postcode (UNIQUE) lat lon nearest I want to test first whether or not a record exists for 'postcode' and if a record does exist, I want to check whether the 'nearest' field contains any data. I've tr

Re: [web2py] Re: To DAL or not to DAL, that is the question!

2011-10-08 Thread Chris Rowson
Chris On Sat, Oct 8, 2011 at 4:19 PM, Massimo Di Pierro wrote: > You don't mind to write engine specific queries but who is going to > use your app will mind because the app is not going to be portable. > Almost any query an be build using the dal. > > Massimo > > On Oct 8,

Re: [web2py] Re: DAL - Selects

2011-10-08 Thread Chris Rowson
=~db.data.download) return dict(table=rows, message=postcodelist) On Sat, Oct 8, 2011 at 3:53 PM, Chris Rowson wrote: > I finally used... > >    postcodelist=[] >    closepostcodes=ukpostcodes.closest_postcodes(session.postcode, > str(session.distance)) >    for p

Re: [web2py] Re: DAL - Selects

2011-10-08 Thread Chris Rowson
x27;m still learning all this stuff :-D Chris On Sun, Oct 2, 2011 at 7:38 AM, Chris Rowson wrote: > Thanks Peter, I'll give that a try. > > Chris > > On Sep 30, 2011 8:01 PM, "Peter Etchells" > wrote: >> results=db(db.data.belongs([p[1] for p in postcodes).select() >

[web2py] To DAL or not to DAL, that is the question!

2011-10-08 Thread Chris Rowson
Call me wierd, but I'm finding it a little hard to get my head around putting together select statements using the DAL. I think I must just be having a stupid couple of weeks! I understand that using the DAL & SQLFORM etc for inserts will help protect me against SQL Injection so I'm happy to keep

Re: [web2py] Re: DAL - Selects

2011-10-01 Thread Chris Rowson
Thanks Peter, I'll give that a try. Chris On Sep 30, 2011 8:01 PM, "Peter Etchells" wrote: > results=db(db.data.belongs([p[1] for p in postcodes).select()

[web2py] DAL - Selects

2011-09-29 Thread Chris Rowson
I'm trying to learn to use the DAL. I've been reading through chapted 6 of the web2py book and I'm sorry if I missed the answer there, but here I go! A user enters his/her postcode and this is checked against an API which issues us back the 10 closest postcodes. We store the 10 closest postcodes

Re: [web2py] Re: Regex messes up web2py editor

2011-09-27 Thread Chris Rowson
I gave it a try and found that when using the 'amy' editor I can't scroll all the way to the bottom of the text. Never mind, thanks for the advice. Chris On Thu, Sep 22, 2011 at 9:55 PM, wrote: > I'll give it a go and see if it works. Thanks. > > Chris > > > > -- Sent from my HP TouchPad > ___

[web2py] Regex messes up web2py editor

2011-09-22 Thread Chris Rowson
Hi all, I've just noticed that the web2py web-based text editor can't cope with this regex requires=IS_MATCH("^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z] {0,1}[0-9][A-Za-z]{2})$"

Re: [web2py] validators

2011-09-22 Thread Chris Rowson
gt; > > On Thu, Sep 22, 2011 at 7:33 AM, Chris Rowson > wrote: >> >> Quick question, >> >> If I put my validators in the model like this: >> >>     db.data.speedtesturl.requires=IS_NOT_IN_DB(db, >> 'data.speedtesturl',error_message=&#x

[web2py] validators

2011-09-22 Thread Chris Rowson
Quick question, If I put my validators in the model like this: db.data.speedtesturl.requires=IS_NOT_IN_DB(db, 'data.speedtesturl',error_message='This speedtest URL is already in the database. Please provide another') They only seem to work if I use SQLFORM. If I create a SQLFORM and then a

Re: [web2py] xml.etree

2011-09-19 Thread Chris Rowson
I ended up with something like this: http://pastebin.com/Y9keC9tB Chris On Mon, Sep 19, 2011 at 8:42 PM, Chris Rowson wrote: > Thanks all! > > Chris > > On Mon, Sep 19, 2011 at 6:49 PM, Phyo Arkar wrote: >> I like lxml more , and check pyquery! jQuery of python at serve

Re: [web2py] xml.etree

2011-09-19 Thread Chris Rowson
Thanks all! Chris On Mon, Sep 19, 2011 at 6:49 PM, Phyo Arkar wrote: > I like lxml more , and check pyquery! jQuery of python at server side. > > On 9/20/11, Bruno Rocha wrote: >> I dont know your needs but, you can pass any XML to web2py TAG[''] helper so >> then you can use Server side DOM to

Re: [web2py] xml.etree

2011-09-19 Thread Chris Rowson
I did look at that Bruno, but some of the articles I read suggested that it is not very memory efficient? Chris On Sep 19, 2011 3:44 PM, "Bruno Rocha" wrote: > I use xml minidom and it is easier. > > http://zerp.ly/rochacbruno > Em 19/09/2011 11:40, "Chris Rowson"

Re: [web2py] xml.etree

2011-09-19 Thread Chris Rowson
o have a python parser. > > But if you can use the JSON API... much simpler. > > mic > > > 2011/9/19 Chris Rowson : >> Anybody using xml.etree? >> >> I asked this question over at the Python tutors group but it seems >> that few people there had experience o

[web2py] xml.etree

2011-09-19 Thread Chris Rowson
Anybody using xml.etree? I asked this question over at the Python tutors group but it seems that few people there had experience of it. I'm trying to access a UK postcode API at www.uk-postcodes.com to take a UK postcode and return the lat/lng of the postcode. This is what the XML looks like: htt

Re: [web2py] Re: Data stored in memory

2011-09-19 Thread Chris Rowson
; single request. Each request is handled by a new thread (from a thread > pool). > Anthony > > On Saturday, September 17, 2011 11:06:14 AM UTC-4, Massimo Di Pierro wrote: >> >> On Sep 17, 6:31 am, Chris Rowson wrote: >> > Hi folks, >> > >> > I&#

Re: [web2py] Data stored in memory

2011-09-17 Thread Chris Rowson
I had read a little about that already, but found myself a little confused as to when an object does or does not continue to refer to another object as described in reference counts. At least you've confirmed I'm on the right track. I'll go back to the books. Thank-you Chris On Sep 17, 2011 2:08

[web2py] Data stored in memory

2011-09-17 Thread Chris Rowson
Hi folks, I'm trying to get my head around what happens to data stored in memory when it isn't needed anymore. Let me give you an example. Let's say I create a function which returns a dict called 'results' populated with data from an external source each time a user registers (for instance let's

Re: [web2py] Re: Why web2py is in French by default? How can I change it?

2011-09-15 Thread Chris Rowson
I had the same problem the other day. Then it reverted itself again. Chris On Thu, Sep 15, 2011 at 12:50 PM, kenji4569 wrote: > I met exactly the same problem. My browser is set with Japanese and > has nothing to do with French settings. > > Regards, > Kenji > > On 9月15日, 午後7:10, guruyaya wrote

Re: [web2py] Re: Selecting a linked field

2011-09-13 Thread Chris Rowson
Started to rework this. Changed to an inner join (I believe!) as suggested. rows=db(db.data.provider==db.providers.id).select(db.data.lon, db.data.lat, db.providers.name) Chris On Mon, Sep 12, 2011 at 9:54 PM, Chris Rowson wrote: > Thank you both. I shall revisit, replace with a join

Re: [web2py] Re: Selecting a linked field

2011-09-12 Thread Chris Rowson
Thank you both. I shall revisit, replace with a join and put the logic into the controller rather than the view :-) Chris

[web2py] Selecting a linked field

2011-09-12 Thread Chris Rowson
I have two tables: - db.define_table('providers', Field('name'), Field('email'), Field('tel') db.define_table('data', Field('dataowner', db.auth_user, default=auth.user_id, writable=False, readable=

Re: [web2py] Re: Computing a field from the value of another field

2011-09-11 Thread Chris Rowson
Thank you everyone for the advice. Chris On Sep 11, 2011 4:47 AM, "pbreit" wrote: > Good point.

Re: [web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
Cool, Thanks Anthony! Does the onvalidation option have benefits over and above the way I've done it? Chris > Another option might be using an onvalidation function: > http://web2py.com/book/default/chapter/07#onvalidation > Anthony > > On Saturday, September 10, 2011 4:37:08 PM UTC-4, leftcase

[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
> Hi there, > > I bought the web2py .pdf, and have been reading it, but I'm struggling > a little bit with: > > http://www.web2py.com/book/default/chapter/07#SQLFORM > > Specifically the section "SQLFORM without database IO" > > I have 2 fields, lon & lat I'd like to calculated from a postcode and

[web2py] Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
Hi there, I bought the web2py .pdf, and have been reading it, but I'm struggling a little bit with: http://www.web2py.com/book/default/chapter/07#SQLFORM Specifically the section "SQLFORM without database IO" I have 2 fields, lon & lat I'd like to calculated from a postcode and enter into the d

Re: [web2py] Re: has anyone done web2py + google maps?

2011-09-10 Thread Chris Rowson
I'm a Python Web Dev noob, but I had a similar requirement. I created this function to convert a postcode into lon & lat data suitable for use in Google Maps. It's a work in progress, not very elegant, and it doesn't have any error management but it's a start. Hopefully someone on the list will be

Re: [web2py] Re: SQLFORM validator question

2011-08-31 Thread Chris Rowson
Ah cool. Thanks, Chris On Wed, Aug 31, 2011 at 10:30 PM, Anthony wrote: > CLEANUP does not actually take a list of ascii codes as an argument. > Instead, it takes a regular expression, which defaults > to '[^\x09\x0a\x0d\x20-\x7e]'. > Anthony > > On Wednesday, August 31, 2011 5:18:43 PM UTC-4,

[web2py] SQLFORM validator question

2011-08-31 Thread Chris Rowson
Hi folks, I'm having a bit of mental blank. I'm trying to create a validator in the model for a postcode entry in SQLFORM to strip all spaces and non-alphanumeric characters like this: db.data.postcode.requires=[IS_NOT_EMPTY(), CLEANUP([48-57,65-90,97-122])] I'm getting the following error: (u

Re: [web2py] Re: Storing logged on user in database

2011-08-31 Thread Chris Rowson
> Good to hear. > It's possible using auth.user_id might also fix it like that. > This is what it says in the book: > auth.user contains a copy of the db.auth_user records for the current logged > in user or None otherwise. There is also also a auth.user_id which is the > same as auth.user.id (i.e.

Re: [web2py] Re: Storing logged on user in database

2011-08-30 Thread Chris Rowson
> You could perhaps try default=auth.user_id instead. I'm not totally sure if > that behaves differently. > I don't usually use is_in_db() so can't say for sure how that might be > affecting it. > Can you provide more of the error details? I think I *might* have fixed it about the same time as you

Re: [web2py] Re: Storing logged on user in database

2011-08-30 Thread Chris Rowson
> Looks OK at a high level. Is it working for you? I thought it was until I logged in and out a couple of times and then started getting an error: "AttributeError:'NoneType' object has no attribute 'id" Noticed a discussion here: http://comments.gmane.org/gmane.comp.python.web2py/44801 Seems to

[web2py] Storing logged on user in database

2011-08-30 Thread Chris Rowson
Hi all, This is my first foray into web app design and so I wondered if it would be possible to get a bit of a sanity check on what I'm doing to ensure I'm understanding web2py correctly. My database has a table which should store data collected by SQLFORM along with the ID of the logged on user

Re: [web2py] Re: Server side form validation

2011-08-29 Thread Chris Rowson
Thanks for the rapid reply Massimo, It is much appreciated. Chris On Aug 30, 2011 12:23 AM, "Massimo Di Pierro" wrote: > Validation is always performed server side. > > if you use FORM(INPUT()) that each input gets its own > requires=[..] > > if you use SQLFORM(table) than the require