avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r990264 - in /avro/trunk: CHANGES.txt lang/py/src/avro/schema.py
Date Fri, 27 Aug 2010 20:51:33 GMT
Author: cutting
Date: Fri Aug 27 20:51:33 2010
New Revision: 990264

URL: http://svn.apache.org/viewvc?rev=990264&view=rev
Log:
AVRO-639. Use namespace-unqualified names for references to schemas in the same namespace.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/py/src/avro/schema.py

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=990264&r1=990263&r2=990264&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Aug 27 20:51:33 2010
@@ -149,6 +149,9 @@ Avro 1.4.0 (unreleased)
     AVRO-632. Java: Change RPC responder to log stack traces for user
     exceptions. (cutting)
 
+    AVRO-639. Python: Use namespace-unqualified names for references
+    to schemas in the same namespace. (cutting)
+
   BUG FIXES
 
     AVRO-622. python avro.ipc doesn't work with python2.4 (philz)

Modified: avro/trunk/lang/py/src/avro/schema.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/py/src/avro/schema.py?rev=990264&r1=990263&r2=990264&view=diff
==============================================================================
--- avro/trunk/lang/py/src/avro/schema.py (original)
+++ avro/trunk/lang/py/src/avro/schema.py Fri Aug 27 20:51:33 2010
@@ -271,6 +271,11 @@ class NamedSchema(Schema):
     # Store full name as calculated from name, namespace
     self._fullname = new_name.fullname
     
+  def name_ref(self, names):
+    if self.namespace == names.default_namespace:
+      return self.name
+    else:
+      return self.fullname
 
   # read-only properties
   name = property(lambda self: self.get_prop('name'))
@@ -378,7 +383,7 @@ class FixedSchema(NamedSchema):
 
   def to_json(self, names):
     if self.fullname in names.names:
-      return self.fullname
+      return self.name_ref(names)
     else:
       names.names[self.fullname] = self
       return self.props
@@ -410,7 +415,7 @@ class EnumSchema(NamedSchema):
 
   def to_json(self, names):
     if self.fullname in names.names:
-      return self.fullname
+      return self.name_ref(names)
     else:
       names.names[self.fullname] = self
       return self.props
@@ -614,7 +619,7 @@ class RecordSchema(NamedSchema):
       return [ f.to_json(names) for f in self.fields ]
 
     if self.fullname in names.names:
-      return self.fullname
+      return self.name_ref(names)
     else:
       names.names[self.fullname] = self
 



Mime
View raw message