Commits

hideki nara committed bfa59a5

to avoid SCRIPT_NAME prefix, session key is appended to the tail of urls

Comments (0)

Files changed (3)

bpmobile/middleware.py

             session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
         else:
             #: restore the sesstion key embedded in url 
-            m=re.search(r'\/\((?P<skey>.+)\)(?P<url>.*)',request.path_info )
+            m=re.search(r'^(?P<url>.*);\((?P<skey>.+)\)',request.path_info )
             if m :
                 session_key = m.groupdict()['skey']   
                 request.path_info = m.groupdict()['url']    # rewrite
-                request.path = re.sub(r'\/\((.+)\)(.*)','\g<2>',request.path) #rewrite
+                request.path = re.sub(r'^(.+);\((.+)\)','\g<1>',request.path) #rewrite
             #: otherwise work in the original bpmobile way
             elif request.method == 'GET' and not request.GET.has_key('guid'):
                 # guid=onを付与したURLにリダイレクト

bpmobile/templatetags/mobile.py

 # )
 
 from django.template.defaulttags import url as default_url
+from django.core.urlresolvers import get_script_prefix
+
 class URLNodeMobile(template.Node):
     def __init__(self,urlnode ):
         self.urlnode = urlnode
         if context.has_key('agent') and context['agent'].is_docomo():
             if context.has_key('request'):
                 request = context['request']  
-                ret= "/(%s)%s" % ( request.session.session_key , ret)
+#                ret= "/(%s)%s" % ( request.session.session_key , ret)
+                ret = ret+ ";(%s)"% request.session.session_key 
         return ret 
 
 @register.tag

bpmobile/utils.py

     if request == None or not hasattr(request,'agent') or not request.agent.is_docomo():
         return url
 
-    return "/(%s)%s" % ( request.session.session_key , url)
+    return url + ";(%s)"%  request.session.session_key