Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegrityError when trying to access allow_lazy_user protected view #15

Open
rockyburt opened this issue Jan 31, 2012 · 3 comments
Open

Comments

@rockyburt
Copy link

I was setting up django-lazysignup 0.7.0 for the first time against a SQLite3 db. I'm running Django 1.3. I get an error when I access a view protected by allow_lazy_user. The code that hooks up allow_lazy_user is:

urlpatterns = patterns('',
    url(r'^app/(?P<slug>.*)/deploy$',
        allow_lazy_user(views.DeployView.as_view()),
        name='app_project_deploy'),
)

The error I get indicates a name collision which is practically impossible since the only user in the db is the admin user.

Traceback (most recent call last):
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
    response = self.get_response(request)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/lazysignup/decorators.py", line 33, in wrapped
    user = LazyUser.objects.create_lazy_user(username)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/lazysignup/models.py", line 29, in create_lazy_user
    user = user_class.objects.create_user(username, '')
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/contrib/auth/models.py", line 136, in create_user
    user.save(using=self._db)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/home/rocky/dev/envs/jazkarta/appsembler/env-appsembler/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
    return Database.Cursor.execute(self, query, params)
IntegrityError: column username is not unique
'''
@danfairs
Copy link
Owner

danfairs commented Feb 2, 2012

Thanks for the report - I'll try and reproduce this in the next few days.

@danfairs
Copy link
Owner

danfairs commented Feb 6, 2012

Hi Rocky,

I'm afraid I'm having trouble reproducing this with the current github master.

I've tried the following combinations:

  • Upgrading an existing site that uses 0.6.1 to the current master
  • Creating a new test site, and:
    • using the @allow_lazy_user decorator directly on a function-based view
    • using the @allow_lazy_user decorator a function-based view, applied in urls.py
    • using the @allow_lazy_user decorator directly on a class-based view in urls.py

Everything seemed to work as it should - I couldn't provoke the error.

You'll have to tell me a little more about your site, I'm afraid.

  • Does the error occur with a fresh database?
  • Are there existing lazy users? How many?
  • Which version of Django are you using?

If you can get a small test case together for me to look at, which provokes the error, that'd be fantastic - even if it's a tarball of a demo site.

@danfairs
Copy link
Owner

danfairs commented Feb 6, 2012

Incidentally, the small test site was SQLite - the larger, existing site was PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants