Skip to content

Instantly share code, notes, and snippets.

@gcavalcante8808
Created March 19, 2012 21:11
Show Gist options
  • Save gcavalcante8808/2127138 to your computer and use it in GitHub Desktop.
Save gcavalcante8808/2127138 to your computer and use it in GitHub Desktop.
TraceBack
Environment:
Request Method: POST
Request URL: http://localhost:8000/admin/core/domaincredential/add/
Django Version: 1.4b1
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'django.contrib.admin',
'south',
'core',
'infra_structure')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in wrapper
368. return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in inner
196. return view(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "C:\Python27\lib\site-packages\django\db\transaction.py" in inner
209. return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in add_view
957. self.save_model(request, new_object, form, False)
File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in save_model
711. obj.save()
File "C:\Users\01388863189\PycharmProjects\dsim\core\models\base_dsinfo.py" in save
67. super(DomainCredential, self).save(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\base.py" in save
464. self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:\Python27\lib\site-packages\django\db\models\base.py" in save_base
552. result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "C:\Python27\lib\site-packages\django\db\models\manager.py" in _insert
203. return insert_query(self.model, objs, fields, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in insert_query
1576. return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
910. cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\util.py" in execute
40. return self.cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py" in execute
52. return self.cursor.execute(query, args)
Exception Type: DatabaseError at /admin/core/domaincredential/add/
Exception Value: ERRO: sequência de bytes é inválida para codificação "UTF8": 0x9a
class DomainCredential(models.Model):
AUTH_TYPE_CHOICES = (
('1', 'LDAPs'),
)
user = models.CharField(_(u"Usuário para Autenticação"), max_length=255, unique=True)
user_pass = models.CharField(_(u"Senha"), max_length=255)
auth_type = models.CharField(_(u"Tipo de Autenticação"), max_length=1, choices=AUTH_TYPE_CHOICES, default='1')
def get_pass(self):
k = des(b"DESCRYPT", CBC, b"\0\0\0\0\0\0\0\0", padmode=PAD_PKCS5)
return k.decrypt(self.user_pass)
def set_pass(self, user_pass):
k = des(b"DESCRYPT", CBC, b"\0\0\0\0\0\0\0\0", padmode=PAD_PKCS5)
return k.encrypt(user_pass)
def save(self, *args, **kwargs):
self.user_pass = self.set_pass(self.user_pass.encode('utf-8'))
super(DomainCredential, self).save(*args, **kwargs)
def __unicode__(self):
return self.user
class Meta:
app_label = 'core'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment