Merge lp:~divmod-dev/divmod.org/811792-different-metadata-approach into lp:divmod.org

Proposed by Tristan Seligmann
Status: Merged
Approved by: Jean-Paul Calderone
Approved revision: 2677
Merged at revision: 2682
Proposed branch: lp:~divmod-dev/divmod.org/811792-different-metadata-approach
Merge into: lp:divmod.org
Diff against target: 69 lines (+13/-23)
1 file modified
Nevow/formless/annotate.py (+13/-23)
To merge this branch: bzr merge lp:~divmod-dev/divmod.org/811792-different-metadata-approach
Reviewer Review Type Date Requested Status
Jean-Paul Calderone Approve
Review via email: mp+70655@code.launchpad.net

Description of the change

This just fixes the zope.interface / TypedInterface incompatibility, in contrast to my other branch removing all of formless. It turns out this is easy to do (apparently we can just set these attributes on the interface nowadays?), and probably easier to review too.

To post a comment you must log in.
Revision history for this message
Zooko Wilcox-O'Hearn (zooko) wrote :

I looked this patch over. It is certainly nice and short compared to the other patch. Unfortunately I don't know enough about formless to tell if this patch is introducing some bugs. I noticed that this patch doesn't have a unit test.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

True that the patch has no unit tests, and there appears to be no direct test coverage for some of these attributes. However, considering the history and likely future of formless, I'm not going to object to the change as-is. If someone is using formless and finds a problem with this change, they're welcome to contribute some new unit tests. Meanwhile, the code is at least executed by the existing test suite, and all of the tests pass, so I think it's great, please merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nevow/formless/annotate.py'
2--- Nevow/formless/annotate.py 2010-02-06 04:33:05 +0000
3+++ Nevow/formless/annotate.py 2011-08-06 18:06:37 +0000
4@@ -677,9 +677,6 @@
5 return None, '\n'.join(docs)
6
7
8-_typedInterfaceMetadata = {}
9-
10-
11 class MetaTypedInterface(InterfaceClass):
12 """The metaclass for TypedInterface. When TypedInterface is subclassed,
13 this metaclass' __new__ method is invoked. The Typed Binding introspection
14@@ -716,21 +713,14 @@
15 Once the metaclass __new__ is done, the Foo class instance will have three
16 properties, __methods__, __properties__, and __spec__,
17 """
18- __methods__ = property(lambda self: _typedInterfaceMetadata[self, '__methods__'])
19- __id__ = property(lambda self: _typedInterfaceMetadata[self, '__id__'])
20- __properties__ = property(lambda self: _typedInterfaceMetadata[self, '__properties__'])
21- __spec__ = property(lambda self: _typedInterfaceMetadata[self, '__spec__'])
22- name = property(lambda self: _typedInterfaceMetadata[self, 'name'])
23- label = property(lambda self: _typedInterfaceMetadata[self, 'label'])
24- description = property(lambda self: _typedInterfaceMetadata[self, 'description'])
25- default = property(lambda self: _typedInterfaceMetadata.get((self, 'default'), 'DEFAULT'))
26- complexType = property(lambda self: _typedInterfaceMetadata.get((self, 'complexType'), True))
27
28 def __new__(cls, name, bases, dct):
29 rv = cls = InterfaceClass.__new__(cls)
30- _typedInterfaceMetadata[cls, '__id__'] = nextId()
31- _typedInterfaceMetadata[cls, '__methods__'] = methods = []
32- _typedInterfaceMetadata[cls, '__properties__'] = properties = []
33+ cls.__id__ = nextId()
34+ cls.__methods__ = methods = []
35+ cls.__properties__ = properties = []
36+ cls.default = 'DEFAULT'
37+ cls.complexType = True
38 possibleActions = []
39 actionAttachers = []
40 for key, value in dct.items():
41@@ -825,21 +815,21 @@
42 attacher.attachActionBindings(possibleActions)
43 methods.sort(_sorter)
44 properties.sort(_sorter)
45- _typedInterfaceMetadata[cls, '__spec__'] = spec = methods + properties
46+ cls.__spec__ = spec = methods + properties
47 spec.sort(_sorter)
48- _typedInterfaceMetadata[cls, 'name'] = name
49+ cls.name = name
50
51 # because attributes "label" and "description" would become Properties,
52 # check for ones with an underscore prefix.
53- _typedInterfaceMetadata[cls, 'label'] = dct.get('_label', None)
54- _typedInterfaceMetadata[cls, 'description'] = dct.get('_description', None)
55+ cls.label = dct.get('_label', None)
56+ cls.description = dct.get('_description', None)
57 defaultLabel, defaultDescription = labelAndDescriptionFromDocstring(dct.get('__doc__'))
58 if defaultLabel is None:
59 defaultLabel = nameToLabel(name)
60- if _typedInterfaceMetadata[cls, 'label'] is None:
61- _typedInterfaceMetadata[cls, 'label'] = defaultLabel
62- if _typedInterfaceMetadata[cls, 'description'] is None:
63- _typedInterfaceMetadata[cls, 'description'] = defaultDescription
64+ if cls.label is None:
65+ cls.label = defaultLabel
66+ if cls.description is None:
67+ cls.description = defaultDescription
68
69 return rv
70

Subscribers

People subscribed via source and target branches

to all changes: