X Tutup
Skip to content

Commit 369ac96

Browse files
committed
SESPRINGPYTHONPY-128: Synched to trunk.
git-svn-id: https://src.springframework.org/svn/se-springpython-py/sandbox/gregturnquist/sespringpythonpy-128@745 ce8fead1-4192-4296-8608-a705134b927f
1 parent d6f0ed5 commit 369ac96

File tree

6 files changed

+40
-27
lines changed

6 files changed

+40
-27
lines changed

build.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ def publish(filepath, s3bucket, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, versio
240240
filename = filepath.split("/")[-1]
241241
s3key = "/".join([ p['release.type'],
242242
p['project.key'],
243-
p['natural.name'],
244243
filename ])
245244

246245
print "Reading in content from %s" % filepath

src/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
license='Apache Software License (http://www.apache.org/licenses/LICENSE-2.0)',
3434
scripts=['plugins/coily'],
3535
packages=['springpython',
36-
'springpython.aop',
36+
'springpython.aop',
37+
'springpython.jms',
3738
'springpython.config',
3839
'springpython.container',
3940
'springpython.context',

src/springpython/context/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import atexit
1818
import logging
19+
from traceback import format_exc
1920

20-
from springpython.util import get_last_traceback
2121
from springpython.container import ObjectContainer
2222

2323
class ApplicationContext(ObjectContainer):
@@ -31,7 +31,7 @@ def __init__(self, config = None):
3131
atexit.register(self.shutdown_hook)
3232

3333
self.logger = logging.getLogger("springpython.context.ApplicationContext")
34-
self.classnames_to_avoid = set(["PyroProxyFactory"])
34+
self.classnames_to_avoid = set(["PyroProxyFactory", "ProxyFactoryObject"])
3535

3636
for object_def in self.object_defs.values():
3737
self._apply(object_def)
@@ -97,7 +97,7 @@ def shutdown_hook(self):
9797
destroy_method = getattr(obj, destroy_method_name)
9898

9999
except Exception, e:
100-
self.logger.error("Could not destroy object '%s', exception '%s'" % (obj_name, get_last_traceback(e)))
100+
self.logger.error("Could not destroy object '%s', exception '%s'" % (obj_name, format_exc()))
101101

102102
else:
103103
if callable(destroy_method):
@@ -106,7 +106,7 @@ def shutdown_hook(self):
106106
destroy_method()
107107
self.logger.debug("Successfully destroyed object '%s'" % obj_name)
108108
except Exception, e:
109-
self.logger.error("Could not destroy object '%s', exception '%s'" % (obj_name, get_last_traceback(e)))
109+
self.logger.error("Could not destroy object '%s', exception '%s'" % (obj_name, format_exc()))
110110
else:
111111
self.logger.error("Could not destroy object '%s', " \
112112
"the 'destroy_method' attribute it defines is not callable, " \

src/springpython/jms/factory.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from xml.sax.saxutils import escape
2424
from binascii import hexlify, unhexlify
2525
from time import time, mktime, strptime, altzone
26+
from traceback import format_exc
2627

2728
try:
2829
import cElementTree as etree
@@ -35,7 +36,7 @@
3536
# Spring Python
3637
from springpython.context import DisposableObject
3738
from springpython.jms.core import reserved_attributes, TextMessage
38-
from springpython.util import TRACE1, get_last_traceback, synchronized
39+
from springpython.util import TRACE1, synchronized
3940
from springpython.jms import JMSException, WebSphereMQJMSException, \
4041
NoMessageAvailableException, DELIVERY_MODE_NON_PERSISTENT, \
4142
DELIVERY_MODE_PERSISTENT
@@ -138,7 +139,7 @@ def destroy(self):
138139
self.logger.info("Caches cleared")
139140
except Exception, e:
140141
try:
141-
self.logger.error("Could not clear the caches. Exception [%s]" % get_last_traceback(e))
142+
self.logger.error("Could not clear the caches. Exception [%s]" % format_exc())
142143
except:
143144
pass
144145
try:
@@ -148,7 +149,7 @@ def destroy(self):
148149
except Exception, e:
149150
try:
150151
self.logger.error("Could not disconnect from queue manager [%s], exception [%s] " % (self.queue_manager,
151-
get_last_traceback(e)))
152+
format_exc()))
152153
except Exception:
153154
pass
154155

src/springpython/security/web.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ def doNextFilter(self, environ, start_response):
3838
results = None
3939
try:
4040
nextFilter = environ["SPRINGPYTHON_FILTER_CHAIN"].next()
41-
results = nextFilter(environ, start_response)
41+
if isinstance(nextFilter, tuple):
42+
func = nextFilter[0]
43+
args = nextFilter[1]
44+
results = func(args)
45+
else:
46+
results = nextFilter(environ, start_response)
4247
except StopIteration:
4348
pass
4449

@@ -110,10 +115,27 @@ def __call__(self, environ, start_response):
110115
class CP3FilterChainProxy(FilterChainProxy):
111116
def __init__(self, filterInvocationDefinitionSource=None):
112117
FilterChainProxy.__init__(self, filterInvocationDefinitionSource)
113-
cherrypy.tools.filterChainProxy = cherrypy.Tool('before_handler', self, priority=75)
118+
self.logger = logging.getLogger("springpython.security.web.CP3FilterChainProxy")
119+
cherrypy.tools.filterChainProxy = cherrypy._cptools.HandlerTool(self)
114120

115121
def __call__(self, environ=None, start_response=None):
116-
return FilterChainProxy.__call__(self, cherrypy.request.wsgi_environ, start_response)
122+
innerfunc = cherrypy.request.handler
123+
def mini_app(*args, **kwargs):
124+
def cherrypy_wrapper(nexthandler, *args, **kwargs):
125+
results = nexthandler(*args, **kwargs)
126+
self.logger.debug("Results = %s" % results)
127+
return results
128+
return cherrypy_wrapper(innerfunc, *args, **kwargs)
129+
130+
self.application = (self.invoke, (mini_app,))
131+
132+
# Store the final results...
133+
cherrypy.response.body = FilterChainProxy.__call__(self, cherrypy.request.wsgi_environ, None)
134+
#...and then signal there is no more handling for CherryPy to do.
135+
return True
136+
137+
def invoke(self, args):
138+
return args[0]()
117139

118140
class SessionStrategy(object):
119141
"""

src/springpython/util.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,31 @@
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
14-
limitations under the License.
14+
limitations under the License.
1515
"""
1616
import logging
1717
import traceback
18-
1918
from threading import RLock, currentThread
2019

2120
try:
2221
from cStringIO import StringIO
2322
except ImportError, e:
2423
from StringIO import StringIO
25-
26-
24+
25+
2726
TRACE1 = 6
2827
logging.addLevelName(TRACE1, "TRACE1")
2928

30-
31-
def get_last_traceback(exception):
32-
""" A utility function for better displaying exceptions.
33-
"""
34-
buff = StringIO()
35-
traceback.print_exc(file=buff)
36-
37-
return buff.getvalue()
38-
3929
# Original code by Anand Balachandran Pillai (abpillai at gmail.com)
4030
# http://code.activestate.com/recipes/533135/
4131
class synchronized(object):
4232
""" Class enapsulating a lock and a function allowing it to be used as
4333
a synchronizing decorator making the wrapped function thread-safe """
44-
34+
4535
def __init__(self, *args):
4636
self.lock = RLock()
4737
self.logger = logging.getLogger("springpython.util.synchronized")
48-
38+
4939
def __call__(self, f):
5040
def lockedfunc(*args, **kwargs):
5141
try:

0 commit comments

Comments
 (0)
X Tutup