Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

various bug-fixes

  • Loading branch information...
commit a7a3b8e68650c32cfbec9fb5371233a5da49f683 1 parent 7e12230
Jordan McCoy jordanm authored
11 mesh/binding/python.py
View
@@ -34,7 +34,7 @@ def __new__(metatype, name, bases, namespace):
if resource is not None:
specification, resource = resource
if not isinstance(specification, Specification):
- raise Exception('bad specification')
+ specification = Specification(specification)
else:
return type.__new__(metatype, name, bases, namespace)
@@ -150,13 +150,14 @@ class BindingGenerator(object):
MODULE_TMPL = get_package_data('mesh.binding', 'templates/module.py.tmpl')
def __init__(self, module_path=None, separate_models=False,
- specification_var='specification'):
+ binding_module='mesh.binding.python', specification_var='specification'):
if module_path:
module_path = module_path.strip('.') + '.'
else:
module_path = ''
+ self.binding_module = binding_module
self.module_path = module_path
self.separate_models = separate_models
self.specification_var = specification_var
@@ -192,8 +193,10 @@ def _generate_model(self, name, model):
}
def _generate_module(self, module_path, content):
- imports = ['from %s%s import %s' % (module_path, self.specification_var,
- self.specification_var)]
+ imports = [
+ 'from %s import *' % self.binding_module,
+ 'from %s%s import %s' % (module_path, self.specification_var, self.specification_var)
+ ]
return self.MODULE_TMPL % {
'imports': '\n'.join(imports),
1  mesh/binding/templates/module.py.tmpl
View
@@ -1,4 +1,3 @@
-from mesh.binding.python import *
%(imports)s
%(content)s
6 mesh/tasks.py
View
@@ -45,6 +45,7 @@ class GeneratePythonBindings(Task):
name = 'mesh.python'
description = 'generate python bindings for a mesh bundle'
parameters = {
+ 'binding': Text(description='binding module'),
'bundle': ObjectReference(description='module path of bundle', required=True),
'package': Text(description='package prefix for generated modules'),
'path': Path(description='path to target directory', required=True),
@@ -54,10 +55,13 @@ class GeneratePythonBindings(Task):
def run(self, runtime):
from mesh.binding.python import BindingGenerator
- generator = BindingGenerator(module_path=self['package'], separate_models=self['separate'])
+ generator = BindingGenerator(module_path=self['package'], separate_models=self['separate'],
+ binding_module=self['binding'])
files = generator.generate(self['bundle'], self['version'])
root = self['path']
+ if not root.exists():
+ root.mkdir()
if not root.isdir():
raise TaskError('...')
3  mesh/transport/base.py
View
@@ -68,6 +68,9 @@ class Client(object):
clients = {}
def __init__(self, specification, environ=None, format=None, formats=None, secondary=False):
+ if not isinstance(specification, Specification):
+ specification = Specification(specification)
+
self.environ = environ or {}
self.format = format
self.specification = specification
13 mesh/transport/http.py
View
@@ -3,9 +3,11 @@
from httplib import HTTPConnection
from urlparse import urlparse
+from mesh.bundle import Specification
from mesh.constants import *
from mesh.exceptions import *
from mesh.transport.base import *
+from scheme.fields import INCOMING, OUTGOING
from scheme.formats import *
__all__ = ('ForwardingHttpServer', 'HttpClient', 'HttpRequest', 'HttpResponse', 'HttpServer')
@@ -305,14 +307,15 @@ def _construct_endpoint(self, bundle, version, resource, controller, request):
class HttpClient(Client):
"""An HTTP API client."""
- def __init__(self, host, specification, environ=None, format=Json, formats=None,
- secondary=False):
+ def __init__(self, url, specification, environ=None, format=Json,
+ formats=None, secondary=False):
super(HttpClient, self).__init__(specification, environ, format, formats, secondary)
- self.connection = Connection(host)
+ self.connection = Connection(url)
self.paths = {}
- self.initial_path = '/%s/%d.%d/' % (specification.name, specification.version[0],
- specification.version[1])
+ self.url = url
+ self.initial_path = '/%s/%d.%d/' % (self.specification.name,
+ self.specification.version[0], self.specification.version[1])
def execute(self, resource, request, subject=None, data=None, format=None):
format = format or self.format
Please sign in to comment.
Something went wrong with that request. Please try again.