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
Implementing Abstract Models #119
Conversation
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.
Just reading this at a glance the one thing that sticks out is naming with leading underscores. This makes sense for 'quasi-protected' methods/attributes, but should be avoided for class names. Better to replace with something more descriptive.
Tests pass! I'm going to plan on merging this into a new branch instead of dev for the time being until it's a bit more solidified with doc updates as necessary. Regarding the naming issue above, that is not urgent. |
I created a new branch better-abstract-models from your PR. |
👍 |
We'll speak again on tuesday. I'm going to be busy because going to FOSDEM, so if you don't hear from me next week, you will surely hear me again the week later. |
@bennylope the classes with the leading underscores contain the base logic, just without the metaclass machinery. That base logic is then extended by the new abstract classes with the metaclass machinery on top of it. The same base logic is also used on the old base classes to maintain backward compatibility. I think there's 3 things that need to be discussed and decided:
|
In brief, I think it's totally fine if the internal meta classes are not externally documented (although should be in docstrings!). The important thing is that the names make sense and everything's backwards compatible (breaking backwards compatibility for massive improvements isn't out of the question if it's necessary and/or significantly reduces a lot of cruft, and is well documented for end users). These underscore classes are what, mediating classes? Maybe something that indicates the role of the class would be good for a name. I'm less concerned about the specific name and more that it makes sense to someone reading the code for the first time. What does a Django dev expect a base class to be named? What kind of conventions does the name imply? Is there any reason that someone using the existing base classes, e.g. |
Inside django, there is If we want to follow this convention, we should name the leading underscore classes as The current implementation is backward compatible, I did not change the behaviour of the currently documented base classes. I think changing the existing base classes can affect negatively apps already extending django-organizations. The safest option is to add the new classes, document them, deprecate the old ones, remove their mention from the docs and consider removing them if everything goes fine and no one complains after a year or two. |
@bennylope the commit db6a295 contains an implementation of the new naming proposal that follows Django's I propose to:
I can do this work if you let me know what you think. Federico Capoano |
PS: I'm reading the code but I haven't understood how to add tests for this new use case. I have taken a look at the existing dir |
Yeah, the |
@bennylope I did create How can I, for example, test only the new |
Backward compatibility is maintained See bennylope#118
@bennylope I figured out how the previous tests for custom organization apps were added and followed those examples. I also have updated the docs. Looking forward to hear your feedback. PS: i've rebased, modified and renamed a few commits in order to cleanup the pull request |
I'm hoping (!!) to have some time in the next day or two to look over, but my intent is to merge this into dev now. |
The updated docs explain how to use the new abstract models and explain the difference between the new abstract models and the old base models.
@bennylope ok great. I had to update the PR because I spotted a little but considerable mistake in the docs, I was referring to the old base models as "prefixed" with |
LGTM. Excited to see this merged. |
Followup of #118.
Consider this a work in progress. I think it will take a few weeks to complete, but I managed to get something working early, so I can try to integrate it in the project I'm working on (named OpenWISP2 btw) before trying to merging it here.
I will also write some tests for this new use case, modeling them against the existing ones.
Abstract
(would need to modifyOrgMeta
)