Hi All,

I've been working with the code here:

http://code.google.com/p/django-and-sqlalchemy-on-web2py/

to "port" a legacy django model to web2py.

It works fine for simple single inheritance cases, and cases where the
ancestor depth is one. However, when I try to use a user-defined
django model that inherits from another user-defined django model, I
get errors at runtime.

I suspect there is additional metaclass munging needed in
DjangoModelFactory but I'm not sure what that looks like exactly.

When I add this class PersonChoice to django.py:

    class Person(Model):
        name=CharField('Full Name',max_length=64,null=True)
        choices=ManyToManyField(Choice)

    class PersonChoice(Person):
        test = CharField('test', max_length=64, null=True)


I get:

Traceback (most recent call last):
  File "django.py", line 213, in <module>
    test_django_model()
  File "django.py", line 33, in test_django_model
    class PersonChoice(Person):
  File "/usr/lib/python2.7/site-packages/gluon/dal.py", line 4592, in
__init__
    db and db._adapter.sequence_name(tablename)
AttributeError: 'str' object has no attribute '_adapter'


And if I change the previous example to:

    class PersonChoice(Model, Person):
        test = CharField('test', max_length=64, null=True)

I get:

Traceback (most recent call last):
  File "django.py", line 213, in <module>
    test_django_model()
  File "django.py", line 33, in test_django_model
    class PersonChoice(Model, Person):
  File "django.py", line 181, in __new__
    obj = type.__new__(cls,name,bases,attrs)
TypeError: Error when calling the metaclass bases
    metaclass conflict: the metaclass of a derived class must be a
(non-strict) subclass of the metaclasses of all its bases

Does anyone know if there's a way to get the DjangoModelFactory to
handle the additional layer of inheritance?

Thanks,
David

Reply via email to