Mercurial > hg > documentViewer
annotate documentViewer.py @ 231:a88ece9a5e74
*** empty log message ***
author | abukhman |
---|---|
date | Mon, 11 Oct 2010 15:12:16 +0200 |
parents | 87c6aac31003 |
children | 0813585df9f4 |
rev | line source |
---|---|
46 | 1 |
0 | 2 from OFS.Folder import Folder |
3 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate | |
52 | 4 from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
0 | 5 from AccessControl import ClassSecurityInfo |
32 | 6 from AccessControl import getSecurityManager |
0 | 7 from Globals import package_home |
231 | 8 from Products.zogiLib import browserCheck |
0 | 9 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
10 from Ft.Xml import EMPTY_NAMESPACE, Parse |
134 | 11 import Ft.Xml.Domlette |
0 | 12 import os.path |
31 | 13 import sys |
0 | 14 import urllib |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
15 import urllib2 |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
16 import logging |
61 | 17 import math |
46 | 18 import urlparse |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
19 import cStringIO |
174 | 20 import re |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
21 |
231 | 22 |
52 | 23 def logger(txt,method,txt2): |
24 """logging""" | |
25 logging.info(txt+ txt2) | |
26 | |
27 | |
25 | 28 def getInt(number, default=0): |
29 """returns always an int (0 in case of problems)""" | |
30 try: | |
31 return int(number) | |
32 except: | |
62 | 33 return int(default) |
25 | 34 |
0 | 35 def getTextFromNode(nodename): |
46 | 36 """get the cdata content of a node""" |
32 | 37 if nodename is None: |
38 return "" | |
0 | 39 nodelist=nodename.childNodes |
40 rc = "" | |
41 for node in nodelist: | |
42 if node.nodeType == node.TEXT_NODE: | |
43 rc = rc + node.data | |
44 return rc | |
45 | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
46 def serializeNode(node, encoding='utf-8'): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
47 """returns a string containing node as XML""" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
48 buf = cStringIO.StringIO() |
136 | 49 Ft.Xml.Domlette.Print(node, stream=buf, encoding=encoding) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
50 s = buf.getvalue() |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
51 buf.close() |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
52 return s |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
53 |
35 | 54 |
55 def getParentDir(path): | |
56 """returns pathname shortened by one""" | |
57 return '/'.join(path.split('/')[0:-1]) | |
58 | |
59 | |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
60 def getHttpData(url, data=None, num_tries=3, timeout=10): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
61 """returns result from url+data HTTP request""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
62 # we do GET (by appending data to url) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
63 if isinstance(data, str) or isinstance(data, unicode): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
64 # if data is string then append |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
65 url = "%s?%s"%(url,data) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
66 elif isinstance(data, dict) or isinstance(data, list) or isinstance(data, tuple): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
67 # urlencode |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
68 url = "%s?%s"%(url,urllib.urlencode(data)) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
69 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
70 response = None |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
71 errmsg = None |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
72 for cnt in range(num_tries): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
73 try: |
167 | 74 logging.debug("getHttpData(#%s %ss) url=%s"%(cnt+1,timeout,url)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
75 if sys.version_info < (2, 6): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
76 # set timeout on socket -- ugly :-( |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
77 import socket |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
78 socket.setdefaulttimeout(float(timeout)) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
79 response = urllib2.urlopen(url) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
80 else: |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
81 response = urllib2.urlopen(url,timeout=float(timeout)) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
82 # check result? |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
83 break |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
84 except urllib2.HTTPError, e: |
167 | 85 logging.error("getHttpData: HTTP error(%s): %s"%(e.code,e)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
86 errmsg = str(e) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
87 # stop trying |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
88 break |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
89 except urllib2.URLError, e: |
167 | 90 logging.error("getHttpData: URLLIB error(%s): %s"%(e.reason,e)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
91 errmsg = str(e) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
92 # stop trying |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
93 #break |
0 | 94 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
95 if response is not None: |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
96 data = response.read() |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
97 response.close() |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
98 return data |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
99 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
100 raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg)) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
101 #return None |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
102 |
0 | 103 |
104 | |
22 | 105 ## |
106 ## documentViewer class | |
107 ## | |
108 class documentViewer(Folder): | |
0 | 109 """document viewer""" |
110 meta_type="Document viewer" | |
111 | |
112 security=ClassSecurityInfo() | |
22 | 113 manage_options=Folder.manage_options+( |
0 | 114 {'label':'main config','action':'changeDocumentViewerForm'}, |
115 ) | |
116 | |
22 | 117 # templates and forms |
118 viewer_main = PageTemplateFile('zpt/viewer_main', globals()) | |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
119 toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
120 toc_text = PageTemplateFile('zpt/toc_text', globals()) |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
121 toc_figures = PageTemplateFile('zpt/toc_figures', globals()) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
122 page_main_images = PageTemplateFile('zpt/page_main_images', globals()) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
123 page_main_text = PageTemplateFile('zpt/page_main_text', globals()) |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
124 page_main_text_dict = PageTemplateFile('zpt/page_main_text_dict', globals()) |
140 | 125 page_main_gis =PageTemplateFile ('zpt/page_main_gis', globals()) |
99 | 126 page_main_xml = PageTemplateFile('zpt/page_main_xml', globals()) |
22 | 127 head_main = PageTemplateFile('zpt/head_main', globals()) |
128 docuviewer_css = PageTemplateFile('css/docuviewer.css', globals()) | |
57 | 129 info_xml = PageTemplateFile('zpt/info_xml', globals()) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
130 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
131 |
68 | 132 thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) |
22 | 133 security.declareProtected('View management screens','changeDocumentViewerForm') |
134 changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals()) | |
135 | |
0 | 136 |
95 | 137 def __init__(self,id,imageScalerUrl=None,textServerName=None,title="",digilibBaseUrl=None,thumbcols=2,thumbrows=5,authgroups="mpiwg"): |
0 | 138 """init document viewer""" |
139 self.id=id | |
140 self.title=title | |
25 | 141 self.thumbcols = thumbcols |
142 self.thumbrows = thumbrows | |
32 | 143 # authgroups is list of authorized groups (delimited by ,) |
144 self.authgroups = [s.strip().lower() for s in authgroups.split(',')] | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
145 # create template folder so we can always use template.something |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
146 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
147 templateFolder = Folder('template') |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
148 #self['template'] = templateFolder # Zope-2.12 style |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
149 self._setObject('template',templateFolder) # old style |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
150 try: |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
151 import MpdlXmlTextServer |
132 | 152 textServer = MpdlXmlTextServer.MpdlXmlTextServer(id='fulltextclient',serverName=textServerName) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
153 #templateFolder['fulltextclient'] = xmlRpcClient |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
154 templateFolder._setObject('fulltextclient',textServer) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
155 except Exception, e: |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
156 logging.error("Unable to create MpdlXmlTextServer for fulltextclient: "+str(e)) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
157 try: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
158 from Products.zogiLib.zogiLib import zogiLib |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
159 zogilib = zogiLib(id="zogilib", title="zogilib for docuviewer", dlServerURL=imageScalerUrl, layout="book") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
160 #templateFolder['zogilib'] = zogilib |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
161 templateFolder._setObject('zogilib',zogilib) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
162 except Exception, e: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
163 logging.error("Unable to create zogiLib for zogilib: "+str(e)) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
164 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
165 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
166 # proxy text server methods to fulltextclient |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
167 def getTextPage(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
168 """get page""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
169 return self.template.fulltextclient.getTextPage(**args) |
22 | 170 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
171 def getQuery(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
172 """get query""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
173 return self.template.fulltextclient.getQuery(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
174 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
175 def getSearch(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
176 """get search""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
177 return self.template.fulltextclient.getSearch(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
178 |
133 | 179 def getNumPages(self, docinfo): |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
180 """get numpages""" |
133 | 181 return self.template.fulltextclient.getNumPages(docinfo) |
191 | 182 |
183 def getNumTextPages(self, docinfo): | |
184 """get numpages text""" | |
185 return self.template.fulltextclient.getNumTextPages(docinfo) | |
186 | |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
187 def getTranslate(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
188 """get translate""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
189 return self.template.fulltextclient.getTranslate(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
190 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
191 def getLemma(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
192 """get lemma""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
193 return self.template.fulltextclient.getLemma(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
194 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
195 def getToc(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
196 """get toc""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
197 return self.template.fulltextclient.getToc(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
198 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
199 def getTocPage(self, **args): |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
200 """get tocpage""" |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
201 return self.template.fulltextclient.getTocPage(**args) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
202 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
203 |
68 | 204 security.declareProtected('View','thumbs_rss') |
205 def thumbs_rss(self,mode,url,viewMode="auto",start=None,pn=1): | |
206 ''' | |
207 view it | |
208 @param mode: defines how to access the document behind url | |
209 @param url: url which contains display information | |
210 @param viewMode: if images display images, if text display text, default is images (text,images or auto) | |
211 | |
212 ''' | |
167 | 213 logging.debug("HHHHHHHHHHHHHH:load the rss") |
214 logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) | |
68 | 215 |
216 if not hasattr(self, 'template'): | |
217 # create template folder if it doesn't exist | |
218 self.manage_addFolder('template') | |
219 | |
220 if not self.digilibBaseUrl: | |
221 self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" | |
222 | |
223 docinfo = self.getDocinfo(mode=mode,url=url) | |
224 pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) | |
225 pt = getattr(self.template, 'thumbs_main_rss') | |
226 | |
227 if viewMode=="auto": # automodus gewaehlt | |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
228 if docinfo.has_key("textURL") or docinfo.has_key('textURLPath'): #texturl gesetzt und textViewer konfiguriert |
68 | 229 viewMode="text" |
230 else: | |
231 viewMode="images" | |
232 | |
233 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) | |
234 | |
22 | 235 security.declareProtected('View','index_html') |
170 | 236 def index_html(self,url,mode="texttool",viewMode="auto",tocMode="thumbs",start=None,pn=1,mk=None, query=None, querySearch=None, characterNormalization=""): |
22 | 237 ''' |
238 view it | |
57 | 239 @param mode: defines how to access the document behind url |
22 | 240 @param url: url which contains display information |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
241 @param viewMode: if images display images, if text display text, default is auto (text,images or auto) |
99 | 242 @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) |
141 | 243 @param characterNormalization type of text display (reg, norm, none) |
100 | 244 @param querySearch: type of different search modes (fulltext, fulltextMorph, xpath, xquery, ftIndex, ftIndexMorph, fulltextMorphLemma) |
22 | 245 ''' |
0 | 246 |
167 | 247 logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) |
22 | 248 |
249 if not hasattr(self, 'template'): | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
250 # this won't work |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
251 logging.error("template folder missing!") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
252 return "ERROR: template folder missing!" |
22 | 253 |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
254 if not getattr(self, 'digilibBaseUrl', None): |
132 | 255 self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" |
22 | 256 |
25 | 257 docinfo = self.getDocinfo(mode=mode,url=url) |
97 | 258 |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
259 if tocMode != "thumbs": |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
260 # get table of contents |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
261 docinfo = self.getToc(mode=tocMode, docinfo=docinfo) |
97 | 262 |
51
c5d3aabbf61b
textviewer now integrated, new modus auto introduced as standard for viewing
dwinter
parents:
50
diff
changeset
|
263 if viewMode=="auto": # automodus gewaehlt |
132 | 264 if docinfo.has_key('textURL') or docinfo.has_key('textURLPath'): #texturl gesetzt und textViewer konfiguriert |
127 | 265 viewMode="text_dict" |
51
c5d3aabbf61b
textviewer now integrated, new modus auto introduced as standard for viewing
dwinter
parents:
50
diff
changeset
|
266 else: |
c5d3aabbf61b
textviewer now integrated, new modus auto introduced as standard for viewing
dwinter
parents:
50
diff
changeset
|
267 viewMode="images" |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
268 |
170 | 269 pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo,viewMode=viewMode,tocMode=tocMode) |
127 | 270 |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
271 pt = getattr(self.template, 'viewer_main') |
75
9673218e155b
minorCVS: ----------------------------------------------------------------------
dwinter
parents:
74
diff
changeset
|
272 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk)) |
0 | 273 |
74 | 274 def generateMarks(self,mk): |
275 ret="" | |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
276 if mk is None: |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
277 return "" |
134 | 278 if not isinstance(mk, list): |
132 | 279 mk=[mk] |
74 | 280 for m in mk: |
75
9673218e155b
minorCVS: ----------------------------------------------------------------------
dwinter
parents:
74
diff
changeset
|
281 ret+="mk=%s"%m |
74 | 282 return ret |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
283 |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
284 |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
285 def findDigilibUrl(self): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
286 """try to get the digilib URL from zogilib""" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
287 url = self.template.zogilib.getDLBaseUrl() |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
288 return url |
126 | 289 |
290 def getDocumentViewerURL(self): | |
291 """returns the URL of this instance""" | |
292 return self.absolute_url() | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
293 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
294 def getStyle(self, idx, selected, style=""): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
295 """returns a string with the given style and append 'sel' if path == selected.""" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
296 #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
297 if idx == selected: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
298 return style + 'sel' |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
299 else: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
300 return style |
74 | 301 |
25 | 302 def getLink(self,param=None,val=None): |
303 """link to documentviewer with parameter param set to val""" | |
35 | 304 params=self.REQUEST.form.copy() |
25 | 305 if param is not None: |
31 | 306 if val is None: |
307 if params.has_key(param): | |
308 del params[param] | |
25 | 309 else: |
35 | 310 params[param] = str(val) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
311 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
312 if params.get("mode", None) == "filepath": #wenn beim erst Aufruf filepath gesetzt wurde aendere das nun zu imagepath |
78 | 313 params["mode"] = "imagepath" |
314 params["url"] = getParentDir(params["url"]) | |
31 | 315 |
35 | 316 # quote values and assemble into query string |
135 | 317 #ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
318 ps = urllib.urlencode(params) | |
35 | 319 url=self.REQUEST['URL1']+"?"+ps |
25 | 320 return url |
321 | |
68 | 322 def getLinkAmp(self,param=None,val=None): |
323 """link to documentviewer with parameter param set to val""" | |
324 params=self.REQUEST.form.copy() | |
325 if param is not None: | |
326 if val is None: | |
327 if params.has_key(param): | |
328 del params[param] | |
329 else: | |
330 params[param] = str(val) | |
331 | |
332 # quote values and assemble into query string | |
167 | 333 logging.debug("XYXXXXX: %s"%repr(params.items())) |
68 | 334 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) |
335 url=self.REQUEST['URL1']+"?"+ps | |
336 return url | |
81
fae97f071724
fixed problem with info.xml when url without index.meta
casties
parents:
79
diff
changeset
|
337 |
57 | 338 def getInfo_xml(self,url,mode): |
339 """returns info about the document as XML""" | |
340 | |
341 if not self.digilibBaseUrl: | |
342 self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" | |
343 | |
344 docinfo = self.getDocinfo(mode=mode,url=url) | |
345 pt = getattr(self.template, 'info_xml') | |
346 return pt(docinfo=docinfo) | |
347 | |
0 | 348 |
35 | 349 def isAccessible(self, docinfo): |
32 | 350 """returns if access to the resource is granted""" |
351 access = docinfo.get('accessType', None) | |
167 | 352 logging.debug("documentViewer (accessOK) access type %s"%access) |
45 | 353 if access is not None and access == 'free': |
167 | 354 logging.debug("documentViewer (accessOK) access is free") |
32 | 355 return True |
45 | 356 elif access is None or access in self.authgroups: |
35 | 357 # only local access -- only logged in users |
358 user = getSecurityManager().getUser() | |
167 | 359 logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr())) |
35 | 360 if user is not None: |
361 #print "user: ", user | |
362 return (user.getUserName() != "Anonymous User") | |
363 else: | |
364 return False | |
32 | 365 |
167 | 366 logging.error("documentViewer (accessOK) unknown access type %s"%access) |
32 | 367 return False |
35 | 368 |
32 | 369 |
73 | 370 def getDirinfoFromDigilib(self,path,docinfo=None,cut=0): |
29 | 371 """gibt param von dlInfo aus""" |
31 | 372 if docinfo is None: |
373 docinfo = {} | |
73 | 374 |
375 for x in range(cut): | |
78 | 376 |
73 | 377 path=getParentDir(path) |
78 | 378 |
40 | 379 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path |
29 | 380 |
167 | 381 logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl)) |
29 | 382 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
383 txt = getHttpData(infoUrl) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
384 if txt is None: |
40 | 385 raise IOError("Unable to get dir-info from %s"%(infoUrl)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
386 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
387 dom = Parse(txt) |
37 | 388 sizes=dom.xpath("//dir/size") |
167 | 389 logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes) |
29 | 390 |
37 | 391 if sizes: |
392 docinfo['numPages'] = int(getTextFromNode(sizes[0])) | |
31 | 393 else: |
394 docinfo['numPages'] = 0 | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
395 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
396 # TODO: produce and keep list of image names and numbers |
31 | 397 |
398 return docinfo | |
32 | 399 |
174 | 400 def getIndexMetaPath(self,url): |
401 """gib nur den Pfad zurueck""" | |
402 regexp = re.compile(r".*(experimental|permanent)/(.*)") | |
403 regpath = regexp.match(url) | |
404 if (regpath==None): | |
405 return "" | |
224 | 406 logging.debug("(getDomFromIndexMeta): URLXAXA: %s"%regpath.group(2)) |
174 | 407 return ("/mpiwg/online/"+regpath.group(1)+"/"+regpath.group(2)) |
408 | |
225 | 409 |
410 | |
174 | 411 def getIndexMetaUrl(self,url): |
412 """returns utr of index.meta document at url""" | |
413 | |
39
1dd90aabd366
added retry when reading index meta from texter applet
casties
parents:
38
diff
changeset
|
414 metaUrl = None |
35 | 415 if url.startswith("http://"): |
416 # real URL | |
39
1dd90aabd366
added retry when reading index meta from texter applet
casties
parents:
38
diff
changeset
|
417 metaUrl = url |
35 | 418 else: |
419 # online path | |
420 server=self.digilibBaseUrl+"/servlet/Texter?fn=" | |
40 | 421 metaUrl=server+url.replace("/mpiwg/online","") |
35 | 422 if not metaUrl.endswith("index.meta"): |
423 metaUrl += "/index.meta" | |
174 | 424 |
425 return metaUrl | |
426 | |
427 def getDomFromIndexMeta(self, url): | |
428 """get dom from index meta""" | |
429 dom = None | |
430 metaUrl = self.getIndexMetaUrl(url) | |
39
1dd90aabd366
added retry when reading index meta from texter applet
casties
parents:
38
diff
changeset
|
431 |
174 | 432 logging.debug("(getDomFromIndexMeta): METAURL: %s"%metaUrl) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
433 txt=getHttpData(metaUrl) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
434 if txt is None: |
39
1dd90aabd366
added retry when reading index meta from texter applet
casties
parents:
38
diff
changeset
|
435 raise IOError("Unable to read index meta from %s"%(url)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
436 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
437 dom = Parse(txt) |
35 | 438 return dom |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
439 |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
440 def getPresentationInfoXML(self, url): |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
441 """returns dom of info.xml document at url""" |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
442 dom = None |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
443 metaUrl = None |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
444 if url.startswith("http://"): |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
445 # real URL |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
446 metaUrl = url |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
447 else: |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
448 # online path |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
449 server=self.digilibBaseUrl+"/servlet/Texter?fn=" |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
450 metaUrl=server+url.replace("/mpiwg/online","") |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
451 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
452 txt=getHttpData(metaUrl) |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
453 if txt is None: |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
454 raise IOError("Unable to read infoXMLfrom %s"%(url)) |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
455 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
456 dom = Parse(txt) |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
457 return dom |
35 | 458 |
459 | |
70 | 460 def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
35 | 461 """gets authorization info from the index.meta file at path or given by dom""" |
167 | 462 logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path)) |
32 | 463 |
464 access = None | |
465 | |
466 if docinfo is None: | |
467 docinfo = {} | |
468 | |
469 if dom is None: | |
78 | 470 for x in range(cut): |
70 | 471 path=getParentDir(path) |
174 | 472 dom = self.getDomFromIndexMeta(path) |
46 | 473 |
32 | 474 acctype = dom.xpath("//access-conditions/access/@type") |
475 if acctype and (len(acctype)>0): | |
476 access=acctype[0].value | |
35 | 477 if access in ['group', 'institution']: |
32 | 478 access = getTextFromNode(dom.xpath("//access-conditions/access/name")[0]).lower() |
479 | |
480 docinfo['accessType'] = access | |
481 return docinfo | |
29 | 482 |
32 | 483 |
70 | 484 def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): |
35 | 485 """gets bibliographical info from the index.meta file at path or given by dom""" |
167 | 486 logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) |
20 | 487 |
22 | 488 if docinfo is None: |
489 docinfo = {} | |
78 | 490 |
22 | 491 if dom is None: |
78 | 492 for x in range(cut): |
70 | 493 path=getParentDir(path) |
174 | 494 dom = self.getDomFromIndexMeta(path) |
495 | |
496 docinfo['indexMetaPath']=self.getIndexMetaPath(path); | |
79
df6952ac93e9
bug in getDocInforFromImagePath, relative lage der index.meta zu path war falsch.
dwinter
parents:
78
diff
changeset
|
497 |
167 | 498 logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) |
59 | 499 # put in all raw bib fields as dict "bib" |
500 bib = dom.xpath("//bib/*") | |
501 if bib and len(bib)>0: | |
502 bibinfo = {} | |
503 for e in bib: | |
504 bibinfo[e.localName] = getTextFromNode(e) | |
505 docinfo['bib'] = bibinfo | |
506 | |
507 # extract some fields (author, title, year) according to their mapping | |
25 | 508 metaData=self.metadata.main.meta.bib |
509 bibtype=dom.xpath("//bib/@type") | |
510 if bibtype and (len(bibtype)>0): | |
511 bibtype=bibtype[0].value | |
20 | 512 else: |
25 | 513 bibtype="generic" |
59 | 514 |
25 | 515 bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) |
59 | 516 docinfo['bib_type'] = bibtype |
25 | 517 bibmap=metaData.generateMappingForType(bibtype) |
174 | 518 logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap)) |
519 logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype)) | |
32 | 520 # if there is no mapping bibmap is empty (mapping sometimes has empty fields) |
31 | 521 if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: |
63 | 522 try: |
523 docinfo['author']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['author'][0])[0]) | |
524 except: pass | |
525 try: | |
526 docinfo['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0]) | |
527 except: pass | |
528 try: | |
529 docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) | |
530 except: pass | |
167 | 531 logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) |
52 | 532 try: |
533 docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) | |
534 except: | |
535 docinfo['lang']='' | |
227 | 536 |
22 | 537 return docinfo |
83 | 538 |
218 | 539 |
540 def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): | |
541 """gets name info from the index.meta file at path or given by dom""" | |
542 if docinfo is None: | |
543 docinfo = {} | |
544 | |
545 if dom is None: | |
546 for x in range(cut): | |
547 path=getParentDir(path) | |
548 dom = self.getDomFromIndexMeta(path) | |
549 | |
226 | 550 #docinfo['indexMetaPath']=self.getIndexMetaPath(path); |
218 | 551 |
219 | 552 #result= dom.xpath("//result/resultPage") |
553 #docinfo['numPages']=int(getTextFromNode(result[0])) | |
218 | 554 |
227 | 555 #result =dom.xpath("//name") |
229 | 556 docinfo['name']=getTextFromNode(dom.xpath("/resource/name")[0]) |
230 | 557 logging.debug("documentViewer docinfo[name] %s"%docinfo['name']) |
227 | 558 |
218 | 559 #logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) |
560 return docinfo | |
83 | 561 |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
562 def getDocinfoFromTextTool(self, url, dom=None, docinfo=None): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
563 """parse texttool tag in index meta""" |
167 | 564 logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url)) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
565 if docinfo is None: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
566 docinfo = {} |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
567 if docinfo.get('lang', None) is None: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
568 docinfo['lang'] = '' # default keine Sprache gesetzt |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
569 if dom is None: |
174 | 570 dom = self.getDomFromIndexMeta(url) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
571 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
572 archivePath = None |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
573 archiveName = None |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
574 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
575 archiveNames = dom.xpath("//resource/name") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
576 if archiveNames and (len(archiveNames) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
577 archiveName = getTextFromNode(archiveNames[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
578 else: |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
579 logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url)) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
580 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
581 archivePaths = dom.xpath("//resource/archive-path") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
582 if archivePaths and (len(archivePaths) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
583 archivePath = getTextFromNode(archivePaths[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
584 # clean up archive path |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
585 if archivePath[0] != '/': |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
586 archivePath = '/' + archivePath |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
587 if archiveName and (not archivePath.endswith(archiveName)): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
588 archivePath += "/" + archiveName |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
589 else: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
590 # try to get archive-path from url |
167 | 591 logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url)) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
592 if (not url.startswith('http')): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
593 archivePath = url.replace('index.meta', '') |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
594 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
595 if archivePath is None: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
596 # we balk without archive-path |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
597 raise IOError("Missing archive-path (for text-tool) in %s" % (url)) |
22 | 598 |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
599 imageDirs = dom.xpath("//texttool/image") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
600 if imageDirs and (len(imageDirs) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
601 imageDir = getTextFromNode(imageDirs[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
602 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
603 else: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
604 # we balk with no image tag / not necessary anymore because textmode is now standard |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
605 #raise IOError("No text-tool info in %s"%(url)) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
606 imageDir = "" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
607 #xquery="//pb" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
608 docinfo['imagePath'] = "" # keine Bilder |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
609 docinfo['imageURL'] = "" |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
610 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
611 if imageDir and archivePath: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
612 #print "image: ", imageDir, " archivepath: ", archivePath |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
613 imageDir = os.path.join(archivePath, imageDir) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
614 imageDir = imageDir.replace("/mpiwg/online", '') |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
615 docinfo = self.getDirinfoFromDigilib(imageDir, docinfo=docinfo) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
616 docinfo['imagePath'] = imageDir |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
617 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
618 docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + imageDir |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
619 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
620 viewerUrls = dom.xpath("//texttool/digiliburlprefix") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
621 if viewerUrls and (len(viewerUrls) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
622 viewerUrl = getTextFromNode(viewerUrls[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
623 docinfo['viewerURL'] = viewerUrl |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
624 |
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
625 # old style text URL |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
626 textUrls = dom.xpath("//texttool/text") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
627 if textUrls and (len(textUrls) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
628 textUrl = getTextFromNode(textUrls[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
629 if urlparse.urlparse(textUrl)[0] == "": #keine url |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
630 textUrl = os.path.join(archivePath, textUrl) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
631 # fix URLs starting with /mpiwg/online |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
632 if textUrl.startswith("/mpiwg/online"): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
633 textUrl = textUrl.replace("/mpiwg/online", '', 1) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
634 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
635 docinfo['textURL'] = textUrl |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
636 |
130
5c779d7b5f71
more modular version with separate object MpdlXmlTextServer
casties
parents:
128
diff
changeset
|
637 # new style text-url-path |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
638 textUrls = dom.xpath("//texttool/text-url-path") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
639 if textUrls and (len(textUrls) > 0): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
640 textUrl = getTextFromNode(textUrls[0]) |
102 | 641 docinfo['textURLPath'] = textUrl |
642 if not docinfo['imagePath']: | |
643 # text-only, no page images | |
205 | 644 docinfo = self.getNumTextPages(docinfo) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
645 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
646 presentationUrls = dom.xpath("//texttool/presentation") |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
647 docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag |
228 | 648 docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
649 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
650 if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
651 # presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
652 # durch den relativen Pfad auf die presentation infos |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
653 presentationPath = getTextFromNode(presentationUrls[0]) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
654 if url.endswith("index.meta"): |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
655 presentationUrl = url.replace('index.meta', presentationPath) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
656 else: |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
657 presentationUrl = url + "/" + presentationPath |
102 | 658 |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
659 docinfo = self.getBibinfoFromTextToolPresentation(presentationUrl, docinfo=docinfo, dom=dom) |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
660 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
661 docinfo = self.getAuthinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get access info |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
662 |
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
663 return docinfo |
22 | 664 |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
665 |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
666 def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None): |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
667 """gets the bibliographical information from the preseantion entry in texttools |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
668 """ |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
669 dom=self.getPresentationInfoXML(url) |
62 | 670 try: |
671 docinfo['author']=getTextFromNode(dom.xpath("//author")[0]) | |
672 except: | |
673 pass | |
674 try: | |
675 docinfo['title']=getTextFromNode(dom.xpath("//title")[0]) | |
676 except: | |
677 pass | |
678 try: | |
679 docinfo['year']=getTextFromNode(dom.xpath("//date")[0]) | |
680 except: | |
681 pass | |
50
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
682 return docinfo |
6c0f20cecc60
added evaluation of the presentation/info.xml in texttools
dwinter
parents:
49
diff
changeset
|
683 |
70 | 684 def getDocinfoFromImagePath(self,path,docinfo=None,cut=0): |
22 | 685 """path ist the path to the images it assumes that the index.meta file is one level higher.""" |
167 | 686 logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path)) |
22 | 687 if docinfo is None: |
688 docinfo = {} | |
29 | 689 path=path.replace("/mpiwg/online","") |
22 | 690 docinfo['imagePath'] = path |
73 | 691 docinfo=self.getDirinfoFromDigilib(path,docinfo=docinfo,cut=cut) |
78 | 692 |
79
df6952ac93e9
bug in getDocInforFromImagePath, relative lage der index.meta zu path war falsch.
dwinter
parents:
78
diff
changeset
|
693 pathorig=path |
78 | 694 for x in range(cut): |
695 path=getParentDir(path) | |
167 | 696 logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path) |
31 | 697 imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path |
22 | 698 docinfo['imageURL'] = imageUrl |
699 | |
79
df6952ac93e9
bug in getDocInforFromImagePath, relative lage der index.meta zu path war falsch.
dwinter
parents:
78
diff
changeset
|
700 #path ist the path to the images it assumes that the index.meta file is one level higher. |
df6952ac93e9
bug in getDocInforFromImagePath, relative lage der index.meta zu path war falsch.
dwinter
parents:
78
diff
changeset
|
701 docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
df6952ac93e9
bug in getDocInforFromImagePath, relative lage der index.meta zu path war falsch.
dwinter
parents:
78
diff
changeset
|
702 docinfo = self.getAuthinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1) |
22 | 703 return docinfo |
20 | 704 |
22 | 705 |
706 def getDocinfo(self, mode, url): | |
707 """returns docinfo depending on mode""" | |
167 | 708 logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url)) |
22 | 709 # look for cached docinfo in session |
51
c5d3aabbf61b
textviewer now integrated, new modus auto introduced as standard for viewing
dwinter
parents:
50
diff
changeset
|
710 if self.REQUEST.SESSION.has_key('docinfo'): |
22 | 711 docinfo = self.REQUEST.SESSION['docinfo'] |
712 # check if its still current | |
713 if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url: | |
167 | 714 logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo) |
22 | 715 return docinfo |
716 # new docinfo | |
717 docinfo = {'mode': mode, 'url': url} | |
718 if mode=="texttool": #index.meta with texttool information | |
719 docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) | |
720 elif mode=="imagepath": | |
721 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) | |
70 | 722 elif mode=="filepath": |
75
9673218e155b
minorCVS: ----------------------------------------------------------------------
dwinter
parents:
74
diff
changeset
|
723 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) |
22 | 724 else: |
167 | 725 logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode) |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
726 raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) |
37 | 727 |
167 | 728 logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo) |
22 | 729 self.REQUEST.SESSION['docinfo'] = docinfo |
730 return docinfo | |
128 | 731 |
170 | 732 def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None, viewMode=None, tocMode=None,characterNormalization=""): |
22 | 733 """returns pageinfo with the given parameters""" |
734 pageinfo = {} | |
25 | 735 current = getInt(current) |
736 pageinfo['current'] = current | |
737 rows = int(rows or self.thumbrows) | |
738 pageinfo['rows'] = rows | |
739 cols = int(cols or self.thumbcols) | |
740 pageinfo['cols'] = cols | |
741 grpsize = cols * rows | |
742 pageinfo['groupsize'] = grpsize | |
61 | 743 start = getInt(start, default=(math.ceil(float(current)/float(grpsize))*grpsize-(grpsize-1))) |
744 # int(current / grpsize) * grpsize +1)) | |
22 | 745 pageinfo['start'] = start |
25 | 746 pageinfo['end'] = start + grpsize |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
747 if (docinfo is not None) and ('numPages' in docinfo): |
25 | 748 np = int(docinfo['numPages']) |
749 pageinfo['end'] = min(pageinfo['end'], np) | |
750 pageinfo['numgroups'] = int(np / grpsize) | |
751 if np % grpsize > 0: | |
128 | 752 pageinfo['numgroups'] += 1 |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
753 pageinfo['viewMode'] = viewMode |
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
754 pageinfo['tocMode'] = tocMode |
173 | 755 #pageinfo['characterNormalization'] =characterNormalization |
756 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ') | |
95 | 757 pageinfo['query'] = self.REQUEST.get('query',' ') |
758 pageinfo['queryType'] = self.REQUEST.get('queryType',' ') | |
759 pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') | |
99 | 760 pageinfo['textPN'] = self.REQUEST.get('textPN','1') |
106 | 761 pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','') |
95 | 762 pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30') |
105 | 763 pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10') |
90
6a4a72033d58
new version with new full-text infrastructure and some more changed templates
casties
parents:
84
diff
changeset
|
764 pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1') |
99 | 765 toc = int (pageinfo['tocPN']) |
766 pageinfo['textPages'] =int (toc) | |
158 | 767 |
99 | 768 if 'tocSize_%s'%tocMode in docinfo: |
769 tocSize = int(docinfo['tocSize_%s'%tocMode]) | |
770 tocPageSize = int(pageinfo['tocPageSize']) | |
128 | 771 # cached toc |
99 | 772 if tocSize%tocPageSize>0: |
773 tocPages=tocSize/tocPageSize+1 | |
774 else: | |
775 tocPages=tocSize/tocPageSize | |
128 | 776 pageinfo['tocPN'] = min (tocPages,toc) |
95 | 777 pageinfo['searchPN'] =self.REQUEST.get('searchPN','1') |
112 | 778 pageinfo['sn'] =self.REQUEST.get('sn','') |
22 | 779 return pageinfo |
780 | |
128 | 781 def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None): |
22 | 782 """init document viewer""" |
783 self.title=title | |
784 self.digilibBaseUrl = digilibBaseUrl | |
25 | 785 self.thumbrows = thumbrows |
786 self.thumbcols = thumbcols | |
32 | 787 self.authgroups = [s.strip().lower() for s in authgroups.split(',')] |
22 | 788 if RESPONSE is not None: |
789 RESPONSE.redirect('manage_main') | |
0 | 790 |
791 def manage_AddDocumentViewerForm(self): | |
792 """add the viewer form""" | |
22 | 793 pt=PageTemplateFile('zpt/addDocumentViewer', globals()).__of__(self) |
0 | 794 return pt() |
795 | |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
796 def manage_AddDocumentViewer(self,id,imageScalerUrl="",textServerName="",title="",RESPONSE=None): |
0 | 797 """add the viewer""" |
84
a6e4f9b6729a
first version with new full-text infrastructure and slightly changed templates
casties
parents:
83
diff
changeset
|
798 newObj=documentViewer(id,imageScalerUrl=imageScalerUrl,title=title,textServerName=textServerName) |
0 | 799 self._setObject(id,newObj) |
800 | |
801 if RESPONSE is not None: | |
802 RESPONSE.redirect('manage_main') | |
22 | 803 |
804 ## DocumentViewerTemplate class | |
805 class DocumentViewerTemplate(ZopePageTemplate): | |
806 """Template for document viewer""" | |
807 meta_type="DocumentViewer Template" | |
808 | |
809 | |
810 def manage_addDocumentViewerTemplateForm(self): | |
811 """Form for adding""" | |
812 pt=PageTemplateFile('zpt/addDocumentViewerTemplate', globals()).__of__(self) | |
813 return pt() | |
814 | |
815 def manage_addDocumentViewerTemplate(self, id='viewer_main', title=None, text=None, | |
816 REQUEST=None, submit=None): | |
817 "Add a Page Template with optional file content." | |
818 | |
819 self._setObject(id, DocumentViewerTemplate(id)) | |
820 ob = getattr(self, id) | |
53
f4e0af8c281d
NEW - # 44: ECHO - vollst?ndige bibliographische Angabe
dwinter
parents:
52
diff
changeset
|
821 txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read() |
167 | 822 logging.info("txt %s:"%txt) |
53
f4e0af8c281d
NEW - # 44: ECHO - vollst?ndige bibliographische Angabe
dwinter
parents:
52
diff
changeset
|
823 ob.pt_edit(txt,"text/html") |
22 | 824 if title: |
825 ob.pt_setTitle(title) | |
826 try: | |
827 u = self.DestinationURL() | |
828 except AttributeError: | |
829 u = REQUEST['URL1'] | |
830 | |
831 u = "%s/%s" % (u, urllib.quote(id)) | |
832 REQUEST.RESPONSE.redirect(u+'/manage_main') | |
833 return '' | |
834 | |
835 | |
41 | 836 |