Changeset 5746
- Timestamp:
- 11/22/08 16:44:23 (2 months ago)
- Files:
-
- branches/1.1/turbogears/controllers.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/turbogears/controllers.py
r5728 r5746 325 325 if not template: 326 326 template = format 327 327 328 if format == "json" or (format is None and template is None): 328 329 template = "json" 329 330 allow_json = True 331 330 332 if content_type is None: 331 333 content_type = config.get("tg.content_type", None) … … 376 378 def _execute_func(func, template, format, content_type, mapping, fragment, args, kw): 377 379 """Call controller method and process it's output.""" 380 378 381 if config.get("tg.strict_parameters", False): 379 382 tg_util.remove_keys(kw, ["tg_random", "tg_format"] 380 383 + config.get("tg.ignore_parameters", [])) 384 381 385 else: 382 386 # get special parameters used by upstream decorators like paginate 383 387 try: 384 388 tg_kw = dict([(k, v) for k, v in kw.items() if k in func._tg_args]) 389 385 390 except AttributeError: 386 391 tg_kw = {} 392 387 393 # remove excessive parameters 388 394 args, kw = tg_util.adapt_call(func, args, kw) 389 395 # add special parameters again 390 396 kw.update(tg_kw) 397 391 398 if config.get('server.environment', 'development') == 'development': 392 399 # Only output this in development mode: If it's a field storage object, 393 400 # this means big memory usage, and we don't want that in production 394 401 log.debug("Calling %s with *(%s), **(%s)", func, args, kw) 402 395 403 output = errorhandling.try_call(func, *args, **kw) 396 404 if isinstance(output, list): 397 405 return output 406 398 407 if str(getattr(response, 'status', '')).startswith('204'): 399 408 # HTTP status 204 indicates a response with no body … … 401 410 try: 402 411 del response.headers['Content-Type'] 412 403 413 except (AttributeError, KeyError): pass 404 414 return 415 405 416 else: 406 417 assert isinstance(output, basestring) or isinstance(output, dict) \ … … 409 420 "be of type basestring, dict or generator." % ( 410 421 args[0].__class__.__name__, fun.__name__) 422 411 423 if isinstance(output, dict): 412 424 template = output.pop("tg_template", template) 413 425 format = output.pop("tg_format", format) 426 414 427 if template and template.startswith("."): 415 428 template = func.__module__[:func.__module__.rfind('.')]+template 429 416 430 return _process_output(output, template, format, content_type, mapping, 417 431 fragment)