- Timestamp:
- 06/08/09 15:25:46 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/system/pylucid_plugin.py
r2008 r2021 25 25 from django.http import HttpResponse 26 26 from django.core import urlresolvers 27 from django.utils.encoding import smart_str 27 28 from django.utils.importlib import import_module 28 29 from django.conf.urls.defaults import patterns, url … … 89 90 def call_plugin(request, prefix_url, rest_url): 90 91 """ Call a plugin and return the response. """ 92 lang_entry = request.PYLUCID.lang_entry 93 91 94 # 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) 93 96 app_label = pluginpage.app_label 94 97 plugin_urlconf_name = app_label + ".urls" … … 98 101 99 102 # 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) 102 104 if not prefix_url.endswith("/"): 103 105 prefix += "/" … … 196 198 if response == None: 197 199 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 ) 203 211 204 212 # FIXME: A HttpResponse allways convert unicode into string. So we need to do that here: