Commits

Ian Bicking  committed 93ddc2d

Handle setting page.content to unicode objects

  • Participants
  • Parent commits efa93a2

Comments (0)

Files changed (1)

File pickywiki/db.py

 def current_user():
     users.get_current_user()
 
+class EncodingBlobProperty(db.BlobProperty):
+    encoding = 'utf8'
+    def __set__(self, obj, value):
+        if isinstance(value, unicode):
+            value = value.encode(self.encoding)
+        super(EncodingBlobProperty, self).__set__(obj, value)
+
 class Page(db.Expando):
     ## The constant name of this page:
     uuid = db.StringProperty(required=True)
     ## The title of this page:
     title = db.TextProperty()
     ## The content/payload of this page:
-    content = db.BlobProperty()
+    content = EncodingBlobProperty()
     ## The content-type, for resource/binary files:
     content_type = db.TextProperty()
     ## This is where this page comes from (used in navigation):