google-code-export / django-mptt

Automatically exported from code.google.com/p/django-mptt
Other
0 stars 0 forks source link

Hacking django's Group no more possible ? #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm trying to code something that get much inspiration from 
http://bitbucket.org/macxxx/django_hgroups/src/tip/src/django_hgroups/models.py 
to add hierarchy to Django's Group.

However, it highly depends on the concept of "register", which is no longer 
available. Since I don't want to get stuck with version 0.3 for the remaining 
days of the project, I wonder if there is a workaround to this problem or if 
the register() function can come back to the project.

Btw, if I try to

Group.__bases__ = (MPTTModel,)
setattr(Group, '__metaclass__', MPTTModelBase)

It looks like not to be working, since that when I call get_ancestors(), I get 
a "AttributeError: 'Group' object has no attribute '_tree_manager'"

Thanks,
Rémy

Original issue reported on code.google.com by remy.san...@hyperthese.net on 19 Oct 2010 at 7:54

GoogleCodeExporter commented 9 years ago
Interesting use case.

The registration is now done earlier, during class creation. That's why 
inserting the bases after class creation doesn't work.

I've added a possible workaround in this branch 
http://github.com/django-mptt/django-mptt/tree/gc77-registration-postcreation

To use it, just do

    from mptt.models import MPTTModelBase
    MPTTModelBase.register(Group, order_insertion_by='foo', ...)

Can you try that and see if it solves your problem? I haven't tested it much at 
all, I'm guessing there'll be some weird issues with it...

Original comment by craig.ds@gmail.com on 20 Oct 2010 at 11:13

GoogleCodeExporter commented 9 years ago
Closing in favour of 
[http://github.com/django-mptt/django-mptt/issues/#issue/19 GH-19]

Rémy, I'd still like your feedback, please try the branch and comment on GH-19 
with your thoughts, thanks.

One of these days Github will sort out the issues with their API and I'll 
migrate all these GC tickets to Github...

Original comment by craig.ds@gmail.com on 26 Oct 2010 at 10:57