First time here? Check out the FAQ!
0

oauth, create user error, pk not updated

when creating user in askbot, we need the id of the newly created user in EmailFeedSetting, called from post_save. I look in the django create user code self.save_base(), the pk is not updated after create user, so id is null in User object. This leads to error in saving EmailFeedSetting().

How does Askbot handle this? Is there another place where user pk is updated?

Thanks,

Error Log user = User.objects.create_user(username, email) File "/home/pubmedly/lib/python2.7/django/contrib/auth/models.py", line 136, in create_user user.save(using=self._db) File "/home/pubmedly/lib/python2.7/django/db/models/base.py", line 460, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update)

File "/home/pubmedly/lib/python2.7/django/db/models/base.py", line 578, in save_base [Mon Aug 13 16:49:59 2012] [error] created=(not record_exists), raw=raw, using=using)

File "/home/pubmedly/lib/python2.7/django/dispatch/dispatcher.py", line 172, in send [Mon Aug 13 16:49:59 2012] [error] response = receiver(signal=self, sender=sender, **named)

File "/home/pubmedly/.virtualenvs/django131/lib/python2.7/site-packages/askbot/models/__init__.py", line 3000, in add_missing_subscriptions instance.add_missing_askbot_subscriptions()

File "/home/pubmedly/.virtualenvs/django131/lib/python2.7/site-packages/askbot/models/__init__.py", line 1761, in user_add_missing_askbot_subscriptions feed_setting.save()

File "/home/pubmedly/.virtualenvs/django131/lib/python2.7/site-packages/askbot/models/user.py", line 323, in save super(EmailFeedSetting,self).save(args,*kwargs)

File "/home/pubmedly/lib/python2.7/django/db/models/base.py", line 460, in save [Mon Aug 13 16:49:59 2012] [error] self.save_base(using=using, force_insert=force_insert, force_update=force_update)

File "/home/pubmedly/lib/python2.7/django/db/models/base.py", line 553, in save_base [Mon Aug 13 16:49:59 2012] [error] result = manager._insert(values, return_id=update_pk, using=using)

File "/home/pubmedly/lib/python2.7/django/db/models/manager.py", line 195, in _insert [Mon Aug 13 16:49:59 2012] [error] return insert_query(self.model, values, **kwargs)

File "/home/pubmedly/lib/python2.7/django/db/models/query.py", line 1436, in insert_query [Mon Aug 13 16:49:59 2012] [error] return query.get_compiler(using=using).execute_sql(return_id)

File "/home/pubmedly/lib/python2.7/django/db/models/sql/compiler.py", line 796, in execute_sql [Mon Aug 13 16:49:59 2012] [error] cursor = super(SQLInsertCompiler, self).execute_sql(None)

File "/home/pubmedly/lib/python2.7/django/db/models/sql/compiler.py", line 738, in execute_sql [Mon Aug 13 16:49:59 2012]

File "/home/pubmedly/lib/python2.7/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute [Mon Aug 13 16:49:59 2012]

IntegrityError: null value in column "subscriber_id" violates not-null constraint

cwjacklin's avatar
11
cwjacklin
asked 2012-08-13 16:42:28 -0500
Evgeny's avatar
13.2k
Evgeny
updated 2012-08-13 20:16:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

We have a function User.add_missing_askbot_subscriptions() you can use that or create those subscriptions manually.

Note that this is an internal piece of code, can change any time.

Evgeny's avatar
13.2k
Evgeny
answered 2012-08-13 20:16:06 -0500
edit flag offensive 0 remove flag delete link

Comments

with django 1.3.1, self.features.can_return_id_from_insert is default to false. We use postgresql. Django is unable to return the pk from the inserted user, to the way to fix this is to use autocommmit.

This is obscure way to resolve it, but this worked for us. You can enable this if you have Postgresql > 8.2 by setting this in your django db settings. 'OPTIONS': {
'autocommit': True, },

cwjacklin's avatar cwjacklin (2012-08-13 22:37:05 -0500) edit
add a comment see more comments