Announcement Announcement Module
Collapse
No announcement yet.
AttributeError: 'module' object has no attribute 'ObjBase' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AttributeError: 'module' object has no attribute 'ObjBase'

    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
    Code:
    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_service_server_ctx.py
    Code:
    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
    simple_server.py
    Code:
    from springpython.context import *
    
    from simple_service_server_ctx import *
    
    if __name__ == "__main__":
        ctx = ApplicationContext(HappyBirthdayContext())
        ctx.get_object("service_exporter")
    I run on a terminal the following command:
    Code:
    python simple_server.py

    and I got the following error:
    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
    If anyone know why I could have been getting this error, please let me know since I am eager to learn Spring Python.

    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.

  • #2
    Hi,

    it's been answered here on StackOverflow http://stackoverflow.com/questions/3889684

    Comment


    • #3
      Ok, thank you. I was going to write the answer yesterday but it was kind of late when I saw it. Thank you. I should have used the version 3.9 of Pyro instead of 4.0.

      Thanks

      Comment

      Working...
      X