I see my problem was a simple syntax error.
== not =
Yes it is working like that. Thank you Massimo!
On Saturday, January 18, 2014 12:50:07 PM UTC-6, David wrote:
>
> Hi Massimo,
>
> This is where I was having problems. I tried what you posted.
>
> @auth.requires_login()
> def edit_rigs():
> form = SQLFORM.grid(db.rig.user_id = auth.user.id,
> user_signature=False)
> return dict(form=form)
>
>
> I get a "Keyword can't be expression error" on this. That's where I am
> getting confused.
>
>
>
>
>
> On Saturday, January 18, 2014 12:35:01 PM UTC-6, Massimo Di Pierro wrote:
>>
>> replace
>>
>> form = SQLFORM.grid(db.rig, user_signature=False)
>>
>> with
>>
>> form = SQLFORM.grid(db.rig.user_id = auth.user.id,
>> user_signature=False)
>>
>>
>> On Saturday, 18 January 2014 10:42:38 UTC-6, David wrote:
>>>
>>> Hey guys,
>>>
>>> It's been a while since I used web2py and I've pretty much forgotten
>>> everything. Try as I might for the last two days I can't quite figure this
>>> out.
>>>
>>> I used a web2pyslice to create a main application which manages
>>> authentication. I have another app referencing main to
>>> login/logout/register etc. It works great.
>>>
>>> I'm having troubles understanding SQLFORM queries. The problem I'm
>>> having is using SQLFORM to select records only for a specific auth.user_id.
>>> I can't seem to figure out how it wants to be handled. I get all kinds of
>>> error messages while trying to perform this so I will just post my code
>>> that works and hopefully can advise on how I would select records
>>> pertaining to the user that created them.
>>>
>>>
>>>
>>> db.define_table(
>>> 'rig',
>>> Field('user_id', default=auth.user_id, readable=False,
>>> writable=False),
>>> Field('name'),
>>> Field('ipaddress'),
>>> Field('port'),
>>> format = '%s(name)s')
>>>
>>> @auth.requires_login()
>>> def edit_rigs():
>>> form = SQLFORM.grid(db.rig, user_signature=False)
>>> return dict(form=form)
>>>
>>> This returns all entries for all users. I only want the current logged
>>> in user to see his/her own records.
>>>
>>> Thank you for any help.
>>>
>>>
--
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/groups/opt_out.