Opened 17 years ago

Closed 16 years ago

Last modified 13 years ago

#7464 closed (fixed)

[QSRF] psycopg2 raises "can't adapt"

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: psycopg2, SafeUnicode, qsrf
Cc: digitalxero@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

Environment:

Request Method: POST
Request URL: http://www.xeroflow.com/admin/projects/project/add/
Django Version: 0.97-pre-SVN-7661
Python Version: 2.5.1
Installed Applications:
['django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.humanize',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'django.contrib.sitemaps',
 'apps.attachments',
 'apps.tasks',
 'apps.comments',
 'apps.projects',
 'apps.assetpackager',
 'websites.xeroflow']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.cache.CacheMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.doc.XViewMiddleware')

Traceback:

File "/home/andurinc/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in add_stage
  264.             new_object = manipulator.save(new_data)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/manipulators.py" in save
  109.         new_object.save()
File "/home/andurinc/lib/python2.5/site-packages/django/db/abstract_models.py" in save
  33.         super(AbstractCategory, self).save(*args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/base.py" in save
  270.         self.save_base()
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/base.py" in save_base
  332.                 result = manager._insert(values, return_id=update_pk)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/manager.py" in _insert
  118.         return insert_query(self.model, values, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/query.py" in insert_query
  735.     return query.execute_sql(return_id)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/subqueries.py" in execute_sql
  300.         cursor = super(InsertQuery, self).execute_sql(None)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/query.py" in execute_sql
  1474.         cursor.execute(sql, params)
File "/home/andurinc/lib/python2.5/site-packages/django/db/backends/util.py" in execute
  18.             return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/projects/project/add/
Exception Value: can't adapt
params = (u'Second Project', 'second-project', u'This is a second Project', u'2', u'2008-06-16 04:54:56.224657', True, u'Mercurial', u'http://changing.this.url/django/')
sql = 'INSERT INTO "projects_project" ("name", "slug", "description", "manager_id", "started", "public", "repository_type", "repository_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s)'

It seems the issues of http://code.djangoproject.com/ticket/5996 have returned with the QSRF since when I went in and manually called unicode() on each param it worked fine.

Attachments (1)

base.py.patch (986 bytes ) - added by Digitalxero@… 17 years ago.
Patch for the issue

Download all attachments as: .zip

Change History (7)

by Digitalxero@…, 17 years ago

Attachment: base.py.patch added

Patch for the issue

comment:1 by Digitalxero@…, 17 years ago

Has patch: set

Attached a patch for this issue

comment:2 by Ramiro Morales, 17 years ago

Description: modified (diff)

comment:3 by Jacob, 16 years ago

milestone: 1.0
Triage Stage: UnreviewedAccepted

Looks like we need a similar change to [6816] to adapt SafeString as well.

comment:4 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [8532]) Fixed #7464 -- Fixed the psycopg2 backend to handle SafeString values as
parameters. Based on a patch from Digitalxero@….

comment:5 by Llanilek, 16 years ago

Needs documentation: set

what base.py file does the patch need to be applied to?

comment:6 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top