I'm actually not sure how to set break points.  I'm using Eclipse so
I'm sure there's a way but while I'm educating myself.  Here's all you
should need to know if the above isn't descriptive enough.

In db.py:
auth = Auth(globals(),db)           # authentication/authorization
auth.define_tables()                # creates all needed tables


Using Appadmin
-Add a user to auth_users
-Create group 'admin' in auth_groups
-Make the user a member of admin in auth_memberships

In the application:
def add():
    """
    Debug Function
    """
    group=db(db.auth_group.role=='admin').select()[0]
    auth.add_permission(group.id,'access','mystuff')
    auth.add_permission(group.id,'access','myotherstuff')
    redirect(URL(request.application,request.controller,'index'))

Call /application/controller/add
In appadmin view the auth_permissions table.
You should see two entries
one with the group.id for Admin, access, and table of 'mystuff'.
one with the group.id for Admin, access, and table of 'myotherstuff'.

Instead you'll get the above error and only "mystuff" is added to the
auth_permissions.
You can comment out either line and add them one at a time with no
errors.  In fact you can add the same permission several times and
you'll see duplicate enteries.  You can not however, have both of the
above added in a single function call.  This use to work but no longer
does.  When I get some time maybe I can test which revision broke this
but my guess is it's 650:7c531beb7820 with comment
"self._last_reference, thanks Dave".

Sorry I'm not more help. Wish I could just patch this but I'm still
learning python/web2py and this one's a bit above me.


On Jun 29, 3:01 pm, Yarko Tymciurak <[email protected]>
wrote:
> can you give a complete example necessary to reproduce?
>
> Alternatively, you can debug yourself:  set a breakpoint at gluon/
> tools.py::Auth:add_permission()
>
> and analyze what's going on...
>
> - Yarko
>
> On Jun 29, 2:13 pm, Chris S <[email protected]> wrote:
>
> > Crap that should read:
>
> > To reproduce:
> > def test():
> >     auth.add_permission(id,'name','table1')
> >     auth.add_permission(id,'name','table2')
> > return
>
> > I'm trying to assign two different permissions to the same group in a
> > single function to get the error.
>
> > On Jun 29, 2:11 pm, Chris S <[email protected]> wrote:
>
> > > Actually, that's not exactly what's happening.
>
> > > The error is produced when trying to make two calls back to back to
> > > auth.add_permission().
> > > Single calls still create duplicate enteries but back to back calls
> > > error on the 2nd call never creating an entry.
>
> > > To reproduce:
> > > def test():
> > >     auth.add_permission(id,'name','table1')
> > >     auth.add_permission(id,'name','table1')
> > > return
>
> > > Either one of the above can be run by itself, but both in the same
> > > controller will fail with the above error on the 2nd permission.
>
> > > On Jun 29, 1:35 pm, Chris S <[email protected]> wrote:
>
> > > > I think the most recent update to trunk I've found a spot in sql.py
> > > > where functionality is different though it might be intended.
>
> > > > In the last stable release you could make a call:
> > > > auth.add_permission(group.id,'name','table_name')
>
> > > > You could do this with out first checking for it's existence already.
> > > > A new entry was created and no errors thrown.
> > > > Now if you try to do the above call and that same permission is
> > > > already defined you get:
> > > > ----------New Error------------
> > > > raise SyntaxError, 'Object exists and cannot be redefined: %s' % key
> > > > SyntaxError: Object exists and cannot be redefined: _last_reference
> > > > ----------/New Error------------
>
> > > > While it's good that this points out that I wasn't checking for these
> > > > permissions before, it's bad that you find out by an error which
> > > > didn't previously exist.
>
> > > > I can wrap my add_permission calls in a try: block, or i could check
> > > > for the permission before adding.  But is that something that should
> > > > just be included in web2py by default?  It's how I assumed it worked
> > > > originally :)
>
>

Reply via email to