Skip to content

Commit

Permalink
Include patch for depot to allow compatibility with sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Feb 1, 2015
1 parent 7c0a2e1 commit d1ea59a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kotti/filedepot.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,20 @@ def adjust_for_engine(conn, branch):
from sqlalchemy.dialects.mysql.base import LONGBLOB
DBStoredFile.__table__.c.data.type = LONGBLOB()

# sqlite's Unicode columns return a buffer which can't be encoded by
# a json encoder. We have to convert to a unicode string so that the value
# can be saved corectly by
# :class:`depot.fields.sqlalchemy.upload.UploadedFile`

def patched_processed_result_value(self, value, dialect):
if not value:
return None
return self._upload_type.decode(unicode(value))

if conn.engine.dialect.name == 'sqlite': # pragma: no cover
from depot.fields.sqlalchemy import UploadedFileField
UploadedFileField.process_result_value = patched_processed_result_value


def includeme(config):
""" Pyramid includeme hook.
Expand Down

0 comments on commit d1ea59a

Please sign in to comment.