Ticket #7976 (closed enhancement: fixed)
Extends __classcall__ to control inheritance
| Reported by: | hivert | Owned by: | hivert |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.3.2 |
| Component: | categories | Keywords: | ClassCall, inheritance |
| Cc: | sage-combinat | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Nicolas M. Thiéry |
| Authors: | Florent Hivert | Merged in: | sage-4.3.2.alpha0 |
| Dependencies: | Stopgaps: |
Description (last modified by nthiery) (diff)
This patch extends ClasscallMetaclass so that one can control the call of a class trough two different static methods:
- __classcall__ which behaves as usual and is inherited
- __classcall_private__ which is not called by derived classes
If both exists the later is used.
By the way it does some polishing of the code.
Attachments
Change History
comment:2 follow-up: ↓ 3 Changed 3 years ago by nthiery
- Keywords ClassCall, added; ClassCall removed
- Reviewers set to Nicolas M. Thiéry
- Status changed from needs_review to needs_work
Thanks Florent, and thanks for using this occasion to cleanup my code!
Can you fix the copyright dates? Mine should be 2009, and yours 2010
I like the idea of using Python's standard convention for private attributes; on the other hand, I am a bit worried about emulating Python's mechanism. In particular, we could eventually get in trouble with the class name hacking we do for pickling:
sage: Sets.ParentMethods.__name__ 'Sets.ParentMethods'
I haven't found a way to *use* Python mechanism. So instead, what about using classcall_private, and doing the test with 'classcall_private' in cls.dict?
(I also prefer private to no_inherit).
Cheers,
comment:3 in reply to: ↑ 2 Changed 3 years ago by hivert
- Status changed from needs_work to needs_review
Replying to nthiery:
Thanks Florent, and thanks for using this occasion to cleanup my code!
Can you fix the copyright dates? Mine should be 2009, and yours 2010
[...] So instead, what about using classcall_private, and doing the test with 'classcall_private' in cls.dict?
(I also prefer private to no_inherit).
I just uploaded a new patch which addresses all these remarks... Please re-review.
comment:4 follow-up: ↓ 5 Changed 3 years ago by nthiery
- Description modified (diff)
- Milestone set to sage-4.3.2
Please double check the quick review patch, and add '#7976:' in front of the patch description, and it's good to go!
comment:5 in reply to: ↑ 4 Changed 3 years ago by hivert
- Status changed from needs_review to positive_review

