Index: publish.py =================================================================== RCS file: /projects/cvsroot/mems/quixote/publish.py,v retrieving revision 1.120 diff -u -r1.120 publish.py --- publish.py 16 May 2002 21:33:50 -0000 1.120 +++ publish.py 23 May 2002 15:30:40 -0000 @@ -507,7 +507,7 @@ component = "_q_index" object = self.get_component(object, component, path, request) - if not callable(object): + if not (isstring(object) or callable(object)): # We went through all the components of the path and ended up at # something which isn't callable, like a module or an instance # without a __call__ method. @@ -557,20 +557,27 @@ if object is None: return None - # Anything else must be a callable object... - if not callable(object): - raise RuntimeError, "object not callable: %s" % repr(object) + # Anything else must be either a string... + if isstring(object): + output = object + + # ...or a callable. + elif callable(object): + try: + output = object(request) + except SystemExit: + output = "SystemExit exception caught, shutting down" + self.log(output) + self.exit_now = 1 - # ...so call it. - try: - output = object(request) - except SystemExit: - output = "SystemExit exception caught, shutting down" - self.log(output) - self.exit_now = 1 + if output is None: + raise RuntimeError, 'callable %s returned None' % repr(object) + + # Uh-oh: 'object' is neither a string nor a callable. + else: + raise RuntimeError( + "object is neither callable nor a string: %s" % repr(object)) - if output is None: - raise RuntimeError, 'callable %s returned None' % repr(object) # The callable ran OK, commit any changes to the session self.finish_successful_request(request) @@ -739,3 +746,6 @@ else: return session.user + +def isstring (x): + return type(x) in (types.StringType, types.InstanceType)