From: <fwi...@us...> - 2009-10-21 01:58:16
|
Revision: 6887 http://jython.svn.sourceforge.net/jython/?rev=6887&view=rev Author: fwierzbicki Date: 2009-10-21 01:58:03 +0000 (Wed, 21 Oct 2009) Log Message: ----------- Merged revisions 6815-6816,6818-6824,6826-6886 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r6815 | pjenvey | 2009-09-30 21:06:20 -0400 (Wed, 30 Sep 2009) | 2 lines allow del of default_factory, small cleanup ........ r6816 | pjenvey | 2009-09-30 21:13:04 -0400 (Wed, 30 Sep 2009) | 3 lines correct the callable check fixes #1478 ........ r6818 | fwierzbicki | 2009-09-30 21:25:40 -0400 (Wed, 30 Sep 2009) | 2 lines svn:ignore *$py.class in these. ........ r6819 | fwierzbicki | 2009-10-01 16:11:08 -0400 (Thu, 01 Oct 2009) | 4 lines Remove useless little inner subclasses, which where there just to add a behavior to nextToken() in Python.g -- since we override nextToken() in Python.g anyway, I relocated the functionality there. ........ r6820 | fwierzbicki | 2009-10-01 16:48:58 -0400 (Thu, 01 Oct 2009) | 3 lines Added a comment for trailing whitespace handling in single mode. Tobias asked me what it did and it took way too long to answer :) ........ r6821 | pjenvey | 2009-10-01 20:59:40 -0400 (Thu, 01 Oct 2009) | 2 lines small cleanup ........ r6822 | pjenvey | 2009-10-01 21:46:27 -0400 (Thu, 01 Oct 2009) | 3 lines allow exec of PyByteCode objects and simplify pycimport so it's not creating frames directly ........ r6823 | pjenvey | 2009-10-01 23:45:27 -0400 (Thu, 01 Oct 2009) | 2 lines pass the cached type through constructors ........ r6824 | pjenvey | 2009-10-02 00:05:54 -0400 (Fri, 02 Oct 2009) | 5 lines o convert PyFrame to exposed annotations o specify its cached type during construction to avoid repeated PyType.fromClass calls o fix the f_lineno value while tracing PyByteCode ........ r6826 | fwierzbicki | 2009-10-02 16:29:01 -0400 (Fri, 02 Oct 2009) | 2 lines Initial import of the part of JRuby's CodegenUtils that we can use. ........ r6827 | fwierzbicki | 2009-10-02 20:09:30 -0400 (Fri, 02 Oct 2009) | 2 lines First nibble at using CodegenUtils. ........ r6828 | fwierzbicki | 2009-10-02 20:48:54 -0400 (Fri, 02 Oct 2009) | 4 lines Converted almost all "org/python/Foo" to p(Foo.class). There is one I'm not sure about as it looks like "[org/python/core/PyObject" which doesn't make sense to me -- I'd expect "[Lorg/python/core/PyObject;". ........ r6829 | pjenvey | 2009-10-03 16:34:59 -0400 (Sat, 03 Oct 2009) | 3 lines add the ability for the method exposer to optionally pass in the current ThreadState when a method signature requests it @ arg 0 ........ r6830 | fwierzbicki | 2009-10-03 21:16:45 -0400 (Sat, 03 Oct 2009) | 2 lines Converted invokespecial and getfield to CodegenUtils. ........ r6831 | fwierzbicki | 2009-10-03 22:42:47 -0400 (Sat, 03 Oct 2009) | 3 lines Fix all invokevirtual to use sig() -- fix some invokespecial lines that went over 100 chars as per coding conventions. ........ r6832 | fwierzbicki | 2009-10-04 10:10:58 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig() for invokestatic calls. ........ r6833 | fwierzbicki | 2009-10-04 10:39:40 -0400 (Sun, 04 Oct 2009) | 2 lines Finish up CodeCompiler conversion to CodegenUtils. ........ r6834 | fwierzbicki | 2009-10-04 11:10:21 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig for invokevirtual. ........ r6835 | fwierzbicki | 2009-10-04 13:03:17 -0400 (Sun, 04 Oct 2009) | 2 lines use sig for invokestatic. ........ r6836 | fwierzbicki | 2009-10-04 16:16:12 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig for invokespecial and addMethod. ........ r6837 | pjenvey | 2009-10-04 17:25:41 -0400 (Sun, 04 Oct 2009) | 3 lines hack around PyReflectedFunction's assumption of how instancemethod calls into it so instancemethod's ThreadState pass through optimization can be enabled ........ r6838 | fwierzbicki | 2009-10-04 18:31:22 -0400 (Sun, 04 Oct 2009) | 2 lines switch to p() from raw path strings where possible, also some cleanup. ........ r6839 | pjenvey | 2009-10-04 19:25:51 -0400 (Sun, 04 Oct 2009) | 4 lines only abspath module __file__s. the only other type having __file__ here is javapackage and their jar paths are already canonicalized by packagecache. saves maybe 150ms off startup ........ r6840 | amak | 2009-10-06 08:27:51 -0400 (Tue, 06 Oct 2009) | 3 lines Adding proper interpreter shutdown on servlet.destroy() for modjy. Fixes: http://bugs.jython.org/issue1474 Thanks to Colin Evans for reporting the issue. ........ r6841 | amak | 2009-10-06 08:38:52 -0400 (Tue, 06 Oct 2009) | 1 line Tabs to spaces. ........ r6842 | amak | 2009-10-06 09:11:06 -0400 (Tue, 06 Oct 2009) | 1 line Tabs to spaces, DOS line-endings to unix. ........ r6843 | fwierzbicki | 2009-10-06 16:32:55 -0400 (Tue, 06 Oct 2009) | 8 lines Make constants more.... constant in the compiler package. Changed confusing method names of the form Py*() that return constants to *constant. For example PyInteger() -> integerConstant(). Also reduced public interface of compiler package, especially around compiler constants. ........ r6844 | pjenvey | 2009-10-06 22:48:36 -0400 (Tue, 06 Oct 2009) | 6 lines optimize attr lookup on Deriveds inheriting object.__getattribute__: don't bother going through the descriptor. Derived's __findattr_ex__ now lives in a Deriveds util class (like java.util.Arrays/Collections but trickier to pronounce) so it can toggle the package private fast path flag on PyType fixes #1102 ........ r6845 | pjenvey | 2009-10-06 22:50:46 -0400 (Tue, 06 Oct 2009) | 1 line regen per r6844 ........ r6846 | fwierzbicki | 2009-10-07 15:16:54 -0400 (Wed, 07 Oct 2009) | 5 lines Make PyCodeConstant an actual constant. Move construction details into PyCodeConstant constructor. Hide more implementation details by making public fields package private. ........ r6847 | fwierzbicki | 2009-10-07 22:33:20 -0400 (Wed, 07 Oct 2009) | 2 lines Coding standards / Cleanup. ........ r6848 | fwierzbicki | 2009-10-07 23:30:17 -0400 (Wed, 07 Oct 2009) | 2 lines Coding standards / Cleanup. ........ r6849 | pjenvey | 2009-10-08 23:17:04 -0400 (Thu, 08 Oct 2009) | 1 line rearrange/cleanup by exposing __call__ with ThreadState ........ r6850 | fwierzbicki | 2009-10-09 14:32:33 -0400 (Fri, 09 Oct 2009) | 3 lines Make all of the fields in CodeCompiler private except "yields". I plan to make "yields" private as well, but that's going to take some surgery on Module. ........ r6851 | pjenvey | 2009-10-10 01:44:16 -0400 (Sat, 10 Oct 2009) | 3 lines after a SystemRestart don't reset PySystemState until after the exitfuncs are called, otherwise some strange problems can occur ........ r6852 | pjenvey | 2009-10-10 02:05:26 -0400 (Sat, 10 Oct 2009) | 3 lines add a flag to sys as a faster SystemRestart check for the code objects. otherwise currentThread().isInterrupted() is now a noticable performance hit ........ r6853 | pjenvey | 2009-10-12 01:04:37 -0400 (Mon, 12 Oct 2009) | 10 lines port Armin Rigo's global mro cache optimization from PyPy/CPython 2.6. unlike their's this version is thread safe (non-blocking). being global, it may become less optimal when shared by many PythonInterpreters/PySystemStates this provides a nice attribute lookup speedup but it can slow down silly things like class attribute counters (maybe due to our extra allocation around the cache invalidation) refs http://bugs.python.org/issue1700288 ........ r6854 | pjenvey | 2009-10-12 22:31:45 -0400 (Mon, 12 Oct 2009) | 2 lines move the cached objectGetattribute out of PyObject to ease bootstrapping ........ r6855 | pjenvey | 2009-10-13 23:19:24 -0400 (Tue, 13 Oct 2009) | 4 lines add support for specifying docstrings in ExposedType/ExposedGet annotations. exposed type.__doc__, which for the most part removes the need for PyObject.getDoc ........ r6856 | pjenvey | 2009-10-14 02:02:01 -0400 (Wed, 14 Oct 2009) | 2 lines docs galore, enable test_descr.descrdoc ........ r6857 | pjenvey | 2009-10-14 02:37:50 -0400 (Wed, 14 Oct 2009) | 2 lines add classmethod docs ........ r6858 | pjenvey | 2009-10-14 02:54:56 -0400 (Wed, 14 Oct 2009) | 1 line fix the docstring test ........ r6859 | amak | 2009-10-15 13:40:22 -0400 (Thu, 15 Oct 2009) | 1 line Checking in support for loading site-packages, through the use of imp.load("site"). Controlled with a "load_site_packages" option, which defaults to true. ........ r6860 | otmarhumbel | 2009-10-15 15:34:31 -0400 (Thu, 15 Oct 2009) | 1 line fixed javadoc warnings ........ r6861 | pjenvey | 2009-10-15 22:39:10 -0400 (Thu, 15 Oct 2009) | 1 line doc sets and BaseException ........ r6862 | pjenvey | 2009-10-15 22:41:41 -0400 (Thu, 15 Oct 2009) | 1 line toArray arg can't be null ........ r6863 | pjenvey | 2009-10-15 23:34:01 -0400 (Thu, 15 Oct 2009) | 1 line make the exposed methods final, cleanup ........ r6864 | pjenvey | 2009-10-16 01:51:46 -0400 (Fri, 16 Oct 2009) | 4 lines The GC thread should be able to safely create GeneratorExits now that PyExceptions no longer create tracebacks when constructed (and so don't immediately need a frame on hand). this speeds up generator construction ........ r6865 | pjenvey | 2009-10-16 22:11:46 -0400 (Fri, 16 Oct 2009) | 3 lines fast path lists along with tuples and avoid the overhead of __len__'ing generators which can be a somewhat common make_array argument ........ r6866 | amak | 2009-10-17 12:03:45 -0400 (Sat, 17 Oct 2009) | 1 line Fixing a previously unnoticed bug where a relative value for "python.home" was not being treated relative to the context root and should have been. ........ r6867 | amak | 2009-10-17 12:10:18 -0400 (Sat, 17 Oct 2009) | 1 line Adding a sample config value for load_site_packages. ........ r6868 | pjenvey | 2009-10-17 12:57:13 -0400 (Sat, 17 Oct 2009) | 2 lines hardcode the __new__ descriptors' __doc__ ........ r6869 | pjenvey | 2009-10-17 13:07:38 -0400 (Sat, 17 Oct 2009) | 2 lines expose PyFastSequenceIter and avoid PyType.fromClass during its construction ........ r6870 | pjenvey | 2009-10-18 14:59:19 -0400 (Sun, 18 Oct 2009) | 1 line cache TYPE ........ r6871 | pjenvey | 2009-10-19 00:56:15 -0400 (Mon, 19 Oct 2009) | 2 lines two exceptions walk into a bar. ouch! ........ r6872 | pjenvey | 2009-10-19 17:26:09 -0400 (Mon, 19 Oct 2009) | 2 lines bring in constantine 0.6 release, for OpenFlags ........ r6873 | pjenvey | 2009-10-19 17:56:07 -0400 (Mon, 19 Oct 2009) | 4 lines move os.py -> posix.py, in prep. for separating the posix bits from it os.py from: http://svn.python.org/projects/python/branches/release26-maint/Lib/os.py@75144 ........ r6874 | pjenvey | 2009-10-19 18:02:41 -0400 (Mon, 19 Oct 2009) | 10 lines o pull posix bits out of os into their own module o further pull some of the slower to initialize bits out of posix into a Java _posix (_nt on Windows) module. this speeds up startup. eventually we should move more if not everything there o adapt 2.6's os.py: - hide exec* - we don't need to use set/get/putenv for the environ dict wrapper - our stat_result can be pickled, remove the copy_reg workaround - re-add some 2.5isms ........ r6875 | pjenvey | 2009-10-19 18:04:02 -0400 (Mon, 19 Oct 2009) | 2 lines remove the platform hiding functionality, until we actually need it ........ r6876 | pjenvey | 2009-10-19 18:08:32 -0400 (Mon, 19 Oct 2009) | 1 line unused imports ........ r6877 | pjenvey | 2009-10-19 20:06:05 -0400 (Mon, 19 Oct 2009) | 1 line don't hardcode the platform module name ........ r6878 | pjenvey | 2009-10-19 20:20:58 -0400 (Mon, 19 Oct 2009) | 5 lines o jna-posix does the pure java stat for us, simplify it + move it to PosixModule o move strerror to PosixModule because it does the work of falling back to Linux errno descriptions on Windows, and we need that from some Java calls ........ r6879 | pjenvey | 2009-10-19 20:54:00 -0400 (Mon, 19 Oct 2009) | 3 lines o constantine lacks sensible Windows OpenFlags constants, roll our own o fix put/unset/getenv on Windows ........ r6880 | pjenvey | 2009-10-19 21:15:51 -0400 (Mon, 19 Oct 2009) | 2 lines move the environ dict into the more appropriate PosixModule ........ r6881 | pjenvey | 2009-10-19 21:20:43 -0400 (Mon, 19 Oct 2009) | 1 line avoid the types import ........ r6882 | pjenvey | 2009-10-19 23:28:30 -0400 (Mon, 19 Oct 2009) | 1 line only import these when necessary ........ r6883 | pjenvey | 2009-10-19 23:43:46 -0400 (Mon, 19 Oct 2009) | 1 line identify reflected funcs as routines so they can show up in help() ........ r6884 | pjenvey | 2009-10-20 00:04:53 -0400 (Tue, 20 Oct 2009) | 2 lines move _exit/listdir to PosixModule, get rid of a duplicate getlogin impl ........ r6885 | pjenvey | 2009-10-20 00:24:54 -0400 (Tue, 20 Oct 2009) | 2 lines fix missing imports and reference to now fixed os.__name__ ........ r6886 | pjenvey | 2009-10-20 00:25:15 -0400 (Tue, 20 Oct 2009) | 4 lines don't decode bytes when searching for an encoding defined in an InputStream thanks artichoke fixes #1487 ........ Modified Paths: -------------- branches/indy/CoreExposed.includes branches/indy/Demo/modjy_webapp/WEB-INF/web.xml branches/indy/Lib/grp.py branches/indy/Lib/inspect.py branches/indy/Lib/modjy/__init__.py branches/indy/Lib/modjy/modjy.py branches/indy/Lib/modjy/modjy_exceptions.py branches/indy/Lib/modjy/modjy_impl.py branches/indy/Lib/modjy/modjy_log.py branches/indy/Lib/modjy/modjy_params.py branches/indy/Lib/modjy/modjy_publish.py branches/indy/Lib/modjy/modjy_response.py branches/indy/Lib/modjy/modjy_write.py branches/indy/Lib/modjy/modjy_wsgi.py branches/indy/Lib/ntpath.py branches/indy/Lib/posixpath.py branches/indy/Lib/pwd.py branches/indy/Lib/pycimport.py branches/indy/Lib/select.py branches/indy/Lib/site.py branches/indy/Lib/subprocess.py branches/indy/Lib/test/test_descr.py branches/indy/Lib/test/test_fileno.py branches/indy/Lib/test/test_import_jy.py branches/indy/Misc/make_pydocs.py branches/indy/NEWS branches/indy/build.xml branches/indy/grammar/Python.g branches/indy/grammar/PythonPartial.g branches/indy/src/com/xhaus/modjy/ModjyJServlet.java branches/indy/src/org/python/antlr/BaseParser.java branches/indy/src/org/python/antlr/PythonTree.java branches/indy/src/org/python/antlr/ast/AssertDerived.java branches/indy/src/org/python/antlr/ast/AssignDerived.java branches/indy/src/org/python/antlr/ast/AttributeDerived.java branches/indy/src/org/python/antlr/ast/AugAssignDerived.java branches/indy/src/org/python/antlr/ast/BinOpDerived.java branches/indy/src/org/python/antlr/ast/BoolOpDerived.java branches/indy/src/org/python/antlr/ast/BreakDerived.java branches/indy/src/org/python/antlr/ast/CallDerived.java branches/indy/src/org/python/antlr/ast/ClassDefDerived.java branches/indy/src/org/python/antlr/ast/CompareDerived.java branches/indy/src/org/python/antlr/ast/ContinueDerived.java branches/indy/src/org/python/antlr/ast/DeleteDerived.java branches/indy/src/org/python/antlr/ast/DictDerived.java branches/indy/src/org/python/antlr/ast/EllipsisDerived.java branches/indy/src/org/python/antlr/ast/ExceptHandlerDerived.java branches/indy/src/org/python/antlr/ast/ExecDerived.java branches/indy/src/org/python/antlr/ast/ExprDerived.java branches/indy/src/org/python/antlr/ast/ExpressionDerived.java branches/indy/src/org/python/antlr/ast/ExtSliceDerived.java branches/indy/src/org/python/antlr/ast/ForDerived.java branches/indy/src/org/python/antlr/ast/FunctionDefDerived.java branches/indy/src/org/python/antlr/ast/GeneratorExpDerived.java branches/indy/src/org/python/antlr/ast/GlobalDerived.java branches/indy/src/org/python/antlr/ast/IfDerived.java branches/indy/src/org/python/antlr/ast/IfExpDerived.java branches/indy/src/org/python/antlr/ast/ImportDerived.java branches/indy/src/org/python/antlr/ast/ImportFromDerived.java branches/indy/src/org/python/antlr/ast/IndexDerived.java branches/indy/src/org/python/antlr/ast/InteractiveDerived.java branches/indy/src/org/python/antlr/ast/LambdaDerived.java branches/indy/src/org/python/antlr/ast/ListCompDerived.java branches/indy/src/org/python/antlr/ast/ListDerived.java branches/indy/src/org/python/antlr/ast/ModuleDerived.java branches/indy/src/org/python/antlr/ast/NameDerived.java branches/indy/src/org/python/antlr/ast/NumDerived.java branches/indy/src/org/python/antlr/ast/PassDerived.java branches/indy/src/org/python/antlr/ast/PrintDerived.java branches/indy/src/org/python/antlr/ast/RaiseDerived.java branches/indy/src/org/python/antlr/ast/ReprDerived.java branches/indy/src/org/python/antlr/ast/ReturnDerived.java branches/indy/src/org/python/antlr/ast/SliceDerived.java branches/indy/src/org/python/antlr/ast/StrDerived.java branches/indy/src/org/python/antlr/ast/SubscriptDerived.java branches/indy/src/org/python/antlr/ast/SuiteDerived.java branches/indy/src/org/python/antlr/ast/TryExceptDerived.java branches/indy/src/org/python/antlr/ast/TryFinallyDerived.java branches/indy/src/org/python/antlr/ast/TupleDerived.java branches/indy/src/org/python/antlr/ast/UnaryOpDerived.java branches/indy/src/org/python/antlr/ast/WhileDerived.java branches/indy/src/org/python/antlr/ast/WithDerived.java branches/indy/src/org/python/antlr/ast/YieldDerived.java branches/indy/src/org/python/antlr/ast/aliasDerived.java branches/indy/src/org/python/antlr/ast/argumentsDerived.java branches/indy/src/org/python/antlr/ast/comprehensionDerived.java branches/indy/src/org/python/antlr/ast/keywordDerived.java branches/indy/src/org/python/antlr/op/AddDerived.java branches/indy/src/org/python/antlr/op/AndDerived.java branches/indy/src/org/python/antlr/op/AugLoadDerived.java branches/indy/src/org/python/antlr/op/AugStoreDerived.java branches/indy/src/org/python/antlr/op/BitAndDerived.java branches/indy/src/org/python/antlr/op/BitOrDerived.java branches/indy/src/org/python/antlr/op/BitXorDerived.java branches/indy/src/org/python/antlr/op/DelDerived.java branches/indy/src/org/python/antlr/op/DivDerived.java branches/indy/src/org/python/antlr/op/EqDerived.java branches/indy/src/org/python/antlr/op/FloorDivDerived.java branches/indy/src/org/python/antlr/op/GtDerived.java branches/indy/src/org/python/antlr/op/GtEDerived.java branches/indy/src/org/python/antlr/op/InDerived.java branches/indy/src/org/python/antlr/op/InvertDerived.java branches/indy/src/org/python/antlr/op/IsDerived.java branches/indy/src/org/python/antlr/op/IsNotDerived.java branches/indy/src/org/python/antlr/op/LShiftDerived.java branches/indy/src/org/python/antlr/op/LoadDerived.java branches/indy/src/org/python/antlr/op/LtDerived.java branches/indy/src/org/python/antlr/op/LtEDerived.java branches/indy/src/org/python/antlr/op/ModDerived.java branches/indy/src/org/python/antlr/op/MultDerived.java branches/indy/src/org/python/antlr/op/NotDerived.java branches/indy/src/org/python/antlr/op/NotEqDerived.java branches/indy/src/org/python/antlr/op/NotInDerived.java branches/indy/src/org/python/antlr/op/OrDerived.java branches/indy/src/org/python/antlr/op/ParamDerived.java branches/indy/src/org/python/antlr/op/PowDerived.java branches/indy/src/org/python/antlr/op/RShiftDerived.java branches/indy/src/org/python/antlr/op/StoreDerived.java branches/indy/src/org/python/antlr/op/SubDerived.java branches/indy/src/org/python/antlr/op/UAddDerived.java branches/indy/src/org/python/antlr/op/USubDerived.java branches/indy/src/org/python/compiler/CodeCompiler.java branches/indy/src/org/python/compiler/Constant.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/core/BuiltinDocs.java branches/indy/src/org/python/core/ClasspathPyImporterDerived.java branches/indy/src/org/python/core/ParserFacade.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/PyArrayDerived.java branches/indy/src/org/python/core/PyBaseCode.java branches/indy/src/org/python/core/PyBaseException.java branches/indy/src/org/python/core/PyBaseExceptionDerived.java branches/indy/src/org/python/core/PyBaseString.java branches/indy/src/org/python/core/PyBoolean.java branches/indy/src/org/python/core/PyBooleanDerived.java branches/indy/src/org/python/core/PyBuiltinCallable.java branches/indy/src/org/python/core/PyCell.java branches/indy/src/org/python/core/PyClassMethod.java branches/indy/src/org/python/core/PyClassMethodDerived.java branches/indy/src/org/python/core/PyClassMethodDescr.java branches/indy/src/org/python/core/PyComplex.java branches/indy/src/org/python/core/PyComplexDerived.java branches/indy/src/org/python/core/PyDataDescr.java branches/indy/src/org/python/core/PyDictionary.java branches/indy/src/org/python/core/PyDictionaryDerived.java branches/indy/src/org/python/core/PyEnumerate.java branches/indy/src/org/python/core/PyEnumerateDerived.java branches/indy/src/org/python/core/PyFastSequenceIter.java branches/indy/src/org/python/core/PyFile.java branches/indy/src/org/python/core/PyFileDerived.java branches/indy/src/org/python/core/PyFloat.java branches/indy/src/org/python/core/PyFloatDerived.java branches/indy/src/org/python/core/PyFrame.java branches/indy/src/org/python/core/PyFrozenSet.java branches/indy/src/org/python/core/PyFrozenSetDerived.java branches/indy/src/org/python/core/PyFunction.java branches/indy/src/org/python/core/PyGenerator.java branches/indy/src/org/python/core/PyInteger.java branches/indy/src/org/python/core/PyIntegerDerived.java branches/indy/src/org/python/core/PyJavaType.java branches/indy/src/org/python/core/PyList.java branches/indy/src/org/python/core/PyListDerived.java branches/indy/src/org/python/core/PyLong.java branches/indy/src/org/python/core/PyLongDerived.java branches/indy/src/org/python/core/PyMethod.java branches/indy/src/org/python/core/PyMethodDescr.java branches/indy/src/org/python/core/PyModule.java branches/indy/src/org/python/core/PyModuleDerived.java branches/indy/src/org/python/core/PyNewWrapper.java branches/indy/src/org/python/core/PyObject.java branches/indy/src/org/python/core/PyObjectDerived.java branches/indy/src/org/python/core/PyProperty.java branches/indy/src/org/python/core/PyPropertyDerived.java branches/indy/src/org/python/core/PyReflectedConstructor.java branches/indy/src/org/python/core/PyReflectedFunction.java branches/indy/src/org/python/core/PySet.java branches/indy/src/org/python/core/PySetDerived.java branches/indy/src/org/python/core/PySlice.java branches/indy/src/org/python/core/PySliceDerived.java branches/indy/src/org/python/core/PyStaticMethod.java branches/indy/src/org/python/core/PyString.java branches/indy/src/org/python/core/PyStringDerived.java branches/indy/src/org/python/core/PySuper.java branches/indy/src/org/python/core/PySuperDerived.java branches/indy/src/org/python/core/PySystemState.java branches/indy/src/org/python/core/PyTableCode.java branches/indy/src/org/python/core/PyTraceback.java branches/indy/src/org/python/core/PyTuple.java branches/indy/src/org/python/core/PyTupleDerived.java branches/indy/src/org/python/core/PyType.java branches/indy/src/org/python/core/PyTypeDerived.java branches/indy/src/org/python/core/PyUnicode.java branches/indy/src/org/python/core/PyUnicodeDerived.java branches/indy/src/org/python/core/PyXRange.java branches/indy/src/org/python/core/ReflectedArgs.java branches/indy/src/org/python/core/exceptions.java branches/indy/src/org/python/core/io/FileIO.java branches/indy/src/org/python/core/io/StreamIO.java branches/indy/src/org/python/core/util/FileUtil.java branches/indy/src/org/python/expose/BaseTypeBuilder.java branches/indy/src/org/python/expose/ExposedClassMethod.java branches/indy/src/org/python/expose/ExposedGet.java branches/indy/src/org/python/expose/ExposedType.java branches/indy/src/org/python/expose/TypeBuilder.java branches/indy/src/org/python/expose/generate/ClassMethodExposer.java branches/indy/src/org/python/expose/generate/DescriptorExposer.java branches/indy/src/org/python/expose/generate/DescriptorVisitor.java branches/indy/src/org/python/expose/generate/ExposedFieldFinder.java branches/indy/src/org/python/expose/generate/ExposedMethodFinder.java branches/indy/src/org/python/expose/generate/ExposedTypeProcessor.java branches/indy/src/org/python/expose/generate/ExposedTypeVisitor.java branches/indy/src/org/python/expose/generate/InstanceMethodExposer.java branches/indy/src/org/python/expose/generate/MethodExposer.java branches/indy/src/org/python/expose/generate/PyTypes.java branches/indy/src/org/python/expose/generate/TypeExposer.java branches/indy/src/org/python/modules/Setup.java branches/indy/src/org/python/modules/_collections/PyDefaultDict.java branches/indy/src/org/python/modules/_collections/PyDefaultDictDerived.java branches/indy/src/org/python/modules/_collections/PyDequeDerived.java branches/indy/src/org/python/modules/_csv/PyDialectDerived.java branches/indy/src/org/python/modules/_functools/PyPartialDerived.java branches/indy/src/org/python/modules/_weakref/ReferenceTypeDerived.java branches/indy/src/org/python/modules/cPickle.java branches/indy/src/org/python/modules/cStringIO.java branches/indy/src/org/python/modules/itertools.java branches/indy/src/org/python/modules/random/PyRandomDerived.java branches/indy/src/org/python/modules/thread/PyLocalDerived.java branches/indy/src/org/python/modules/zipimport/zipimporterDerived.java branches/indy/src/org/python/util/jython.java branches/indy/src/templates/object.derived branches/indy/tests/java/org/python/antlr/PythonPartialTester.java branches/indy/tests/java/org/python/antlr/PythonTreeTester.java branches/indy/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java branches/indy/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java branches/indy/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java branches/indy/tests/java/org/python/expose/generate/MethodExposerTest.java branches/indy/tests/java/org/python/expose/generate/SimpleExposed.java branches/indy/tests/java/org/python/expose/generate/TypeExposerTest.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestBase.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestContentHeaders.java branches/indy/tests/modjy/test_apps_dir/content_header_tests.py branches/indy/tests/modjy/test_apps_dir/environ_tests.py branches/indy/tests/modjy/test_apps_dir/header_tests.py branches/indy/tests/modjy/test_apps_dir/return_tests.py branches/indy/tests/modjy/test_apps_dir/simple_app.py branches/indy/tests/modjy/test_apps_dir/stream_tests.py branches/indy/tests/modjy/test_apps_dir/web_inf_tests.py Added Paths: ----------- branches/indy/Lib/nt.py branches/indy/Lib/os.py branches/indy/Lib/posix.py branches/indy/Lib/test/test_inspect_jy.py branches/indy/extlibs/constantine.jar branches/indy/src/org/python/core/Deriveds.java branches/indy/src/org/python/modules/posix/ branches/indy/src/org/python/modules/posix/OS.java branches/indy/src/org/python/modules/posix/PosixModule.java branches/indy/src/org/python/modules/posix/PyStatResult.java branches/indy/src/org/python/modules/posix/PythonPOSIXHandler.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestInterpreterLifecycle.java branches/indy/tests/modjy/test_apps_dir/lifecycle_tests.py Removed Paths: ------------- branches/indy/Lib/os.py branches/indy/Lib/posix.py branches/indy/extlibs/constantine-0.4.jar branches/indy/src/org/python/modules/posix/OS.java branches/indy/src/org/python/modules/posix/PosixModule.java branches/indy/src/org/python/modules/posix/PyStatResult.java branches/indy/src/org/python/modules/posix/PythonPOSIXHandler.java Property Changed: ---------------- branches/indy/ branches/indy/Lib/collections/ branches/indy/Lib/compiler/ branches/indy/Lib/distutils/ branches/indy/Lib/distutils/command/ branches/indy/Lib/distutils/tests/ branches/indy/Lib/modjy/ branches/indy/Lib/test/bugs/ branches/indy/Lib/test/bugs/pr133/ branches/indy/Lib/test/pbcvm/test/ branches/indy/Lib/test/pyservlet/ branches/indy/Lib/test/test_metaclass_support/ branches/indy/Lib/test/zxjdbc/ branches/indy/Lib/xml/etree/ branches/indy/Lib/xml/parsers/ branches/indy/extlibs/xercesImpl-2.9.1.jar branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-6814 + /trunk/jython:1-6886 Modified: svn:mergeinfo - /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741,6762-6814 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741,6762-6886 Modified: branches/indy/CoreExposed.includes =================================================================== --- branches/indy/CoreExposed.includes 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/CoreExposed.includes 2009-10-21 01:58:03 UTC (rev 6887) @@ -15,8 +15,10 @@ org/python/core/PyDictProxy.class org/python/core/PyEnumerate.class org/python/core/PyEllipsis.class +org/python/core/PyFastSequenceIter.class org/python/core/PyFile.class org/python/core/PyFloat.class +org/python/core/PyFrame.class org/python/core/PyFrozenSet.class org/python/core/PyFunction.class org/python/core/PyGenerator.class @@ -59,6 +61,7 @@ org/python/modules/_weakref/ReferenceType.class org/python/modules/operator$PyAttrGetter.class org/python/modules/operator$PyItemGetter.class +org/python/modules/posix/PyStatResult.class org/python/modules/random/PyRandom.class org/python/modules/thread/PyLocal.class org/python/modules/time/PyTimeTuple.class Modified: branches/indy/Demo/modjy_webapp/WEB-INF/web.xml =================================================================== --- branches/indy/Demo/modjy_webapp/WEB-INF/web.xml 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Demo/modjy_webapp/WEB-INF/web.xml 2009-10-21 01:58:03 UTC (rev 6887) @@ -6,7 +6,7 @@ <display-name>modjy demo application</display-name> <description> - modjy WSGI demo application + modjy WSGI demo application </description> <servlet> @@ -15,58 +15,67 @@ <init-param> <param-name>python.home</param-name> <param-value>C:/jython2.5</param-value> - </init-param> -<!-- - There are two different ways you can specify an application to modjy - 1. Using the app_import_name mechanism - 2. Using a combination of app_directory/app_filename/app_callable_name - Examples of both are given below - See the documenation for more details. + </init-param> +<!-- + There are two different ways you can specify an application to modjy + 1. Using the app_import_name mechanism + 2. Using a combination of app_directory/app_filename/app_callable_name + Examples of both are given below + See the documenation for more details. http://modjy.xhaus.com/locating.html#locating_callables ---> -<!-- - This is the app_import_name mechanism. If you specify a value - for this variable, then it will take precedence over the other mechanism +--> +<!-- + This is the app_import_name mechanism. If you specify a value + for this variable, then it will take precedence over the other mechanism <init-param> <param-name>app_import_name</param-name> <param-value>my_wsgi_module.my_handler_class().handler_method</param-value> - </init-param> + </init-param> --> -<!-- - And this is the app_directory/app_filename/app_callable_name combo - The defaults for these three variables are ""/application.py/handler - So if you specify no values at all for any of app_* variables, then modjy - will by default look for "handler" in "application.py" in the servlet - context root. +<!-- + And this is the app_directory/app_filename/app_callable_name combo + The defaults for these three variables are ""/application.py/handler + So if you specify no values at all for any of app_* variables, then modjy + will by default look for "handler" in "application.py" in the servlet + context root. <init-param> <param-name>app_directory</param-name> <param-value>some_sub_directory</param-value> - </init-param> + </init-param> --> <init-param> <param-name>app_filename</param-name> <param-value>demo_app.py</param-value> </init-param> -<!-- - Supply a value for this parameter if you want your application - callable to have a different name than the default. +<!-- + Supply a value for this parameter if you want your application + callable to have a different name than the default. <init-param> <param-name>app_callable_name</param-name> <param-value>my_handler_func</param-value> </init-param> ---> - <!-- Do you want application callables to be cached? --> +--> + <!-- Do you want application callables to be cached? --> <init-param> <param-name>cache_callables</param-name> <param-value>1</param-value> - </init-param> - <!-- Should the application be reloaded if it's .py file changes? --> + </init-param> + <!-- Should the application be reloaded if it's .py file changes? --> <!-- Does not work with the app_import_name mechanism --> <init-param> <param-name>reload_on_mod</param-name> <param-value>1</param-value> </init-param> + <!-- + Is site-packages to be loaded through imp.load("site")? + Same as -S option to command line interpreter + --> <init-param> + <param-name>load_site_packages</param-name> + <param-value>1</param-value> +<!-- <param-value>0</param-value> --> + </init-param> + <init-param> <param-name>log_level</param-name> <param-value>debug</param-value> <!-- <param-value>info</param-value> --> Property changes on: branches/indy/Lib/collections ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/compiler ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils/command ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils/tests ___________________________________________________________________ Added: svn:ignore + *$py.class Modified: branches/indy/Lib/grp.py =================================================================== --- branches/indy/Lib/grp.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/grp.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -17,7 +17,7 @@ __all__ = ['getgrgid', 'getgrnam', 'getgrall'] -from os import _name, _posix +from os import _name, _posix_impl if _name == 'nt': raise ImportError, 'grp module not supported on Windows' @@ -50,7 +50,7 @@ Return the group database entry for the given numeric group ID. If id is not valid, raise KeyError. """ - entry = _posix.getgrgid(uid) + entry = _posix_impl.getgrgid(uid) if not entry: raise KeyError(uid) return struct_group(entry) @@ -62,7 +62,7 @@ Return the group database entry for the given group name. If name is not valid, raise KeyError. """ - entry = _posix.getgrnam(name) + entry = _posix_impl.getgrnam(name) if not entry: raise KeyError(name) return struct_group(entry) @@ -76,7 +76,7 @@ """ groups = [] while True: - group = _posix.getgrent() + group = _posix_impl.getgrent() if not group: break groups.append(struct_group(group)) Modified: branches/indy/Lib/inspect.py =================================================================== --- branches/indy/Lib/inspect.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/inspect.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -30,6 +30,7 @@ import sys, os, types, string, re, dis, imp, tokenize, linecache from operator import attrgetter +ReflectedFunctionType = type(os.listdir) # ----------------------------------------------------------- type-checking def ismodule(object): @@ -196,7 +197,8 @@ return (isbuiltin(object) or isfunction(object) or ismethod(object) - or ismethoddescriptor(object)) + or ismethoddescriptor(object) + or isinstance(object, ReflectedFunctionType)) def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Property changes on: branches/indy/Lib/modjy ___________________________________________________________________ Added: svn:ignore + *$py.class Modified: branches/indy/Lib/modjy/__init__.py =================================================================== --- branches/indy/Lib/modjy/__init__.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/__init__.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,22 +1,22 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -__all__ = ['modjy', 'modjy_exceptions', 'modjy_impl', 'modjy_log', 'modjy_params', 'modjy_publish', 'modjy_response', 'modjy_write', 'modjy_wsgi',] - +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +__all__ = ['modjy', 'modjy_exceptions', 'modjy_impl', 'modjy_log', 'modjy_params', 'modjy_publish', 'modjy_response', 'modjy_write', 'modjy_wsgi',] + Modified: branches/indy/Lib/modjy/modjy.py =================================================================== --- branches/indy/Lib/modjy/modjy.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,121 +1,121 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import jarray -import synchronize -import sys -import types - -sys.add_package("javax.servlet") -sys.add_package("javax.servlet.http") -sys.add_package("org.python.core") - -from modjy_exceptions import * -from modjy_log import * -from modjy_params import modjy_param_mgr, modjy_servlet_params -from modjy_wsgi import modjy_wsgi -from modjy_response import start_response_object -from modjy_impl import modjy_impl -from modjy_publish import modjy_publisher - -from javax.servlet.http import HttpServlet - -class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl): - - def __init__(self): - HttpServlet.__init__(self) - - def do_param(self, name, value): - if name[:3] == 'log': - getattr(self.log, "set_%s" % name)(value) - else: - self.params[name] = value - - def process_param_container(self, param_container): - param_enum = param_container.getInitParameterNames() - while param_enum.hasMoreElements(): - param_name = param_enum.nextElement() - self.do_param(param_name, param_container.getInitParameter(param_name)) - - def get_params(self): - self.process_param_container(self.servlet_context) - self.process_param_container(self.servlet) - - def init(self, delegator): - self.servlet = delegator - self.servlet_context = self.servlet.getServletContext() - self.servlet_config = self.servlet.getServletConfig() - self.log = modjy_logger(self.servlet_context) - self.params = modjy_param_mgr(modjy_servlet_params) - self.get_params() - self.init_impl() - self.init_publisher() - import modjy_exceptions - self.exc_handler = getattr(modjy_exceptions, '%s_handler' % self.params['exc_handler'])() - - def service (self, req, resp): - wsgi_environ = {} - try: - self.dispatch_to_application(req, resp, wsgi_environ) - except ModjyException, mx: - self.log.error("Exception servicing request: %s" % str(mx)) - typ, value, tb = sys.exc_info()[:] - self.exc_handler.handle(req, resp, wsgi_environ, mx, (typ, value, tb) ) - - def get_j2ee_ns(self, req, resp): - return { - 'servlet': self.servlet, - 'servlet_context': self.servlet_context, - 'servlet_config': self.servlet_config, - 'request': req, - 'response': resp, - } - - def dispatch_to_application(self, req, resp, environ): - app_callable = self.get_app_object(req, environ) - self.set_wsgi_environment(req, resp, environ, self.params, self.get_j2ee_ns(req, resp)) - response_callable = start_response_object(req, resp) - try: - app_return = self.call_application(app_callable, environ, response_callable) - if app_return is None: - raise ReturnNotIterable("Application returned None: must return an iterable") - self.deal_with_app_return(environ, response_callable, app_return) - except ModjyException, mx: - self.raise_exc(mx.__class__, str(mx)) - except Exception, x: - self.raise_exc(ApplicationException, str(x)) - - def call_application(self, app_callable, environ, response_callable): - if self.params['multithread']: - return app_callable.__call__(environ, response_callable) - else: - return synchronize.apply_synchronized( \ - app_callable, \ - app_callable, \ - (environ, response_callable)) - - def expand_relative_path(self, path): - if path.startswith("$"): - return self.servlet.getServletContext().getRealPath(path[1:]) - return path - - def raise_exc(self, exc_class, message): - self.log.error(message) - raise exc_class(message) +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import jarray +import synchronize +import sys +import types + +sys.add_package("javax.servlet") +sys.add_package("javax.servlet.http") +sys.add_package("org.python.core") + +from modjy_exceptions import * +from modjy_log import * +from modjy_params import modjy_param_mgr, modjy_servlet_params +from modjy_wsgi import modjy_wsgi +from modjy_response import start_response_object +from modjy_impl import modjy_impl +from modjy_publish import modjy_publisher + +from javax.servlet.http import HttpServlet + +class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl): + + def __init__(self): + HttpServlet.__init__(self) + + def do_param(self, name, value): + if name[:3] == 'log': + getattr(self.log, "set_%s" % name)(value) + else: + self.params[name] = value + + def process_param_container(self, param_container): + param_enum = param_container.getInitParameterNames() + while param_enum.hasMoreElements(): + param_name = param_enum.nextElement() + self.do_param(param_name, param_container.getInitParameter(param_name)) + + def get_params(self): + self.process_param_container(self.servlet_context) + self.process_param_container(self.servlet) + + def init(self, delegator): + self.servlet = delegator + self.servlet_context = self.servlet.getServletContext() + self.servlet_config = self.servlet.getServletConfig() + self.log = modjy_logger(self.servlet_context) + self.params = modjy_param_mgr(modjy_servlet_params) + self.get_params() + self.init_impl() + self.init_publisher() + import modjy_exceptions + self.exc_handler = getattr(modjy_exceptions, '%s_handler' % self.params['exc_handler'])() + + def service (self, req, resp): + wsgi_environ = {} + try: + self.dispatch_to_application(req, resp, wsgi_environ) + except ModjyException, mx: + self.log.error("Exception servicing request: %s" % str(mx)) + typ, value, tb = sys.exc_info()[:] + self.exc_handler.handle(req, resp, wsgi_environ, mx, (typ, value, tb) ) + + def get_j2ee_ns(self, req, resp): + return { + 'servlet': self.servlet, + 'servlet_context': self.servlet_context, + 'servlet_config': self.servlet_config, + 'request': req, + 'response': resp, + } + + def dispatch_to_application(self, req, resp, environ): + app_callable = self.get_app_object(req, environ) + self.set_wsgi_environment(req, resp, environ, self.params, self.get_j2ee_ns(req, resp)) + response_callable = start_response_object(req, resp) + try: + app_return = self.call_application(app_callable, environ, response_callable) + if app_return is None: + raise ReturnNotIterable("Application returned None: must return an iterable") + self.deal_with_app_return(environ, response_callable, app_return) + except ModjyException, mx: + self.raise_exc(mx.__class__, str(mx)) + except Exception, x: + self.raise_exc(ApplicationException, str(x)) + + def call_application(self, app_callable, environ, response_callable): + if self.params['multithread']: + return app_callable.__call__(environ, response_callable) + else: + return synchronize.apply_synchronized( \ + app_callable, \ + app_callable, \ + (environ, response_callable)) + + def expand_relative_path(self, path): + if path.startswith("$"): + return self.servlet.getServletContext().getRealPath(path[1:]) + return path + + def raise_exc(self, exc_class, message): + self.log.error(message) + raise exc_class(message) Modified: branches/indy/Lib/modjy/modjy_exceptions.py =================================================================== --- branches/indy/Lib/modjy/modjy_exceptions.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy_exceptions.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,91 +1,91 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import sys -import StringIO -import traceback - -from java.lang import IllegalStateException -from java.io import IOException -from javax.servlet import ServletException - -class ModjyException(Exception): pass - -class ModjyIOException(ModjyException): pass - -class ConfigException(ModjyException): pass -class BadParameter(ConfigException): pass -class ApplicationNotFound(ConfigException): pass -class NoCallable(ConfigException): pass - -class RequestException(ModjyException): pass - -class ApplicationException(ModjyException): pass -class StartResponseNotCalled(ApplicationException): pass -class StartResponseCalledTwice(ApplicationException): pass -class ResponseCommitted(ApplicationException): pass -class HopByHopHeaderSet(ApplicationException): pass -class WrongLength(ApplicationException): pass -class BadArgument(ApplicationException): pass -class ReturnNotIterable(ApplicationException): pass -class NonStringOutput(ApplicationException): pass - -class exception_handler: - - def handle(self, req, resp, environ, exc, exc_info): - pass - - def get_status_and_message(self, req, resp, exc): - return resp.SC_INTERNAL_SERVER_ERROR, "Server configuration error" - -# -# Special exception handler for testing -# - -class testing_handler(exception_handler): - - def handle(self, req, resp, environ, exc, exc_info): - typ, value, tb = exc_info - err_msg = StringIO.StringIO() - err_msg.write("%s: %s\n" % (typ, value,) ) - err_msg.write(">Environment\n") - for k in environ.keys(): - err_msg.write("%s=%s\n" % (k, repr(environ[k])) ) - err_msg.write("<Environment\n") - err_msg.write(">TraceBack\n") - for line in traceback.format_exception(typ, value, tb): - err_msg.write(line) - err_msg.write("<TraceBack\n") - try: - status, message = self.get_status_and_message(req, resp, exc) - resp.setStatus(status) - resp.setContentLength(len(err_msg.getvalue())) - resp.getOutputStream().write(err_msg.getvalue()) - except IllegalStateException, ise: - raise exc # Let the container deal with it - -# -# Standard exception handler -# - -class standard_handler(exception_handler): - - def handle(self, req, resp, environ, exc, exc_info): - raise exc_info[0], exc_info[1], exc_info[2] +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import sys +import StringIO +import traceback + +from java.lang import IllegalStateException +from java.io import IOException +from javax.servlet import ServletException + +class ModjyException(Exception): pass + +class ModjyIOException(ModjyException): pass + +class ConfigException(ModjyException): pass +class BadParameter(ConfigException): pass +class ApplicationNotFound(ConfigException): pass +class NoCallable(ConfigException): pass + +class RequestException(ModjyException): pass + +class ApplicationException(ModjyException): pass +class StartResponseNotCalled(ApplicationException): pass +class StartResponseCalledTwice(ApplicationException): pass +class ResponseCommitted(ApplicationException): pass +class HopByHopHeaderSet(ApplicationException): pass +class WrongLength(ApplicationException): pass +class BadArgument(ApplicationException): pass +class ReturnNotIterable(ApplicationException): pass +class NonStringOutput(ApplicationException): pass + +class exception_handler: + + def handle(self, req, resp, environ, exc, exc_info): + pass + + def get_status_and_message(self, req, resp, exc): + return resp.SC_INTERNAL_SERVER_ERROR, "Server configuration error" + +# +# Special exception handler for testing +# + +class testing_handler(exception_handler): + + def handle(self, req, resp, environ, exc, exc_info): + typ, value, tb = exc_info + err_msg = StringIO.StringIO() + err_msg.write("%s: %s\n" % (typ, value,) ) + err_msg.write(">Environment\n") + for k in environ.keys(): + err_msg.write("%s=%s\n" % (k, repr(environ[k])) ) + err_msg.write("<Environment\n") + err_msg.write(">TraceBack\n") + for line in traceback.format_exception(typ, value, tb): + err_msg.write(line) + err_msg.write("<TraceBack\n") + try: + status, message = self.get_status_and_message(req, resp, exc) + resp.setStatus(status) + resp.setContentLength(len(err_msg.getvalue())) + resp.getOutputStream().write(err_msg.getvalue()) + except IllegalStateException, ise: + raise exc # Let the container deal with it + +# +# Standard exception handler +# + +class standard_handler(exception_handler): + + def handle(self, req, resp, environ, exc, exc_info): + raise exc_info[0], exc_info[1], exc_info[2] Modified: branches/indy/Lib/modjy/modjy_impl.py =================================================================== --- branches/indy/Lib/modjy/modjy_impl.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy_impl.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,101 +1,101 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import types -import sys - -from modjy_exceptions import * - -class modjy_impl: - - def deal_with_app_return(self, environ, start_response_callable, app_return): - self.log.debug("Processing app return type: %s" % str(type(app_return))) - if isinstance(app_return, types.StringTypes): - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - if type(app_return) is types.FileType: - pass # TBD: What to do here? can't call fileno() - if hasattr(app_return, '__len__') and callable(app_return.__len__): - expected_pieces = app_return.__len__() - else: - expected_pieces = -1 - try: - try: - ix = 0 - for next_piece in app_return: - if not isinstance(next_piece, types.StringTypes): - raise NonStringOutput("Application returned iterable containing non-strings: %s" % str(type(next_piece))) - if ix == 0: - # The application may have called start_response in the first iteration - if not start_response_callable.called: - raise StartResponseNotCalled("Start_response callable was never called.") - if not start_response_callable.content_length \ - and expected_pieces == 1 \ - and start_response_callable.write_callable.num_writes == 0: - # Take the length of the first piece - start_response_callable.set_content_length(len(next_piece)) - start_response_callable.write_callable(next_piece) - ix += 1 - if ix == expected_pieces: - break - if expected_pieces != -1 and ix != expected_pieces: - raise WrongLength("Iterator len() was wrong. Expected %d pieces: got %d" % (expected_pieces, ix) ) - except AttributeError, ax: - if str(ax) == "__getitem__": - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - else: - raise ax - except TypeError, tx: - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - except ModjyException, mx: - raise mx - except Exception, x: - raise ApplicationException(x) - finally: - if hasattr(app_return, 'close') and callable(app_return.close): - app_return.close() - - def init_impl(self): - self.do_j_env_params() - - def add_packages(self, package_list): - packages = [p.strip() for p in package_list.split(';')] - for p in packages: - self.log.info("Adding java package %s to jython" % p) - sys.add_package(p) - - def add_classdirs(self, classdir_list): - classdirs = [cd.strip() for cd in classdir_list.split(';')] - for cd in classdirs: - self.log.info("Adding directory %s to jython class file search path" % cd) - sys.add_classdir(cd) - - def add_extdirs(self, extdir_list): - extdirs = [ed.strip() for ed in extdir_list.split(';')] - for ed in extdirs: - self.log.info("Adding directory %s for .jars and .zips search path" % ed) - sys.add_extdir(self.expand_relative_path(ed)) - - def do_j_env_params(self): - if self.params['packages']: - self.add_packages(self.params['packages']) - if self.params['classdirs']: - self.add_classdirs(self.params['classdirs']) - if self.params['extdirs']: - self.add_extdirs(self.params['extdirs']) +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import types +import sys + +from modjy_exceptions import * + +class modjy_impl: + + def deal_with_app_return(self, environ, start_response_callable, app_return): + self.log.debug("Processing app return type: %s" % str(type(app_return))) + if isinstance(app_return, types.StringTypes): + raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) + if type(app_return) is types.FileType: + pass # TBD: What to do here? can't call fileno() + if hasattr(app_return, '__len__') and callable(app_return.__len__): + expected_pieces = app_return.__len__() + else: + expected_pieces = -1 + try: + try: + ix = 0 + for next_piece in app_return: + if not isinstance(next_piece, types.StringTypes): + raise NonStringOutput("Application returned iterable containing non-strings: %s" % str(type(next_piece))) + if ix == 0: + # The application may have called start_response in the first iteration + if not start_response_callable.called: + raise StartResponseNotCalled("Start_response callable was never called.") + if not start_response_callable.content_length \ + and expected_pieces == 1 \ + and start_response_callable.write_callable.num_writes == 0: + # Take the length of the first piece + start_response_callable.set_content_length(len(next_piece)) + start_response_callable.write_callable(next_piece) + ix += 1 ... [truncated message content] |