Permalink
Browse files

fix local variable referenced before assignment. also pass the new ma…

…x_length on so that the field in the database will be large enough to accomodate max_length + encryption overhead
  • Loading branch information...
1 parent 7e9cd05 commit 191fe006b40baecdfcee5093c9911c4c09e5c3c8 @trbs trbs committed Jul 6, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 django_extensions/db/fields/encrypted.py
@@ -21,10 +21,11 @@ def __init__(self, *args, **kwargs):
self.crypt = keyczar.Crypter.Read(settings.ENCRYPTED_FIELD_KEYS_DIR)
# Encrypted size is larger than unencrypted
- self.unencrypted_length = max_length
+ self.unencrypted_length = max_length = kwargs.get('max_length', None)
if max_length:
max_length = len(self.prefix) + \
len(self.crypt.Encrypt('x'*max_length))
+ kwargs['max_length'] = max_length
super(BaseEncryptedField, self).__init__(*args, **kwargs)
@@ -93,3 +94,4 @@ def south_field_triple(self):
args, kwargs = introspector(self)
# That's our definition!
return (field_class, args, kwargs)
+

0 comments on commit 191fe00

Please sign in to comment.