我正在尝试将此库与Django一起使用:
https://github.com/dcwatson/django-pgcrypto/
我试着把我的领域设置成这样:
username = pgcrypto.EncryptedTextField(cipher='AES', key='datekey')
这个:
^{pr2}$还有这个:
username = pgcrypto.EncryptedTextField()
在每种情况下,我在进行查询时都会收到相同的错误:
文件“/blahblahblah/python2.7/site-packages/pgcrypto/字段.py“,第221行,在as_postgresql中 参数=lhs\U参数+[自身lhs来源.cipher_key]+rhs_参数 AttributeError:“Col”对象没有属性“source”
现在我要看的是这个类:
if django.VERSION >= (1, 7):
from django.db.models.lookups import Lookup
class EncryptedLookup (Lookup):
def as_postgresql(self, qn, connection):
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
params = lhs_params + [self.lhs.source.cipher_key] + rhs_params
rhs = connection.operators[self.lookup_name] % rhs
cipher = {
'AES': 'aes',
'Blowfish': 'bf',
}[self.lhs.source.cipher_name]
return "convert_from(decrypt(dearmor(%s), %%s, '%s'), 'utf-8')%s %s" % \
(lhs, cipher, self.lhs.source.field_cast, rhs), params
for lookup_name in ('exact', 'gt', 'gte', 'lt', 'lte'):
class_name = 'EncryptedLookup_%s' % lookup_name
lookup_class = type(class_name, (EncryptedLookup,), {'lookup_name': lookup_name})
BaseEncryptedField.register_lookup(lookup_class)
它似乎在寻找lhs变量的源和密码密钥(我猜它代表左手边)。在
如何为这个lhs变量添加源?在
是否有任何配置设置可能导致此问题?在
我收到了同样的信息,并在这里提交了一份错误报告: https://github.com/dcwatson/django-pgcrypto/issues/17
相关问题 更多 >
编程相关推荐