-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fixed layout issue to prevent needing to replace WidgyPage #257
Conversation
60d8a49
to
3a40a32
Compare
37fe67d
to
917cc93
Compare
@property | ||
def owner_class(self): | ||
if 'widgy.contrib.widgy_mezzanine' in settings.INSTALLED_APPS: | ||
from widgy.contrib.widgy_mezzanine.models import WidgyPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavinwahl, do I need to put a try/except here because of the potential of an ImportError?
I don't understand this owner_class thing |
In the valid_root_of method you provided, owner_class in the function only produces the widgy.contrib.widgy_mezzanine.models.WidgyPage, so it needs something to compare it to. I added in an owner_class property so it could tell the difference between a WIDGY_MEZZANINE_PAGE_MODEL and lets say a Blog model. Does that help? |
I was thinking it would look like this:
Unrelated, I'm wonder why valid_root_of returns a boolean instead of having a root_choices_for that returns a list of possible roots. |
I will try putting the necessary logic in valid_root_of. |
497100a
to
69b77c0
Compare
@gavinwahl, I think I see where you are going with this. I kept it with just what you put on google groups, then I overrided site.py in my test project to make it work. https://github.com/zmetcalf/layout_issue/blob/master/widgy_demo/site.py What do you think of adding in a setting?
|
On your example, the second line will always return |
@gavinwahl, sorry for being a mess. I updated the test project so it works now: https://github.com/zmetcalf/layout_issue/blob/master/widgy_demo/site.py |
I think @gavinwahl means doing something like this: def get_root_choices_for(self, owner_class):
if issubclass(owner_class, WidgyPage):
return ('myapp.MyBaseLayout',)
else:
return owner_class.root_node.root_choices HOWEVER, what I just realized is that we are dealing with the owner_class, which is actually breaking one of our eventual use-cases of allowing a model to have multiple WidgyFields. This method and the |
I didn't mean to close it, sorry! |
No worries, I am going to close it anyway because it looks like you all need to figure out the future of |
This should allow better control of which layouts are available for a given site. This is basically Gavin Wahl's change from #257 but passing the field instead of the model to address Rocky Meza's concern about multiple `WidgyField`s on a single model.
@gavinwahl, I took what you gave on the google groups and added in a little bit with layout. What do you think?
I have a project I tried it out on here: https://github.com/zmetcalf/layout_issue