Repository: qpid-dispatch
Updated Branches:
  refs/heads/master ba8e158d6 -> 9c4933ffb


DISPATCH-293: The $ character can't be used inside a prefix for linkRoute

The $ character was being used for "schema references" a feature that was not
much used and not very useful. It has been removed, $ is now treated as an
ordinary character.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/9c4933ff
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/9c4933ff
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/9c4933ff

Branch: refs/heads/master
Commit: 9c4933ffbd4821e55b0dc870c254d55eecffea89
Parents: ba8e158
Author: Alan Conway <[email protected]>
Authored: Mon Apr 25 13:20:44 2016 -0400
Committer: Alan Conway <[email protected]>
Committed: Mon Apr 25 13:20:44 2016 -0400

----------------------------------------------------------------------
 python/qpid_dispatch/management/qdrouter.json   |  1 -
 .../qpid_dispatch_internal/management/schema.py | 47 +++++---------------
 tests/management/schema.py                      | 27 -----------
 tools/qdmanage                                  |  2 +-
 4 files changed, 13 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9c4933ff/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json 
b/python/qpid_dispatch/management/qdrouter.json
index 018d7d0..c8614e4 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -125,7 +125,6 @@
                 "type": {
                     "type": "string",
                     "required": true,
-                    "value": "$$entityType",
                     "description": "Management entity type.",
                     "create": true
                 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9c4933ff/python/qpid_dispatch_internal/management/schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema.py 
b/python/qpid_dispatch_internal/management/schema.py
index 794e0ad..32897f7 100644
--- a/python/qpid_dispatch_internal/management/schema.py
+++ b/python/qpid_dispatch_internal/management/schema.py
@@ -233,7 +233,7 @@ class AttributeType(object):
 
     def missing_value(self, check_required=True, add_default=True, **kwargs):
         """
-        Fill in missing default and fixed values but don't resolve references.
+        Fill in missing default and fixed values.
         @keyword check_required: Raise an exception if required attributes are 
misssing.
         @keyword add_default:  Add a default value for missing attributes.
         @param kwargs: See L{Schema.validate_all}
@@ -245,11 +245,10 @@ class AttributeType(object):
         if check_required and self.required:
             raise ValidationError("Missing required attribute '%s'" % 
(self.name))
 
-    def validate(self, value, resolve=lambda x: x, check_unique=None, 
**kwargs):
+    def validate(self, value, check_unique=None, **kwargs):
         """
         Validate value for this attribute definition.
         @param value: The value to validate.
-        @param resolve: function to resolve value references.
         @keyword check_unique: set of (name, value) to check for attribute 
uniqueness.
             None means don't check for uniqueness.
         @param create: if true, check that the attribute allows create
@@ -257,11 +256,11 @@ class AttributeType(object):
         @param kwargs: See L{Schema.validate_all}
         @return: value converted to the correct python type. Rais exception if 
any check fails.
         """
-        value = resolve(value)
         if self.unique and not _is_unique(check_unique, (self.name, value)):
             raise ValidationError("Duplicate value '%s' for unique attribute 
'%s'"%(value, self.name))
-        if self.value and value != resolve(self.value):
-            raise ValidationError("Attribute '%s' has fixed value '%s' but 
given '%s'"%(self.name, resolve(self.value), value))
+        if self.value and value != self.value:
+            raise ValidationError("Attribute '%s' has fixed value '%s' but 
given '%s'"%(
+                self.name, self.value, value))
         try:
             return self.atype.validate(value, **kwargs)
         except (TypeError, ValueError), e:
@@ -339,14 +338,12 @@ class EntityType(object):
             self.attributes = OrderedDict((k, AttributeType(k, 
defined_in=self, **v))
                                               for k, v in (attributes or 
{}).iteritems())
             self.operations = operations or []
-            # Bases and annotations are resolved in self.resolve
+            # Bases and annotations are resolved in self.init()
             self.base = extends
             self.all_bases = []
             self.annotations = annotations or []
             # List of annotations that are singletons
             self.references = []
-            # This map defines values that can be referred to using $$ in the 
schema.
-            self.refs = {'entityType': self.name}
             self.singleton = singleton
             self.referential = referential
             self._init = False      # Have not yet initialized from base and 
attributes.
@@ -358,7 +355,7 @@ class EntityType(object):
             raise ValidationError, "%s '%s': %s" % (type(self).__name__, name, 
msg), trace
 
     def init(self):
-        """Resolve bases and annotations after all types are loaded."""
+        """Find bases and annotations after all types are loaded."""
         if self._init: return
         self._init = True
         if self.base:
@@ -368,7 +365,7 @@ class EntityType(object):
             self._extend(self.base, 'extend')
         if self.annotations:
             self.references = [x for x in self.annotations
-                                if self.schema.annotation(x).referential]    
+                                if self.schema.annotation(x).referential]
             self.annotations = [self.schema.annotation(a) for a in 
self.annotations]
         for a in self.annotations:
             self._extend(a, 'be annotated')
@@ -384,33 +381,14 @@ class EntityType(object):
         self.operations += other.operations
         check(self.attributes.iterkeys(), other.attributes.itervalues(), 
"attributes")
         self.attributes.update(other.attributes)
+        if other.name == 'entity':
+            # Fill in entity "type" attribute automatically.
+            self.attributes["type"]["value"] = self.name
 
     def extends(self, base): return base in self.all_bases
 
     def is_a(self, type): return type == self or self.extends(type)
 
-    def resolve(self, value, attributes):
-        """
-        Resolve a $ or $$ reference.
-        $attr refers to another attribute.
-        $$name refers to a value in EntityType.refs
-        """
-        values = [value]
-        while True:
-            if isinstance(value, basestring) and value.startswith('$$'):
-                if value[2:] not in self.refs:
-                    raise ValidationError("Invalid entity type reference 
'%s'"%value)
-                value = self.refs[value[2:]]
-            elif isinstance(value, basestring) and value.startswith('$'):
-                if value[1:] not in self.attributes:
-                    raise ValidationError("Invalid attribute reference 
'%s'"%value)
-                value = attributes.get(value[1:])
-            else:
-                return value # Not a reference, don't need to resolve
-            if value == values[0]: # Circular reference
-                raise ValidationError("Unresolved circular reference 
'%s'"%values)
-            values.append(value)
-
     def attribute(self, name):
         """Get the AttributeType for name"""
         if not name in self.attributes:
@@ -449,8 +427,7 @@ class EntityType(object):
             for name, value in attributes.iteritems():
                 if name == 'type':
                     value = self.schema.long_name(value)
-                attributes[name] = self.attribute(name).validate(
-                    value, lambda v: self.resolve(v, attributes), **kwargs)
+                attributes[name] = self.attribute(name).validate(value, 
**kwargs)
         except ValidationError, e:
             raise  ValidationError, "%s: %s"%(self, e), sys.exc_info()[2]
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9c4933ff/tests/management/schema.py
----------------------------------------------------------------------
diff --git a/tests/management/schema.py b/tests/management/schema.py
index 26f5937..d703d4b 100644
--- a/tests/management/schema.py
+++ b/tests/management/schema.py
@@ -130,33 +130,6 @@ class SchemaTest(unittest.TestCase):
         e.init()
         self.assertEqual(e.validate({'x':1}), {'x':1, 'foo1': 'FOO1', 'foo2': 
'FOO2'})
 
-    def test_entity_refs(self):
-        e = EntityType('MyEntity', Schema(), attributes={
-            'type': {'type': 'string', 'required': True, 'value': 
'$$entityType'},
-            'name': {'type':'string', 'default':'$identity'},
-            'identity': {'type':'string', 'default':'$name', "required": 
True}})
-
-        self.assertEqual({'type': 'MyEntity', 'identity': 'x', 'name': 'x'},
-                         e.validate({'identity':'x'}))
-        self.assertEqual({'type': 'MyEntity', 'identity': 'x', 'name': 'x'},
-                         e.validate({'name':'x'}))
-        self.assertEqual({'type': 'MyEntity', 'identity': 'x', 'name': 'y'},
-                         e.validate({'identity': 'x', 'name':'y'}))
-        self.assertRaises(ValidationError, e.validate, {}) # Circular 
reference.
-
-    def test_entity_annotation_refs(self):
-        s = Schema(annotations={
-            'i1': {'attributes': {
-                'name': {'type':'string', 'default':'$identity'},
-                'identity': {'type':'string', 'default':'$name', "required": 
True}}}})
-
-        e = EntityType('MyEntity', s, attributes={}, annotations=['i1'])
-        e.init()
-        self.assertEqual({'identity': 'x', 'name': 'x'}, 
e.validate({'identity':'x'}))
-        self.assertEqual({'identity': 'x', 'name': 'x'}, 
e.validate({'name':'x'}))
-        self.assertEqual({'identity': 'x', 'name': 'y'}, 
e.validate({'identity': 'x', 'name':'y'}))
-        self.assertRaises(ValidationError, e.validate, {})
-
     def test_schema_validate(self):
         s = Schema(**SCHEMA_1)
         # Duplicate unique attribute 'name'

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/9c4933ff/tools/qdmanage
----------------------------------------------------------------------
diff --git a/tools/qdmanage b/tools/qdmanage
index 39f930c..8572411 100755
--- a/tools/qdmanage
+++ b/tools/qdmanage
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 #
-# Licensed to the Apache Software Foundation (ASF) under one
+# Licensed to the Apache Software Foundation (ASF) undeugr one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
 # regarding copyright ownership.  The ASF licenses this file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to