[web2py] How to query many to many with three fields?

2013-08-27 Thread Apple Mason
I have this many to many relationship example: db.define_table('location', Field('geom', 'geometry()')) db.define_table('item', Field('name')) db.define_table('item_location', Field('item', db.item), Field('location_one', db.location), Field('location_two', db.location)) T

[web2py] Re: How to query many to many with three fields?

2013-08-27 Thread Apple Mason
) & > (location_one.geom.st_equals(point_x_y)) & (location_two.geom. > st_equals(point_n_m))).select(db.item.ALL) > > Alex > > Am Dienstag, 27. August 2013 19:43:08 UTC+2 schrieb Apple Mason: >> >> I have this many to many relationship example: >

[web2py] Re: How to query many to many with three fields?

2013-08-27 Thread Apple Mason
7;) > > > I hope this works. > > Am Dienstag, 27. August 2013 21:51:56 UTC+2 schrieb Apple Mason: >> >> Hey Alex, >> >> Thanks for the suggestion. The problem with the query is that >> 'location_one.geom.st_equals(point_x_y)' won't work

[web2py] Help with deploying on nginx

2013-08-29 Thread Apple Mason
I keep getting 502 Bad Gateway, and I'm not sure why. I followed the Nginx deployment recipe on the website, with the following changes: /etc/uwsgi/web2py.xml: Used /var/www-data/web2py/ instead of /home/www-data/web2py/ nginx conf: server_name is my server ip (I don't have a domain name) inst

[web2py] Re: Help with deploying on nginx

2013-08-29 Thread Apple Mason
quested: 0 -- On Thursday, August 29, 2013 3:10:20 PM UTC-4, Niphlod wrote: > > what does uwsgi log show ? > > On Thursday, August 29, 2013 8:18:02 PM UTC+2, Apple Mason wrote: >> >> I keep getting 502 Bad Gateway, and I'm not sure why. I followed the >> Ngi

[web2py] How to process a custom register form?

2013-09-06 Thread Apple Mason
The default register form has too many fields, so I created a slimmed-down custom one: register.html: Username: {{=form.custom.widget.username}} Email: {{=form.custom.widget.email}} Password: {{=form.custom.widget.password}} {{=form.custom.submit}} default.py: def register(): return d

[web2py] Re: How to process a custom register form?

2013-09-06 Thread Apple Mason
_user[field].writable = > False > return dict(form=auth()) > > > Anthony > > On Friday, September 6, 2013 5:17:23 PM UTC-4, Apple Mason wrote: >> >> The default register form has too many fields, so I created a >> slimmed-down custom one: >> >> register

[web2py] Re: How to process a custom register form?

2013-09-07 Thread Apple Mason
On Friday, September 6, 2013 8:55:13 PM UTC-4, Anthony wrote: > > On Friday, September 6, 2013 7:51:54 PM UTC-4, Apple Mason wrote: > >> Oops, I do have form.custom.begin and form.custom.end. I had forgotten to >> type it here. >> >> I also wanted a custom v

[web2py] Updating the auth_user profile that also has a one-to-many field?

2013-09-09 Thread Apple Mason
I created a custom profile view so that the user can create/update his profile. Currently I have something like: models/db.py: db.define_table('images', Field('image', 'upload', requires = IS_EMPTY_OR(IS_IMAGE())) auth.settings.extra_fields['auth_user'] = [ Field('user_image', 'reference

[web2py] Re: Updating the auth_user profile that also has a one-to-many field?

2013-09-09 Thread Apple Mason
your requirements making your own > profile update/insert page, dealing with all the things you explained . > > On Monday, September 9, 2013 9:50:40 PM UTC+2, Apple Mason wrote: >> >> I created a custom profile view so that the user can create/update his >> profile. Current

[web2py] Redirect to my own 404 page through a custom error handler?

2013-09-19 Thread Apple Mason
I would like to throw a 404 when a user tries to access something that doesn't exist, like trying to access a non-existent comment by providing a comment id that doesn't exist in the database. In these cases, web2py will throw an exception and point to a ticket (ie, NoneType has no attribute 'i

[web2py] Re: Redirect to my own 404 page through a custom error handler?

2013-09-20 Thread Apple Mason
Nevermind, I think I've figured things out. Although I noticed that routes_onerror doesn't do anything if it's in the application-specific routes.py. It works if I place it in the web2py root routes.py. Is this intentional? On Friday, September 20, 2013 2:27:20 AM UTC-4, Ap

[web2py] missing 'index' in url with routes.py?

2013-10-09 Thread Apple Mason
I'm trying to shorten the url from something like: www.example.com/myapp/default/index?page=1 to www.example/com/index?page=1 I'm using pagination on the index page, so that's why you see the ?page=1 My routes.py is pretty standard: routers = dict( # base router BASE=dict( de

Re: [web2py] missing 'index' in url with routes.py?

2013-10-10 Thread Apple Mason
Thanks Jonathan, I ended just pointing the default function to a main() and from there I redirected to my index() in my controller. On Thursday, October 10, 2013 5:47:22 PM UTC-4, Jonathan Lundell wrote: > > On 9 Oct 2013, at 9:11 PM, Apple Mason > > wrote: > > I'm tr

[web2py] How to map custom code to specific user roles to determine the auth_user field?

2013-10-14 Thread Apple Mason
Suppose I have three different types of users: buyer, distributor, and reseller. All buyers, distributors, and resellers have an email, password, and ratings. Since email and password are already part of auth_user, the ratings Field will be an extra field in auth_user. To separate the user rol

[web2py] Sharing fields across different tables in models?

2014-01-08 Thread Apple Mason
If we have a table full of products, but some products use slightly different fields, how should this be represented? For example, if I sell clothing and furniture: clothing and furniture share these fields: - price - description - stock - name clothing have these special fields: - materia

[web2py] "incomplete format" error when trying to insert ids

2014-01-09 Thread Apple Mason
My many-to-many table is throwing an error every time I access that table in the admin page: incomplete format Traceback (most recent call last): File "/home/apl/Desktop/web2py/gluon/restricted.py", line 217, in restricted exec ccode in environment File "/home/apl/Desktop/web2py/applic

[web2py] Re: "incomplete format" error when trying to insert ids

2014-01-09 Thread Apple Mason
Nevermind, I figured it out. My format string was wrong. After fixing that, everything works. On Thursday, January 9, 2014 4:42:01 PM UTC-5, Apple Mason wrote: > > My many-to-many table is throwing an error every time I access that table > in the admin page: > > incomplete forma

[web2py] Is there a way to have a field in one table be computed by a field in another table?

2014-01-13 Thread Apple Mason
In the online doc on computed field, the computed fields uses a field in the current table, and not in another table. I modified the one-to-many example by adding a 'total_items' field on person. If I want 'total_items' to be the sum of all items the person currently has, and this field should

[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
in db.person, you probably want to create _after_insert and > _after_update callbacks for db.thing (see > http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks > ). > > Anthony > > On Tuesday, January 14, 2014 12:48:59

[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
I read through the link you show me. I'm using _before_delete now, since doing s.select() returns 0 rows since it's already been deleted. I'm not sure how to deal with sets in _after_delete. Here is my updated models: db.define_table('person', Field('name'),

[web2py] Re: Is there a way to have a field in one table be computed by a field in another table?

2014-01-14 Thread Apple Mason
Yeah, that thread says to use _before_delete, and it fits this use case. Can you verify if what I'm seeing about the delete is correct? The _before_delete is causing the admin panel to not delete the record for some reason. Is it a bug? I'm using web2py 2.7.4 stable On Tuesday, January 14, 201

[web2py] Multiple one-to-many join query help.

2014-01-22 Thread Apple Mason
I have the following tables: db.define_table('person', Field('name', 'string')) db.define_table('pet', Field('name', 'string'), Field('person_id', 'reference person')) db.define_table('thing', Field('name', 'string'), Field('person_id', 'reference person')) I have a person

[web2py] Re: Multiple one-to-many join query help.

2014-01-24 Thread Apple Mason
able.filter == something).select( > main_table, other_table, > left=[other_table.on(main_table.some_id == other_table.reference), > > ] > ) > > > > On Wednesday, January 22, 2014 10:24:14 PM UTC+1, Apple Mason wrote: >> >> >> I have the foll

[web2py] Form on every page?

2014-01-26 Thread Apple Mason
I have a search bar that I want to display on every page, but something is not working. Here is an example of what I have: layout.html: {{include 'default/searchbar.html'}} In default/searchbar.html: {{=form}} But web2py doesn't find the searchbar controller function. I get a

[web2py] Re: Form on every page?

2014-01-26 Thread Apple Mason
My controller default.py: def searchbar: form = SQLFORM() return (form=form) On Monday, January 27, 2014 12:03:37 AM UTC-5, Apple Mason wrote: > > I have a search bar that I want to display on every page, but something is > not working. Here is an example of wh

[web2py] Re: Form on every page?

2014-01-26 Thread Apple Mason
Oh, it's probably because the url is /index.html and not /searchform.html. In that case, how would I create a search form that is present globally in the site? On Monday, January 27, 2014 12:04:43 AM UTC-5, Apple Mason wrote: > > My controller default.py: > > def searchbar: >

[web2py] Re: Form on every page?

2014-01-27 Thread Apple Mason
On Monday, January 27, 2014 12:20:50 AM UTC-5, Apple Mason wrote: > > Oh, it's probably because the url is /index.html and not /searchform.html. > > In that case, how would I create a search form that is present globally in > the site? > > On Monday, January 27, 2014

[web2py] Re: Form on every page?

2014-01-27 Thread Apple Mason
for search). How you create the form itself in the view > depends on your needs. Do you just need a single text search field? What > does the search function do to return results? > > Anthony > > On Monday, January 27, 2014 1:02:03 PM UTC-5, Apple Mason wrote: >> &

[web2py] Re: Form on every page?

2014-01-27 Thread Apple Mason
h form making GET requests open to the public? In that > case, I don't think you need to worry about CSRF or input sanitizing. > > Anthony > > On Monday, January 27, 2014 2:16:04 PM UTC-5, Apple Mason wrote: >> >> If I manually create the raw html form and set the acti

[web2py] Querying rows over several many-to-many tables.

2014-01-28 Thread Apple Mason
I want to search across some many to many tables, but with certain conditions. db.define_table('person', Field('name', 'string'), Field('nickname', 'string')) db.define_table('clothing', Field('name', 'string')) db.define_table('item', Field('name', 'string')) db.define_table(

[web2py] Re: Querying rows over several many-to-many tables.

2014-01-29 Thread Apple Mason
d) > ) > > then, you can search it as > > what_I_want = ( > (db.person.name == 'Bob') & > > (db.item.name == 'item1') > ) > > rows = db(whole_set)(what_I_want).select() > > On Wednesday, January 29, 2014 6:29:10 AM UTC+1, A

[web2py] Re: Querying rows over several many-to-many tables.

2014-01-29 Thread Apple Mason
; (db.person.id == db.clothing_person.person_id) > ) #the reference >q = q & (db.clothing.name.belongs(clothings)) > > rows = db(q).select(db.person.ALL) > return rows > > > > > > On Wednesd

[web2py] Adding checkboxes to sqlform.factory and form validation based on another table

2014-02-05 Thread Apple Mason
If we have these simple models: db.define_table('person', Field('name', 'string')) db.define_table('common_allergies', Field('name', 'string')) The common_allergies is a table full of common allergies that people may have like 'peanuts' or 'bee stings'. This table is pre-populated by the syst

[web2py] Re: Adding checkboxes to sqlform.factory and form validation based on another table

2014-02-05 Thread Apple Mason
I forgot to highlight code samples in my last post. Sorry about that. If we have these simple models: db.define_table('person', Field('name', 'string')) db.define_table('common_allergies', Field('name', 'string')) The common_allergies is a table full of common allergies that people may