You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2014/12/08 18:41:58 UTC
svn commit: r1643870 -
/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py
Author: aconway
Date: Mon Dec 8 17:41:58 2014
New Revision: 1643870
URL: http://svn.apache.org/r1643870
Log:
NO-JIRA: Fix ordering problem that prevented schema from loading on python <= 2.6.
Modified:
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py
Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py?rev=1643870&r1=1643869&r2=1643870&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/schema.py Mon Dec 8 17:41:58 2014
@@ -329,21 +329,29 @@ class EntityType(AttrsAndOps):
@param operations: Allowed operations, list of operation names.
"""
super(EntityType, self).__init__(name, schema, attributes, operations, description)
- self.base = None
+ # Bases and annotations are resolved in self.resolve
+ self.base = extends
self.all_bases = []
- if extends:
- self.base = schema.entity_type(extends)
+ self.annotations = annotations or []
+ # This map defines values that can be referred to using $$ in the schema.
+ self.refs = {'entityType': self.name}
+ self.singleton = singleton
+ self._init = False # Have not yet initialized from base and attributes.
+
+ def init(self):
+ """Resolve bases and annotations after all types are loaded."""
+ if self._init: return
+ self._init = True
+ if self.base:
+ self.base = self.schema.entity_type(self.base)
+ self.base.init()
self.all_bases = [self.base] + self.base.all_bases
self._extend(self.base, 'extend')
-
- self.annotations = [ schema.annotation(a) for a in annotations or []]
+ if self.annotations:
+ self.annotations = [self.schema.annotation(a) for a in self.annotations]
for a in self.annotations:
self._extend(a, 'be annotated')
- # This map defines values that can be referred to using $$ in the schema.
- self.refs = {'entityType': self.name}
- self.singleton = singleton
-
def _extend(self, other, how):
"""Add attributes and operations from other"""
def check(a, b, what):
@@ -458,16 +466,14 @@ class Schema(object):
self.prefixdot = self.prefix + '.'
else:
self.prefix = self.prefixdot = ""
-
self.description = description
- self.annotations = OrderedDict()
- self.entity_types = OrderedDict()
- def add_defs(thing, mymap, defs):
- for k, v in defs.iteritems():
- t = thing(k, self, **v)
- mymap[t.name] = t
- add_defs(Annotation, self.annotations, annotations or {})
- add_defs(EntityType, self.entity_types, entityTypes or {})
+
+ def make_dict(klass, params):
+ if not params: return OrderedDict()
+ return OrderedDict((t.name, t) for t in (klass(k, self, **v) for k, v in params.iteritems()))
+ self.annotations = make_dict(Annotation, annotations)
+ self.entity_types = make_dict(EntityType, entityTypes)
+ for et in self.entity_types.itervalues(): et.init()
def short_name(self, name):
"""Remove prefix from name if present"""
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org