Commits

Tom Willis committed 5588e0a

release for 0.5.1 removing alchemyextra dependency

  • Participants
  • Parent commits f3b0a72

Comments (0)

Files changed (4)

+0.5.1
+-----
+
+- removed alchemyextra dependency
+
+
 0.5
 ---
 
  Spazzer
 =========
 
-Spazzer is a web based music portal application. It's written in python, it runs under WSGI, it's built on top of bfg. 
+Spazzer is a web based music portal application. It's written in
+python, it runs under WSGI, it's built on top of bfg.
 
 
 
 requires = ['repoze.bfg',
             'mutagen',
             'sqlalchemy',
-            'alchemyextra',
             'zope.sqlalchemy',
             "Paste>=1.7.2",
             "PasteDeploy>=1.3.3",
             "PasteScript>=1.7.3"]
 
 setup(name = 'spazzer',
-      version = '0.5',
+      version = '0.5.1',
       description = 'spazzer',
       long_description = README + '\n\n' + CHANGES,
       classifiers = [
       [paste.paster_create_template]
       spazzer-instance = spazzer.config:InstanceTemplate
       """,
-      scripts = ["scripts/spazzer-create"]
-      )
+      scripts = ["scripts/spazzer-create"])

File spazzer/collection/model.py

 from sqlalchemy.types import Unicode, Integer, DateTime
 from sqlalchemy.sql import or_
 from meta import _s
-from alchemyextra.schema import id_column
 import os
 from cStringIO import StringIO
 import zipfile
 
+from sqlalchemy import types
+try:
+    from sqlalchemy.dialects.mysql.base import MSBinary
+except ImportError:
+    from sqlalchemy.databases.mysql import MSBinary
+
+from sqlalchemy.schema import Column
+import uuid
+
+
 Base = declarative_base()
 
 
+class UUID(types.TypeDecorator):
+    """
+    UUID column type should be compatible with MS SqlServer guid type.
+    """
+    impl = MSBinary
+
+    def __init__(self):
+        self.impl.length = 16
+        types.TypeDecorator.__init__(self, length=self.impl.length)
+
+    def process_bind_param(self, value, dialect=None):
+        if value and isinstance(value, uuid.UUID):
+            return value.bytes
+        elif value and not isinstance(value, uuid.UUID):
+            raise ValueError('value %s is not a valid uuid.UUID' % value)
+        else:
+            return None
+
+    def process_result_value(self, value, dialect=None):
+        if value:
+            return uuid.UUID(bytes=value)
+        else:
+            return None
+
+    def is_mutable(self):
+        return False
+
+id_column_name = "id"
+
+
+def id_column():
+    """
+    util method for primary key column declaration with UUID type
+    """
+    import uuid
+    return Column(id_column_name, UUID(), primary_key=True, default=uuid.uuid4)
+
+
 class Queryable(object):
     """
     adds query class method as a convenience.