On Fri, Jan 19, 2007 at 11:30:48AM -0500, Christoph Berendes wrote:
> >ValueError: class Table is already in the registry (other class is  
> ><class '__main__.Table'>, from the module __main__ in dyn1.py;  
> >attempted new class is <class '__main__.Table'>, from the module  
> >__main__ in dyn1.py)

   There are registries that store classes by their __name__'s. You have to
fake the __name__ in the metaclass. Thanks goodness and the SQLObject
author there is a simplified metaclass magic, so you can do

def makeTable(name):
   class Test(SQLObject):
      class sqlmeta:
         table = name

      def __classinit__(cls, new_attrs):
         cls.__name__ = name
         SQLObject.__classinit__(cls, new_attrs)

   return Test

test1 = makeTable("test1")
test2 = makeTable("test2")

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to