On Friday, October 31, 2014 11:26:02 AM UTC-4, Ron McOuat wrote:
>
> Thanks Anthony, that worked. For some reason lambdas still confuse me, I
> need to work on that.
>
Note, it doesn't have to be a lambda -- you can write a separate function:
def address_format(row):
return '%s %s' % (row.street_id.name, row.avenue_id.name)
db.define_table('address', ..., format=address_format)
A lambda is just a convenient way of creating a simple function without
having to bother with the separate function definition block.
In terms of the model I didn't show all the fields, there are mid block
> addresses as well. I am thinking the best way forward is to denormalize the
> road table into the address table and put the values directly in there.
> This part of the database is very static so I could keep the road table as
> a lookup for building new intersection and mid block address table entries
> with a custom form. In the rare event a road changes name an update query
> could take care of that. That would remove the recursive database lookup.
> This is an inventory of city infrastructure - traffic signals, pedestrian
> signals at mid block, radios etc. It is currently managed by spreadsheet
> which has its own set of little horrors such as several ways to represent
> 76 Avenue spawned by people typing things in. I have a lat long value pair
> to the address table and adding some code would weed out duplicate entries
> and coordinate lookup failures would prevent entry of impossible addresses.
> It might be time to look at the GIS extensions to PostgreSQL if this
> prototype gets wings.
>
Yeah, I was thinking it might be simpler to just denormalize the road. Good
luck.
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.