Hello-
I am new to Web2Py and I think I have a simple question, but I've banged my 
head on the desk for two hours and searched this forum to no avail. 

I have setup a basic database and want to give the user the ability to edit 
a series of fields using SQLFORM.grid. I also want users to be logged in 
before they can edit the fields (I'd actually prefer they can only edit 
fields they inserted, but I will come back to that later...). 

Here is my model:

db.define_table('portfolio_data',
    Field('portfolio_id'),
    Field('close_date', 'date'),
    Field('index_value'),
    Field('portfolio_value'),
    Field('cash_change'))

portfolio_id is simply a sequential number (1, 2, 3) generated when the 
user creates the new portfolio. 

I created a controller called edit, which takes an argument equal to the 
portfolio_id (so edit/1 edits rows for portfolio 1, edit/2 rows for 
portfolio 2, etc.)

@auth.requires_login()
def edit():
    # get portfolio ID from URL string
    passed_id = request.args(0)

    query = (db.portfolio_data.portfolio_id == passed_id)
    form = SQLFORM.grid(query=query)
        
    return dict(form=form)

When I try to access /default/edit/1, I get a "Not Authorized" error. If I 
set user_signature=False in the SQLFORM.grid call, then I'm able to view 
and edit the table rows without a problem. 

My diagnosis is that I have something set incorrectly in the authentication 
tables. I added a group users and gave them permission to read, update and 
select from the table db.portfolio_data, but still no luck. I'm also 
confused why I would need to do that at all, since all I'm asking for in 
the controller is a login and nothing more (i.e., I'm not restricting table 
access anywhere). (And lest anyone ask, I am definitely logged in.) 

Are there default table edit restrictions somewhere that I missed in the 
documentation? Or is there something else I need to do to get SQLFORM and 
auth to play together nicely? I'm working from the default web2py scaffold, 
so I'm surprised no one else has run into this issue. The only similar 
issue I found was 
this<https://groups.google.com/forum/?fromgroups=#!topic/web2py/t3a6KkK41zo>- I 
can't even reproduce the issue Kevin highlights in his question. 



-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to