[ckan-dev] Modifying user's properties with code

Rustam Mehmandarov minspamboks at gmail.com
Sat Sep 3 21:53:43 UTC 2011


Hi all,

I have a code that creates a user if it does not exists:

if user is None:
            user = User(openid=user_id,
                        name=data['name'],
                        fullname=data['name'],
                        email=data['mail'])
            Session.add(user)
            Session.commit()
            Session.remove()

But now, I also need some code that is able to update (for example)
the user's name every time I log in (the data is sent from another
system that does the authentication for CKAN). Is there some kind of
update user function in Session? Then I can do something like:

user = User(openid=user_id,
            name=data['name'],
            fullname=data['name'],
            email=data['mail'])
if user is None:
            Session.add(user)
else:
            Session.UPDATE(user)
Session.commit()
Session.remove()

Any kind of help is greatly appreciated. :)

Thanks!
Rustam




More information about the ckan-dev mailing list