[KSS-checkins] r46037 - kukit/kss.pylons/trunk/kss/pylons

jvloothuis at codespeak.net jvloothuis at codespeak.net
Mon Aug 27 17:23:58 CEST 2007


Author: jvloothuis
Date: Mon Aug 27 17:23:55 2007
New Revision: 46037

Modified:
   kukit/kss.pylons/trunk/kss/pylons/helpers.py
Log:
Cleanup helpers by reusing routes instead of generating the base tag url ourselves. This has the added advantage that you can easily setup all KSS requests to go to a specific controller.


Modified: kukit/kss.pylons/trunk/kss/pylons/helpers.py
==============================================================================
--- kukit/kss.pylons/trunk/kss/pylons/helpers.py	(original)
+++ kukit/kss.pylons/trunk/kss/pylons/helpers.py	Mon Aug 27 17:23:55 2007
@@ -1,6 +1,5 @@
 import os
-from urllib import quote
-from routes import request_config
+from routes import url_for
 
 javascript_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'kukit')
@@ -33,27 +32,8 @@
     tag = '<script type="text/javascript" src="/kukit/%s"></script>'
     return ''.join([tag % script for script in java_scripts])
 
-def kss_base_tag():
-    config = request_config()
-    environ = config.environ
-
-    url = environ['wsgi.url_scheme']+'://'
-
-    if environ.get('HTTP_HOST'):
-        url += environ['HTTP_HOST']
-    else:
-        url += environ['SERVER_NAME']
-
-        if environ['wsgi.url_scheme'] == 'https':
-            if environ['SERVER_PORT'] != '443':
-               url += ':' + environ['SERVER_PORT']
-        else:
-            if environ['SERVER_PORT'] != '80':
-               url += ':' + environ['SERVER_PORT']
-
-    url += quote(environ.get('SCRIPT_NAME',''))
-
-    return '<base href="%s"/>' % url
+def kss_base_tag(**kwargs):
+    return '<base href="%s"/>' % url_for(**kwargs)
 
 def kss_class_attributes(**kwargs):
     return ' '.join(['kssattr-%s-%s' % item for item in kwargs.items()])


More information about the Kukit-checkins mailing list