From: Mike Bayer Date: Thu, 22 Sep 2005 06:48:55 +0000 (+0000) Subject: more work on the types... X-Git-Tag: rel_0_1_0~624 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=024051c2d906d625b64fe8bc409fc89590e85d3c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git more work on the types... --- diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index e0860c83a3..ab441a8ea5 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -18,6 +18,14 @@ class TypeEngine(object): raise NotImplementedError() def adapt(self, typeobj): return typeobj() + def type_descriptor(self, conversion, cls = None): + t = cls or self.__class__ + for t in t.__mro__[0:-1]: + try: + return self.adapt(conversion[t]) + except KeyError, e: + pass + return self.adapt(cls or self.__class__) typeclass = property(lambda s: s.__class__) typeself = property(lambda s:s) @@ -35,6 +43,12 @@ class String(TypeEngine): self.length = length def adapt(self, typeobj): return typeobj(self.length) + def type_descriptor(self, conversion): + if self.length is None: + return super(String, self).type_descriptor(conversion, TEXT) + else: + return super(String, self).type_descriptor(conversion) + String.singleton = String(-1) class Integer(TypeEngine):