changeset 622:bc68ca0d2c0a

make annotationServerUrl work with protocol-relative URL (//).
author casties
date Fri, 12 Dec 2014 16:27:58 +0100
parents a7b287122ce8
children 6012fe93f78c
files SrvTxtUtils.py documentViewer.py zpt/viewer/layer_text_annotator.zpt
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/SrvTxtUtils.py	Thu Dec 11 17:24:21 2014 +0100
+++ b/SrvTxtUtils.py	Fri Dec 12 16:27:58 2014 +0100
@@ -280,6 +280,8 @@
         for cnt in range(num_tries):
             try:
                 logging.debug("getHttp(lib2)Data(#%s %ss) url=%s"%(cnt+1,timeout,url))
+                # I would prefer at least disable_ssl_certificate_validation=insecure
+                # but python < 2.7.9 doesn't do SNI :-(
                 h = httplib2.Http(cache=cache, timeout=float(timeout), disable_ssl_certificate_validation=True)
                 if username:
                     h.add_credentials(username, password)
--- a/documentViewer.py	Thu Dec 11 17:24:21 2014 +0100
+++ b/documentViewer.py	Fri Dec 12 16:27:58 2014 +0100
@@ -1161,6 +1161,15 @@
     def getAnnotatorGroupsForUser(self, user, annotationServerUrl="http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager"):
         """returns list of groups {name:*, id:*} on the annotation server for the user"""
         groups = []
+        if annotationServerUrl.startswith('//'):
+            # add matching http(s) from our URL
+            myUrl = self.REQUEST['URL']
+            logging.debug("my URL: %s"%myUrl)
+            if myUrl.startswith('https:'):
+                annotationServerUrl = "https:%s"%annotationServerUrl
+            else:
+                annotationServerUrl = "http:%s"%annotationServerUrl
+            
         groupsUrl = "%s/annotator/groups?user=%s"%(annotationServerUrl,user)
         data = getHttpData(url=groupsUrl, noExceptions=True)
         if data:
--- a/zpt/viewer/layer_text_annotator.zpt	Thu Dec 11 17:24:21 2014 +0100
+++ b/zpt/viewer/layer_text_annotator.zpt	Fri Dec 12 16:27:58 2014 +0100
@@ -27,7 +27,7 @@
   <!-- <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/filter.js"></script> -->
 
   <script type="text/javascript" 
-    tal:define="global annServerUrl string:https://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager;
+    tal:define="global annServerUrl string://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager;
     annUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s?pn=%s'%(docinfo['documentPath'],pageinfo['pn']);
     resUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s'%(docinfo['documentPath']);
     global annUser python:here.getAuthenticatedUser(anon='anonymous');