Show
Ignore:
Timestamp:
06/08/09 15:25:46 (14 months ago)
Author:
JensDiemer
Message:

add current use lang for get the PluginPage? entry, is that usefull??? See also:  http://pylucid.org/phpBB2/viewtopic.php?t=284

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/system/pylucid_plugin.py

    r2008 r2021  
    2525from django.http import HttpResponse 
    2626from django.core import urlresolvers 
     27from django.utils.encoding import smart_str 
    2728from django.utils.importlib import import_module 
    2829from django.conf.urls.defaults import patterns, url 
     
    8990def call_plugin(request, prefix_url, rest_url): 
    9091    """ Call a plugin and return the response. """ 
     92    lang_entry = request.PYLUCID.lang_entry 
     93     
    9194    # Get the information witch django app would be used 
    92     pluginpage = PluginPage.objects.get(page=request.PYLUCID.pagetree) 
     95    pluginpage = PluginPage.objects.get(page=request.PYLUCID.pagetree, lang=lang_entry) 
    9396    app_label = pluginpage.app_label 
    9497    plugin_urlconf_name = app_label + ".urls" 
     
    98101     
    99102    # build the url prefix 
    100     lang_code = request.PYLUCID.lang_entry.code 
    101     prefix = "^%s/%s" % (lang_code, prefix_url) 
     103    prefix = "^%s/%s" % (lang_entry.code, prefix_url) 
    102104    if not prefix_url.endswith("/"): 
    103105        prefix += "/" 
     
    196198        if response == None: 
    197199            return "" 
    198         assert(isinstance(response, http.HttpResponse), 
    199             "plugin context middleware render() must return a http.HttpResponse instance or None!" 
    200         ) 
    201         result = response.content 
    202         return result 
     200        elif isinstance(response, unicode): 
     201            return smart_str(response, encoding=settings.DEFAULT_CHARSET) 
     202        elif isinstance(response, str): 
     203            return response 
     204        elif isinstance(response, http.HttpResponse): 
     205            return response.content 
     206        else: 
     207            raise RuntimeError( 
     208                "plugin context middleware render() must return" 
     209                " http.HttpResponse instance or a basestring or None!" 
     210            ) 
    203211     
    204212    # FIXME: A HttpResponse allways convert unicode into string. So we need to do that here: