Ejemplo n.º 1
0
 def wrapper(*args, **kwargs):
     template = None
     if len(args) > 0:
         instance = args[0]
         if inspect.isclass(instance.__class__):
             template = path.join(instance.__class__.__name__.lower(),
                                  "%s.html" % f.__name__.lower())
             method_id = "%s.%s" % (instance.__class__.__name__,
                                    f.__name__)
     try:
         result = f(*args, **kwargs)
     except Exception:
         pass
         # TODO: Implement it
     if isinstance(result, tuple):
         model, template = result[0], result[1]
     else:
         model = result
     renderer = ApplicationContext.get_instance().get_object('renderer')
     response = args[2]
     # FIXME: Exception handling if template is None
     # FIXME: Handling from string based templates
     try:
         logger.debug("Rendering model for %s" % method_id)
         content = renderer.process(template, model)
     except Exception, e:
         content = 'Template Fehler: %s' % e
         response.status = 500
Ejemplo n.º 2
0
 def __init__(self, context_config_files):
     """ """
     self.logger = logging.getLogger("seminode.core.runtime.wsgi.WSGIRuntime")
     context_config = []
     if not isinstance(context_config_files, list):
         context_config_files = [context_config_files]
     for cfg in context_config_files:
         file_ext = path.splitext(cfg)[1]
         file_ext = file_ext.strip(".")
         self.logger.debug(file_ext)
         reader = self.config_reader_map.get(file_ext, None)
         if not reader:
             raise SeminodeConfigurationError("No reader found for: %s" % cfg)
         context_config.append(reader(cfg))
     application_context = ApplicationContext(context_config)
     SecurityContextHolder.setStrategy(SecurityContextHolder.MODE_THREADLOCAL)
     SecurityContextHolder.getContext()
     self.wsgi_app = application_context.get_object("filterchain.proxy")
Ejemplo n.º 3
0
 def wrapper(*args, **kwargs):
     if prefix == 'method_id':
         if len(args) > 0:
             instance = args[0]
             if inspect.isclass(instance.__class__):
                 prefix = "%s.%s." % (instance.__class__.__name__,
                                        f.__name__)
     elif prefix is None:
         prefix = ''
     else:
         prefix += '.'
     request = args[1]
     if not request.form.has_key(key):
         pass
         # FIXME: raise Exception
     # TODO: Much more safer form param handling
     cache_key = "%s%s" % (prefix, str(request.form['id']))
     cache = ApplicationContext.get_instance().get_object(context_key)
     result = cache.get(cache_key)
     if result is not None:
         logger.debug("Cache entry found")
         # TODO: Check for pickled content
         return result
     else:
         try:
             result = f(*args, **kwargs)
         except Exception:
             pass
             # TODO: Implement it
         if not isinstance(result, (str, unicode)):
             data = pickle.dumps(result)
             logger.debug("Caching result for %s: %s" % \
                          (key, str(request.form['id'])))
             cache.set(cache_key, data)
         else:
             cache.set(cache_key, result)
         return result