Created
July 1, 2012 03:47
-
-
Save tototoshi/3026732 to your computer and use it in GitHub Desktop.
spring-python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<objects xmlns="http://www.springframework.org/springpython/schema/objects/1.1" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/springpython/schema/objects/1.1 | |
http://springpython.webfactional.com/schema/context/spring-python-context-1.1.xsd"> | |
<object id="greeting" class="example1.GoodBye" /> | |
</objects> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objects: | |
- object: greeting | |
class: example2.Hello | |
scope: prototype |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from springpython.context import ApplicationContext | |
from springpython.config import XMLConfig | |
class Hello: | |
def greet(self): | |
print "Hello" | |
class GoodBye: | |
def greet(self): | |
print "GoodBye" | |
if __name__ == '__main__': | |
container = ApplicationContext(XMLConfig("app-context.xml")) | |
greeting = container.get_object("greeting") | |
greeting.greet() | |
# $ ./example1.py | |
# GoodBye |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from springpython.context import ApplicationContext | |
from springpython.config import YamlConfig | |
class Hello: | |
def greet(self): | |
print "Hello" | |
class GoodBye: | |
def greet(self): | |
print "GoodBye" | |
if __name__ == '__main__': | |
container = ApplicationContext(YamlConfig("app-context.yaml")) | |
greeting = container.get_object("greeting") | |
greeting.greet() | |
# $ ./example2.py | |
# Hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from springpython.context import ApplicationContext | |
from springpython.config import PythonConfig, scope, Object | |
class GreetApplicationContext(PythonConfig): | |
@Object(scope.PROTOTYPE) | |
def greeting(self): | |
return Hello() | |
class Hello: | |
def greet(self): | |
print "Hello" | |
class GoodBye: | |
def greet(self): | |
print "GoodBye" | |
if __name__ == '__main__': | |
container = ApplicationContext(GreetApplicationContext()) | |
greeting = container.get_object("greeting") | |
greeting.greet() | |
# $ ./example3.py | |
# Hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment