I've dropped my attempt to use validate_and_update_or_insert() and have 
this workaround whereby I do a search and then call either 
validate_and_update() or validate_and_insert() ...

user = [
    Storage(username="u1", password='p1', field2='field2'),
   Storage(username="u1", password='p1', field2='field2')]

for user in users:

        rows = 
db(db.auth_user.username==user.username).select(db.auth_user.ALL)
        if rows:
            row = rows[0]
            db(db.auth_user.id==row.id).validate_and_update(
                password=user.password,
                field2=user.field2)
        else:
            db.auth_user.validate_and_insert(
                username=user.username,
                password=user.password,
                field2=user.field2)



On Monday, 12 October 2015 20:08:38 UTC+1, Carl Hunter Roach wrote:
>
> I'm trying to use validate_and_update_or_insert() to update/insert users 
> into my auth_user table. 
>
> user = [
>     Storage(username="u1", password='p1', field2='field2'),
>    Storage(username="u1", password='p1', field2='field2')]
>
> for user in users:
>     res = 
> db(db.auth_user.username==user).validate_and_update_or_insert(password=user.password,
>  
> field2=user.field2)
>
> When a user is inserted all is well.
> *But when a user is to be updated then Web2py throws an exception finding 
> that "object has no attribute 'primary_key'"*
> What have I misunderstood?
>
> I can't find any documentation for validate_and_update_or_insert() but it 
> operates very similarly to validate_and_update or validate_and_insert
>
> My Auth is as follows:
> https_secure = False if isGAELocal() else True
> auth = Auth(db, secure=https_secure)
>
> The execution, above, is local and therefore over http but will be over 
> https when it goes into production. i.e. testing using dev_appserver and 
> targetting App Engine Big Table.
>

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

Reply via email to