Hi,

I want to be able to use MySQL's AES_ENCRYPT function on some of my SQLObjects, but I can't find any information on whether this is possible.

I have tried using the sqlbuilder func funtion to achieve this but haven't had any look so far:

model.py:
class EncryptionTest(SQLObject):
   clearStr = StringCol(length=50)
   encStr = BLOBCol()

I then tried the following in the tg-admin shell:
>>> ts = EncryptionTest( clearStr="some text", encStr=None )
>>> ts.encStr = func.AES_ENCRYPT( ts.clearStr, 'salt' )
Traceback (most recent call last):
 File "<console>", line 1, in ?
 File "<string>", line 1, in <lambda>
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/main.py", line 1031, in _SO_setValue
   dbValue = from_python(value, self._SO_validatorState)
File "/usr/lib/python2.4/site-packages/FormEncode-0.2.3dev_r1104-py2.4.egg/formencode/compound.py", line 57, in from_python
   from_python)
File "/usr/lib/python2.4/site-packages/FormEncode-0.2.3dev_r1104-py2.4.egg/formencode/compound.py", line 104, in attempt_convert
   value = validate(validator, value, state)
File "/usr/lib/python2.4/site-packages/FormEncode-0.2.3dev_r1104-py2.4.egg/formencode/compound.py", line 14, in from_python
   return validator.from_python(value, state)
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/col.py", line 1050, in from_python
   binary = state.soObject._connection.createBinary(value)
File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/dbconnection.py", line 546, in createBinary
   return self.module.Binary(value)
File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 61, in Binary
   return array('c', x)
TypeError: iteration over non-sequence


Could anyone give me any pointers where this is going wrong? Am I trying to do something that isn't supported, or am I just going wrong with syntax somewhere?

Thanks,

Tim

Reply via email to