Hello from Spain.
Well, I bought the book Spring Python 1.1 and I have been facing some problems that I cannot solve. I am going to write the code of each file in order to make sure everything is clear. If some of you know what is the problem, please tell me because I am desperate.
simple_service.py
simple_service_server_ctx.pyCode:class Service(object): def happy_birthday(self, name): results = [] for i in range(4): if i <= 2: results.append("Happy birthday dear %s!" % name) else: results.append("Happy birthday to you!") return results
simple_server.pyCode:from springpython.config import * from springpython.remoting.pyro import * from simple_service import * class HappyBirthdayContext(PythonConfig): def __init__(self): PythonConfig.__init__(self) @Object def target_service(self): return Service() @Object def service_exporter(self): exporter = PyroServiceExporter() exporter.service = self.target_service() exporter.service_name = "service" exporter.service_host = "127.0.0.1" exporter.service_port = "7766" exporter.after_properties_set() return exporter
I run on a terminal the following command:Code:from springpython.context import * from simple_service_server_ctx import * if __name__ == "__main__": ctx = ApplicationContext(HappyBirthdayContext()) ctx.get_object("service_exporter")
Code:python simple_server.py
and I got the following error:
If anyone know why I could have been getting this error, please let me know since I am eager to learn Spring Python.Code:(spring)kiko@kiko-laptop:~/examples/spring$ python simple_server.py Traceback (most recent call last): File "simple_server.py", line 6, in <module> ctx = ApplicationContext(HappyBirthdayContext()) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/context/__init__.py", line 45, in __init__ self.get_object(object_def.id, ignore_abstract=True) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/container/__init__.py", line 80, in get_object comp = self._create_object(object_def) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/container/__init__.py", line 129, in _create_object self._get_constructors_kw(object_def.named_constr)) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/factory/__init__.py", line 62, in create_object return self.method() File "<string>", line 2, in service_exporter File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/config/__init__.py", line 1370, in object_wrapper return _object_wrapper(f, theScope, parent, log_func_name, *args, **kwargs) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/config/__init__.py", line 1350, in _object_wrapper return _deco(f, scope, parent, log_func_name, *args, **kwargs) File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/config/__init__.py", line 1345, in _deco results = f(*args, **kwargs) File "/home/kiko/examples/spring/simple_service_server_ctx.py", line 22, in service_exporter exporter.after_properties_set() File "/home/kiko/.virtualenvs/spring/lib/python2.6/site-packages/springpython/remoting/pyro/__init__.py", line 58, in after_properties_set pyro_obj = Pyro.core.ObjBase() AttributeError: 'module' object has no attribute 'ObjBase' Exception KeyError: (('127.0.0.1', 7766),) in <bound method PyroServiceExporter.__del__ of <springpython.remoting.pyro.PyroServiceExporter object at 0x9d5264c>> ignored
Thank you for your help in advance
P.D. I am using a virtualenv but the error is the same even in the standard env.


Reply With Quote
