Skip to content

Commit

Permalink
added compatibility with Pyro 4.44+ metadata datatype change (set to …
Browse files Browse the repository at this point in the history
…list)
  • Loading branch information
irmen committed May 21, 2016
1 parent 11789d7 commit 5c17bac
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 43 deletions.
3 changes: 1 addition & 2 deletions dotnet/Pyrolite.TestPyroNaming/TestNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void Main(String[] args) {
} catch (Exception x) {
Console.WriteLine("unhandled exception: {0}",x);
}
Console.WriteLine("\r\nEnter to exit:"); Console.ReadLine();
}

public static void Test() {
Expand Down Expand Up @@ -105,8 +106,6 @@ public static void Test() {
// ok
Console.WriteLine("got a PyroException (expected): {0}", x.Message);
}

Console.WriteLine("\r\nEnter to exit:"); Console.ReadLine();
}

}
Expand Down
4 changes: 2 additions & 2 deletions dotnet/Pyrolite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion ("4.10.0.*")]
[assembly: AssemblyFileVersion("4.10.0.0")]
[assembly: AssemblyVersion ("4.11.0.*")]
[assembly: AssemblyFileVersion("4.11.0.0")]
2 changes: 1 addition & 1 deletion dotnet/Pyrolite/Pyro/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum SerializerType {
public static bool METADATA = true;

public const int PROTOCOL_VERSION = 48; // Pyro 4.38+
public const string PYROLITE_VERSION="4.10";
public const string PYROLITE_VERSION="4.11";

public const string DAEMON_NAME = "Pyro.Daemon";
}
Expand Down
18 changes: 3 additions & 15 deletions dotnet/Pyrolite/Pyro/NameServerProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public PyroURI lookup(string name) {
public Tuple<PyroURI, ISet<string>> lookup(string name, bool return_metadata) {
object[] result = (object[])this.call("lookup", name, return_metadata);
PyroURI uri = (PyroURI) result[0];
var metaobjects = (ISet<object>) result[1];
var metastrings = new HashSet<string>();
foreach(object ms in metaobjects) {
metastrings.Add((string)ms);
}
var metastrings = GetStringSet(result[1]);
return new Tuple<PyroURI, ISet<string>>(uri, metastrings);
}

Expand Down Expand Up @@ -84,11 +80,7 @@ public IDictionary<string, Tuple<string, ISet<string>>> list_with_meta(string pr
foreach(object name in hash.Keys) {
object[] o = (object[]) hash[name];
string uri = (string) o[0];
var metaobjects = (ISet<object>)o[1];
var metastrings = new HashSet<string>();
foreach(object ms in metaobjects) {
metastrings.Add((string)ms);
}
var metastrings = GetStringSet(o[1]);
typed[(string)name] = new Tuple<string, ISet<string>>(uri, metastrings);
}
return typed;
Expand All @@ -100,11 +92,7 @@ public IDictionary<string, Tuple<string, ISet<string>>> list_with_meta(string pr
foreach(object name in hash.Keys) {
object[] o = (object[]) hash[name];
string uri = (string) o[0];
var metaobjects = (ISet<object>)o[1];
var metastrings = new HashSet<string>();
foreach(object ms in metaobjects) {
metastrings.Add((string)ms);
}
var metastrings = GetStringSet(o[1]);
typed[(string)name] = new Tuple<string, ISet<string>>(uri, metastrings);
}
return typed;
Expand Down
36 changes: 16 additions & 20 deletions dotnet/Pyrolite/Pyro/PyroProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,35 +117,31 @@ protected void GetMetadata(string objectId) {
/// </summary>
private void _processMetadata(Hashtable result)
{
// the collections in the result can be either an object[] or a HashSet<object>, depending on the serializer that is used
// the collections in the result can be either an object[] or a HashSet<object> or List<object>,
// depending on the serializer and Pyro version that is used
object[] methods_array = result["methods"] as object[];
object[] attrs_array = result["attrs"] as object[];
object[] oneway_array = result["oneway"] as object[];
if(methods_array!=null)
this.pyroMethods = new HashSet<string>(methods_array.Select(o=>o as string));
else if((result["methods"] as HashSet<string>) != null)
this.pyroOneway = result["methods"] as HashSet<string>;
else
this.pyroMethods = new HashSet<string>((result["methods"] as HashSet<object>).Select(o=>o.ToString()));

if(attrs_array!=null)
this.pyroAttrs = new HashSet<string>(attrs_array.Select(o=>o as string));
else if((result["attrs"] as HashSet<string>) != null)
this.pyroAttrs = result["attrs"] as HashSet<string>;
else
this.pyroAttrs = new HashSet<string>((result["attrs"] as HashSet<object>).Select(o=>o.ToString()));

if(oneway_array!=null)
this.pyroOneway = new HashSet<string>(oneway_array.Select(o=>o as string));
else if((result["oneway"] as HashSet<string>) != null)
this.pyroOneway = result["oneway"] as HashSet<string>;
else
this.pyroOneway =new HashSet<string> ((result["oneway"] as HashSet<object>).Select(o=>o.ToString()));
this.pyroMethods = methods_array != null ? new HashSet<string>(methods_array.Select(o => o as string)) : GetStringSet(result["methods"]);
this.pyroAttrs = attrs_array != null ? new HashSet<string>(attrs_array.Select(o => o as string)) : GetStringSet(result["attrs"]);
this.pyroOneway = oneway_array != null ? new HashSet<string>(oneway_array.Select(o => o as string)) : GetStringSet(result["attrs"]);

if(!pyroMethods.Any() && !pyroAttrs.Any()) {
throw new PyroException("remote object doesn't expose any methods or attributes");
}
}

protected HashSet<string> GetStringSet(object strings)
{
var result1 = strings as HashSet<string>;
if(result1!=null)
return result1;

// another collection, convert to set of strings.
var result = (IEnumerable<object>)strings;
return new HashSet<string>(result.Select(o=>o.ToString()));
}

/// <summary>
/// Makes it easier to call methods on the proxy by intercepting the methods calls.
Expand Down
6 changes: 3 additions & 3 deletions dotnet/Pyrolite/Pyrolite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Razorvine.Pyrolite</id>
<version>4.10.0.0</version>
<version>4.11.0.0</version>
<title>Razorvine.Pyrolite</title>
<authors>Irmen de Jong</authors>
<owners>Irmen de Jong</owners>
Expand All @@ -13,8 +13,8 @@
Also includes Pickle/Unpickle.
More info about Pyro: http://pythonhosted.org/Pyro4/</description>
<summary>Pyro (Python Remote Objects) client library</summary>
<releaseNotes>@todo</releaseNotes>
<copyright>Copyright 2015</copyright>
<releaseNotes>added compatibility with Pyro 4.44+ metadata datatype change (set to list)</releaseNotes>
<copyright>Copyright 2015, 2016</copyright>
<tags>pyro python rpc remote-objects</tags>
<dependencies>
<dependency id="Razorvine.Serpent" version="1.12" />
Expand Down

0 comments on commit 5c17bac

Please sign in to comment.