title: SqlAlchemy UserDefinedType based on built-in type, with additional method
body: <p>I have class <code>Foo</code> which is defined as:</p>
  
  <pre><code>class Foo(object):
      def bar(self):
         pass
  </code></pre>
  
  <p>I want to extend sqlalchemy type:</p>
  
  <pre><code>class MyUnicode(Foo, sqlalchemy.Unicode):
      def bar(self):
          print "MyUnicode::bar"
  </code></pre>
  
  <p>and define table like this:</p>
  
  <pre><code>Base = declarative_base()
  class Table(Base):
     __tablename__ = "Table"
  
     first  = Column(Unicode(16))
     second = Column(MyUnicode(16))
  </code></pre>
  
  <p>Finaly, I want to be able use it as here:</p>
  
  <pre><code>t = query(Table).first()
  t.bar()
  </code></pre>
  
  <p>The problem is probably with TypeEngine, because debugger show that <code>t</code> is type of <code>unicode</code> not <code>MyUnicode</code> or even <code>sqlalchemy.Unicode</code></p>
  
  <p>I tried do this by:</p>
  
  <pre><code>class myunicode(Foo, unicode):
      def bar(self):
          print "myunicode::bar"
  
  class MyUnicode(sqlalchemy.Unicode):
  
      @property
      def python_type(self):
          return myunicode
  </code></pre>
  
  <p>but this doesn't work. Any suggestions?</p>