-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymorphic field queries appear to be broken by abstract classes #25
Comments
Hi, thanks for your report! I like the interesting case it presents. This is an area I want to look into as well; adding authorization hooks for backends. I've encountered some problems with django-polymorphic in Django 1.5 before, because the class hierarchy has an abstract class, and proxy model too. The basic support for it got fixed in the recent 0.4.1 release.
As workaround, I'd be thinking about something like:
You could also override |
Thanks for the quick feedback on this. I agree that the problem is in the way that polymorphic field lookup is accomplished. I don't think it's compatible at this point with abstract classes or proxy models. If I can find the time, I'll look further into it. Good to know you'd be able to manage updating! I've opened an issue on the project where we are using this package in the hopes that we'll be able to find the project budget to implement some sort of authorization hooks. I really like the idea of being able to implement authorization in a pluggable manner. My current approach is entirely to invasive and specific to the needs of our current project. |
You're welcome! Glad to know I can help. If you're able to work on this issue before I manage to address it, I'd be happy to look into that and merge it. Thanks so far for your assistance and help on improving this project. I've been looking into your fork too, this is a good inspiration for designing a good permission-based API :) |
Hi. I believe I've found a problem with the class inheritance hierarchy of this package.
I've been working with a page class derived from the
FluentPageBase
abstract class. This class provides a foreign key todjango.contrib.auth.models.Group
, and my intention was then to create a customized dispatcher and menu template tag that would filter the menu display and prevent access to pages that weren't shared with the current user.The intention here was to be able to customize
get_queryset
inCmsPageDispatcher
like so:This should then return any "normal" page types, plus all restricted page types that are either open, or shared with a group to which the current user belongs.
Unfortunately, this does not work. The method
polymorphic.query_translate.translate_polymorphic_field_path
returns an appropriately modified path that lists the full inheritance structure of my class (htmlpage__fluentpagebase__restrictedfluentpage
), but theUrlNodeManager
does not recognizehtmlpage
as a valid query field.Testing against the structure in the django-polymorphic tests where all the members of the class hierarchy are concrete works fine:
Here I can do Model2A.objects.filter(Q(Model2C___field3='a')) and it works great. I get all the Model2C instances with that value for field3.
I suspect that the problem may be in the abstract classes that are spread through this class hierarchy. Can you confirm this? If it is the case, is there any workaround available?
The text was updated successfully, but these errors were encountered: