Skip to content

Instantly share code, notes, and snippets.

@soeirosantos
Created May 19, 2012 06:14
Show Gist options
  • Save soeirosantos/2729594 to your computer and use it in GitHub Desktop.
Save soeirosantos/2729594 to your computer and use it in GitHub Desktop.
alo mundo usando Spring Python
"""
Download springpython-[release].tar.gz
Unpack and type python setup.py install
http://static.springsource.org/spring-python/1.2.x/sphinx/html/index.html
"""
from springpython.config import PythonConfig
from springpython.config import Object
from springpython.context import scope
class MovieLister(object):
def __init__(self, description):
self.description = description
class MovieBasedApplicationContext(PythonConfig):
def __init__(self):
super(MovieBasedApplicationContext, self).__init__()
@Object(scope.PROTOTYPE, lazy_init=True)
def MovieLister(self):
lister = MovieLister(self.SingletonString())
self.logger.debug("Description = %s" % lister.description)
return lister
@Object(lazy_init=True) # scope.SINGLETON is the default
def SingletonString(self):
return "Alo Mundo!"
def NotExposed(self):
pass
if __name__ == '__main__':
from springpython.context import ApplicationContext
container = ApplicationContext(MovieBasedApplicationContext())
service = container.get_object("MovieLister")
print "alow: " + service.description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment