Skip to content

Commit 3fe954b

Browse files
author
Dariusz Suchojad
committed
SESPRINGPYTHONPY-12: Synced with trunk.
git-svn-id: https://src.springframework.org/svn/se-springpython-py/sandbox/dsuch/jira/SESPRINGPYTHONPY-12@712 ce8fead1-4192-4296-8608-a705134b927f
2 parents f276261 + 61a20ca commit 3fe954b

File tree

125 files changed

+43595
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+43595
-482
lines changed

springpython/build.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def usage():
7373
print "\t--clean\t\t\tclean out this build by deleting the %s directory" % p["targetDir"]
7474
print "\t--test\t\t\trun the test suite, leaving all artifacts in %s" % p["testDir"]
7575
print "\t--suite [suite]\t\trun a specific test suite, leaving all artifacts in %s" % p["testDir"]
76-
print "\t--jython\t\trun a different test suite, with different arguments to support jython"
7776
print "\t--coverage\t\trun the test suite with coverage analysis, leaving all artifacts in %s" % p["testDir"]
7877
print "\t--debug-level [info|debug]\n\t\t\t\tthreshold of logging message when running tests or coverage analysis"
7978
print "\t--package\t\tpackage everything up into a tarball for release to sourceforge in %s" % p["packageDir"]
@@ -93,7 +92,7 @@ def usage():
9392
optlist, args = getopt.getopt(sys.argv[1:],
9493
"hct",
9594
["help", "clean", "test", "suite=", "debug-level=", "coverage", "package", "build-stamp=", \
96-
"publish", "register", "jython", \
95+
"publish", "register", \
9796
"site", "docs-html-multi", "docs-html-single", "docs-pdf", "docs-all", "pydoc"])
9897
except getopt.GetoptError:
9998
# print help information and exit:
@@ -137,20 +136,13 @@ def test(dir, test_suite, debug_level):
137136
if not os.path.exists(dir):
138137
os.makedirs(dir)
139138

140-
_run_nose(argv=["", "--with-nosexunit", "--source-folder=src", "--where=test/springpythontest", "--xml-report-folder=%s" % dir, test_suite], debug_level=debug_level)
139+
try:
140+
import java
141+
if test_suite == "checkin": test_suite = "jython"
142+
_run_nose(argv=["", "--where=test/springpythontest", test_suite], debug_level=debug_level)
143+
except ImportError:
144+
_run_nose(argv=["", "--with-nosexunit", "--source-folder=src", "--where=test/springpythontest", "--xml-report-folder=%s" % dir, test_suite], debug_level=debug_level)
141145

142-
def test_jython(dir, test_suite, debug_level):
143-
"""
144-
Run nose programmatically, with the NoseXUnit option taken out, to support Jython.
145-
146-
Nose expects to receive a sys.argv, of which the first arg is the script path (usually nosetests). Since this isn't
147-
being run that way, a filler entry was created to satisfy the library's needs.
148-
"""
149-
if not os.path.exists(dir):
150-
os.makedirs(dir)
151-
152-
_run_nose(argv=["", "--where=test/springpythontest", test_suite], debug_level=debug_level)
153-
154146
def test_coverage(dir, test_suite, debug_level):
155147
"""
156148
Run nose programmatically, so that it uses the same python version as this script uses
@@ -425,6 +417,9 @@ def create_pydocs():
425417
pydoc.writedoc("springpython.security.providers")
426418
pydoc.writedoc("springpython.security.providers.dao")
427419
pydoc.writedoc("springpython.security.providers.encoding")
420+
pydoc.writedoc("springpython.security.providers.Ldap")
421+
pydoc.writedoc("springpython.security.providers._Ldap_cpython")
422+
pydoc.writedoc("springpython.security.providers._Ldap_jython")
428423
pydoc.writedoc("springpython.security.userdetails")
429424
pydoc.writedoc("springpython.security.userdetails.dao")
430425
pydoc.writedoc("springpython.security.web")
@@ -500,13 +495,9 @@ def create_pydocs():
500495
test(p["testDir"], "checkin", debug_level)
501496

502497
if option[0] in ("--suite"):
503-
print "Running test suite..."
498+
print "Running test suite %s..." % option[1]
504499
test(p["testDir"], option[1], debug_level)
505500

506-
if option[0] in ("--jython"):
507-
print "Running for jython..."
508-
test_jython(p["testDir"], "jython", debug_level)
509-
510501
if option[0] in ("--coverage"):
511502
test_coverage(p["testDir"], "checkin", debug_level)
512503

Binary file not shown.
Binary file not shown.

springpython/dependencies/apacheds-1.5.5-i386.bin

Lines changed: 40590 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
41.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

springpython/docs/reference/src/objects.xml

Lines changed: 226 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,51 @@ service = container.get_object("MovieLister")
692692
]]></programlisting>
693693

694694
</section>
695-
695+
696+
<section id="objects-config-xmlconfig-python-builtin-types-mappings">
697+
<title>XMLConfig and basic Python types</title>
698+
</section>
699+
700+
<para>Objects of most commonnly used Python types
701+
-
702+
<classname>str</classname>,
703+
<classname>unicode</classname>,
704+
<classname>int</classname>,
705+
<classname>long</classname>,
706+
<classname>float</classname>,
707+
<classname>decimal.Decimal</classname>,
708+
<classname>bool</classname> and
709+
<classname>complex</classname>
710+
-
711+
may be expressed in XMLConfig using a shorthand syntax which allows
712+
for a following XMLConfig file:
713+
</para>
714+
<programlisting><![CDATA[
715+
<?xml version="1.0" encoding="UTF-8"?>
716+
<objects xmlns="http://www.springframework.org/springpython/schema/objects/1.1"
717+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
718+
xsi:schemaLocation="http://www.springframework.org/springpython/schema/objects/1.1
719+
http://springpython.webfactional.com/schema/context/spring-python-context-1.1.xsd">
720+
721+
<str id="MyString">My string</str>
722+
723+
<unicode id="MyUnicode">Zażółć gęślą jaźń</unicode>
724+
725+
<int id="MyInt">10</int>
726+
727+
<long id="MyLong">100000000000000000000000</long>
728+
729+
<float id="MyFloat">3.14</float>
730+
731+
<decimal id="MyDecimal">12.34</decimal>
732+
733+
<bool id="MyBool">False</bool>
734+
735+
<complex id="MyComplex">10+0j</complex>
736+
737+
</objects>
738+
]]></programlisting>
739+
696740
</section>
697741

698742
<section id="objects-config-yamlconfig">
@@ -934,6 +978,186 @@ properties:
934978
</note>
935979

936980
</section>
981+
982+
<section id="objects-config-yamlconfig-python-builtin-types-mappings">
983+
<title>Support for Python builtin types and mappings of other types onto YAML syntax</title>
984+
</section>
985+
<para>
986+
Objects of commonly used Python builtin types may be tersely expressed
987+
in YamlConfig. Supported types are
988+
<classname>str</classname>,
989+
<classname>unicode</classname>,
990+
<classname>int</classname>,
991+
<classname>long</classname>,
992+
<classname>float</classname>,
993+
<classname>decimal.Decimal</classname>,
994+
<classname>bool</classname>,
995+
<classname>complex</classname>,
996+
<classname>dict</classname>,
997+
<classname>list</classname> and
998+
<classname>tuple</classname>.
999+
</para>
1000+
<para>
1001+
Here's a sample YamlConfig featuring their usage. Note that
1002+
with the exception of <classname>decimal.Decimal</classname>,
1003+
names of the YAML attributes are the same as the names of
1004+
Python types.
1005+
</para>
1006+
<programlisting><![CDATA[
1007+
objects:
1008+
- object: MyString
1009+
str: My string
1010+
1011+
- object: MyUnicode
1012+
unicode: Zażółć gęślą jaźń
1013+
1014+
- object: MyInt
1015+
int: 10
1016+
1017+
- object: MyLong
1018+
long: 100000000000000000000000
1019+
1020+
- object: MyFloat
1021+
float: 3.14
1022+
1023+
- object: MyDecimal
1024+
decimal: 12.34
1025+
1026+
- object: MyBoolean
1027+
bool: False
1028+
1029+
- object: MyComplex
1030+
complex: 10+0j
1031+
1032+
- object: MyList
1033+
list: [1, 2, 3, 4]
1034+
1035+
- object: MyTuple
1036+
tuple: ["a", "b", "c"]
1037+
1038+
- object: MyDict
1039+
dict:
1040+
1: "a"
1041+
2: "b"
1042+
3: "c"
1043+
1044+
- object: MyRef
1045+
decimal:
1046+
ref: MyDecimal
1047+
]]></programlisting>
1048+
<para>
1049+
Under the hood, while parsing the YAML files, Spring Python
1050+
will translate the definitions such as the one above into
1051+
the following one:
1052+
</para>
1053+
<programlisting><![CDATA[
1054+
objects:
1055+
- object: MyString
1056+
class: types.StringType
1057+
constructor-args: ["My string"]
1058+
1059+
- object: MyUnicode
1060+
class: types.UnicodeType
1061+
constructor-args: ["Zażółć gęślą jaźń"]
1062+
1063+
- object: MyInt
1064+
class: types.IntType
1065+
constructor-args: [10]
1066+
1067+
- object: MyLong
1068+
class: types.LongType
1069+
constructor-args: [100000000000000000000000]
1070+
1071+
- object: MyFloat
1072+
class: types.FloatType
1073+
constructor-args: [3.14]
1074+
1075+
- object: MyDecimal
1076+
class: decimal.Decimal
1077+
constructor-args: ["12.34"]
1078+
1079+
- object: MyBoolean
1080+
class: types.BooleanType
1081+
constructor-args: [False]
1082+
1083+
- object: MyComplex
1084+
class: types.ComplexType
1085+
constructor-args: [10+0j]
1086+
1087+
- object: MyList
1088+
class: types.ListType
1089+
constructor-args: [[1,2,3,4]]
1090+
1091+
- object: MyTuple
1092+
class: types.TupleType
1093+
constructor-args: [["a", "b", "c"]]
1094+
1095+
- object: MyDict
1096+
class: types.DictType
1097+
constructor-args: [{1: "a", 2: "b", 3: "c"}]
1098+
1099+
- object: MyRef
1100+
class: decimal.Decimal
1101+
constructor-args: [{ref: MyDecimal}]
1102+
]]></programlisting>
1103+
1104+
<para>
1105+
Configuration of how YAML elements are mapped onto Python types
1106+
is stored in the
1107+
<classname>springpython.config.yaml_mappings</classname>
1108+
dictionary which can be easily customized to fulfill one's needs.
1109+
The dictionary's keys are names of the YAML elements and its
1110+
values are the coresponding Python types, written as strings
1111+
in the form of <classname>"package_name.module_name.class_name"</classname>
1112+
- note that the <classname>"package_name.module_name."</classname> part is
1113+
required, it needs to be a fully qualified name.
1114+
</para>
1115+
<para>
1116+
Let's assume that in your configuration you're frequently creating
1117+
objects of type
1118+
<classname>interest_rate.InterestRateFrequency</classname>,
1119+
here's how you can save yourself a lot of typing by customizing
1120+
the mappings dictionary. First, on Python side, create an
1121+
<classname>InterestRate</classname> class, such as:
1122+
<programlisting><![CDATA[
1123+
class InterestRate(object):
1124+
def __init__(self, value=None):
1125+
self.value = value
1126+
]]></programlisting>
1127+
1128+
<para>
1129+
.. which will allow you to create such a YAML context
1130+
</para>
1131+
1132+
<programlisting><![CDATA[
1133+
objects:
1134+
- object: base_interest_rate
1135+
interest_rate: "7.35"
1136+
]]></programlisting>
1137+
1138+
<para>
1139+
.. then, before creating the context, update the
1140+
mappings dictionary as needed and next you'll be able to
1141+
access the <classname>base_interest_rate</classname>
1142+
object as if it had been defined using the standard syntax:
1143+
</para>
1144+
1145+
<programlisting><![CDATA[
1146+
from springpython.context import ApplicationContext
1147+
from springpython.config import YamlConfig, yaml_mappings
1148+
1149+
yaml_mappings.update({"interest_rate": "interest_rate.InterestRate"})
1150+
1151+
# .. create the context now
1152+
container = ApplicationContext(YamlConfig("./app-ctx.yaml"))
1153+
1154+
# .. fetch the object
1155+
base_interest_rate = container.get_object("base_interest_rate")
1156+
1157+
# .. will show "7.35", as defined in the "./app-ctx.yaml" config
1158+
print base_interest_rate.value
1159+
]]></programlisting>
1160+
</para>
9371161

9381162
<section id="objects-config-yamlconfig-constructors">
9391163
<title>Constructors</title>
@@ -974,7 +1198,7 @@ constructor-args:
9741198
<para>It is also valuable to know that you can mix this up and use both.</para>
9751199

9761200
</section>
977-
1201+
9781202
</section>
9791203

9801204
<section id="objects-config-object">

springpython/docs/reference/src/samples.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
</listitem>
2121
</itemizedlist>
2222

23-
<para>NOTICE: Spring Python's FilterSecurityInterceptor has NOT been upgraded to CherryPy 3.1 yet (while the rest of PetClinic has). Somes pages for certain users are not yet denying access as expected.</para>
24-
2523
<section id="samples-petclinic-running">
2624
<title>How to run</title>
2725

@@ -44,7 +42,8 @@ bash$ python petclinic.py
4442

4543
<para>This assumes you have <ulink url="http://www.cherrypy.org">CherryPy 3</ulink>
4644
installed. It probably <emphasis>won't</emphasis> work if you are still using
47-
CherryPy 2.</para>
45+
CherryPy 2. NOTE: If you are using Python 2.5.2+, you must install CherryPy 3.1.2+. The older
46+
version of CherryPy (3.1.0) only works pre-2.5.2.</para>
4847

4948
<para>Finally, after launching it, you should see a nice URL at the bottom: http://localhost:8080.
5049
Well, go ahead! Things should look good now!</para>

0 commit comments

Comments
 (0)