portal_type_class: possible to overwrite methods or properties in mixin
- Loading...
Before this change, class hierarchy is like this when using mixin:
class MyClass(BaseClass, Mixin1....)
which is usually ok when classes don't override each other's
But if we want to overwrite BaseClass's method by using mixin to do more thing,
For example:
class BaseClass(object):
def test(self):
print 'base test'
class Mixin1(object):
def test(self):
super(Mixin,self).test()
print 'mixin'
I want to display 'mixin base test' when call test, but it doesn't work
since priority of how methods are resolved is from left
to right: BaseClass----->Mixin1, it only display 'base test'
So the correct way to use mixin should be in reverse order:
class MyClass(Mixin1, BaseClass)
Check out, review, and merge locally
Step 1. Fetch and check out the branch for this merge request
git fetch "https://lab.nexedi.com/xiaowu.zhang/erp5.git" "mixin" git checkout -b "xiaowu.zhang/erp5-mixin" FETCH_HEAD
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git fetch origin git checkout "origin/master" git merge --no-ff "xiaowu.zhang/erp5-mixin"
Step 4. Push the result of the merge to GitLab
git push origin "master"
Note that pushing to GitLab requires write access to this repository.
Tip: You can also checkout merge requests locally by following these guidelines.
- You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Revert this commit
This will create a new commit in order to revert the existing changes.