Index: SrvTxtUtils.py
===================================================================
--- SrvTxtUtils.py	(revision 528)
+++ SrvTxtUtils.py	(revision 546)
@@ -12,5 +12,5 @@
 
 
-srvTxtUtilsVersion = "1.4.1"
+srvTxtUtilsVersion = "1.5"
 
 def getInt(number, default=0):
@@ -38,5 +38,5 @@
             return s.decode('latin-1')
     else:
-        return unicode(s)
+        return s
 
 def utf8ify(s):
@@ -48,5 +48,5 @@
         return s
     else:
-        return unicode(s).encode('utf-8')
+        return s.encode('utf-8')
 
 def getText(node, recursive=0):
@@ -76,5 +76,5 @@
 
 
-def getHttpData(url, data=None, num_tries=3, timeout=10):
+def getHttpData(url, data=None, num_tries=3, timeout=10, noExceptions=False):
     """returns result from url+data HTTP request"""
     # we do GET (by appending data to url)
@@ -117,4 +117,7 @@
         return data
     
+    if noExceptions:
+        return None
+    
     raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg))
     #return None
Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 543)
+++ documentViewer.py	(revision 546)
@@ -127,6 +127,6 @@
     viewer_index = PageTemplateFile('zpt/viewer_index', globals())
     viewer_thumbs = PageTemplateFile('zpt/viewer_thumbs', globals())
-    # available layer types
-    builtinLayers = {'text': ['dict','search','gis','annotator'],
+    # available layer types (annotator not default)
+    builtinLayers = {'text': ['dict','search','gis'],
                      'xml': None, 'images': None, 'index': None}
     availableLayers = builtinLayers;
@@ -317,16 +317,4 @@
         return pt(docinfo=docinfo, pageinfo=pageinfo)
   
-    #WTF?
-    def generateMarks(self,mk):
-        ret=""
-        if mk is None:
-            return ""
-        if not isinstance(mk, list):
-            mk=[mk]
-        for m in mk:
-            ret+="mk=%s"%m
-        return ret
-    
-    
     def getAvailableLayers(self):
         """returns dict with list of available layers per viewMode"""
@@ -986,4 +974,20 @@
         
 
+    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 = []
+        groupsUrl = "%s/annotator/groups?user=%s"%(annotationServerUrl,user)
+        data = getHttpData(url=groupsUrl, noExceptions=True)
+        if data:
+            res = json.loads(data)
+            rows = res.get('rows', None)
+            if rows is None:
+                return groups
+            for r in rows:
+                groups.append({'id': r.get('id', None), 'name': r.get('name', None), 'uri': r.get('uri', None)})
+                
+        return groups
+    
+
     security.declareProtected('View management screens','changeDocumentViewerForm')    
     changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals())
Index: zpt/layer_text_annotator.zpt
===================================================================
--- zpt/layer_text_annotator.zpt	(revision 531)
+++ zpt/layer_text_annotator.zpt	(revision 546)
@@ -34,6 +34,9 @@
 
   <script type="text/javascript" 
-    tal:define="annUrl python:'%s?url=%s&pn=%s'%(rootUrl,docinfo['url'],pageinfo['pn']); annUser python:here.getAuthenticatedUser(anon='anonymous');"
-    tal:content="structure string:var annotatorPageUrl='$annUrl'; var annotatorUser='$annUser';"></script>
+    tal:define="annUrl python:'%s?url=%s&pn=%s'%(rootUrl,docinfo['url'],pageinfo['pn']); 
+      global annUser python:here.getAuthenticatedUser(anon='anonymous');
+      global annGroup python:request.get('annotator_group', None);
+      permUser python:test(annGroup, 'group:%s'%annGroup, annUser);"
+    tal:content="structure string:var annotatorPageUrl='$annUrl'; var annotatorUser='$annUser'; var permissionUser='$permUser';"></script>
 
   <script type="text/javascript">
@@ -46,5 +49,5 @@
                     tokenUrl : 'template/token?user='+annotatorUser
                 }).addPlugin('Permissions', {
-                    user : annotatorUser,
+                    user : permissionUser,
                     userString : function(user) {
                         if (user && user.name) {
@@ -60,5 +63,6 @@
                     }
                 }).addPlugin('Store', {
-                    prefix: 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator',
+                    //prefix: 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator',
+                    prefix: 'http://r583-1.mpiwg-berlin.mpg.de:18080/AnnotationManager/annotator',
                     annotationData : {
                         'uri' : uri
@@ -89,7 +93,24 @@
   <metal:block metal:define-macro="options_box" tal:condition="python:'annotator' in viewLayers">
     <!-- BEGIN ANNOTATIONS -->
-    <div class="options" tal:define="annUser python:here.getAuthenticatedUser(anon='anonymous')">
+    <div class="options">
       <h4>Annotations</h4>
-      <div>You are user "<span tal:replace="annUser"/>"</div>
+      <p>
+        User "<span tal:replace="annUser" />"<span tal:condition="annGroup" tal:content="string: ($annGroup)"/>.
+      </p>
+      <!-- TODO: login button -->
+      <form class="autosubmit" tal:attributes="action viewerUrl">
+        <input type="hidden" tal:define="params python:here.getParams(params={'annotator_group':None});" tal:repeat="param params"
+          tal:attributes="name param; value python:params[param]" />
+        <p>
+          In group
+          <select class="autosubmit" name="annotator_group">
+            <option value="" tal:attributes="selected not:annGroup;"> </option>
+            <option
+              tal:repeat="group python:here.getAnnotatorGroupsForUser(user=annUser,annotationServerUrl='http://localhost:18080/AnnotationManager')"
+              tal:attributes="value group/id; selected python:group['id']==annGroup;" tal:content="group/name" />
+          </select> <br /> 
+          <input type="submit" value="Go!" />
+        </p>
+      </form>
     </div>
     <!-- END ANNOTATIONS -->
