Mercurial > hg > documentViewer
comparison documentViewer.py @ 514:c55e376be01b
search works even with unicode...
| author | casties |
|---|---|
| date | Tue, 28 Feb 2012 19:46:37 +0100 |
| parents | 67095296c95a |
| children | 7d7b639d7be7 |
comparison
equal
deleted
inserted
replaced
| 513:67095296c95a | 514:c55e376be01b |
|---|---|
| 15 import math | 15 import math |
| 16 import urlparse | 16 import urlparse |
| 17 import re | 17 import re |
| 18 import string | 18 import string |
| 19 | 19 |
| 20 from SrvTxtUtils import getInt, getText, getHttpData, refreshingImageFileIndexHtml | 20 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml |
| 21 | 21 |
| 22 def serializeNode(node, encoding="utf-8"): | 22 def serializeNode(node, encoding="utf-8"): |
| 23 """returns a string containing node as XML""" | 23 """returns a string containing node as XML""" |
| 24 s = ET.tostring(node) | 24 s = ET.tostring(node) |
| 25 | 25 |
| 379 | 379 |
| 380 def getLink(self, param=None, val=None, params=None, baseUrl=None, paramSep='&', duplicates='comma'): | 380 def getLink(self, param=None, val=None, params=None, baseUrl=None, paramSep='&', duplicates='comma'): |
| 381 """returns URL to documentviewer with parameter param set to val or from dict params""" | 381 """returns URL to documentviewer with parameter param set to val or from dict params""" |
| 382 urlParams = self.getParams(param=param, val=val, params=params, duplicates=duplicates) | 382 urlParams = self.getParams(param=param, val=val, params=params, duplicates=duplicates) |
| 383 # quote values and assemble into query string (not escaping '/') | 383 # quote values and assemble into query string (not escaping '/') |
| 384 ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(unicode(v),'/')) for (k, v) in urlParams.items()]) | 384 ps = paramSep.join(["%s=%s"%(k, urllib.quote_plus(utf8ify(v), '/')) for (k, v) in urlParams.items()]) |
| 385 if baseUrl is None: | 385 if baseUrl is None: |
| 386 baseUrl = self.getDocumentViewerURL() | 386 baseUrl = self.getDocumentViewerURL() |
| 387 | 387 |
| 388 url = "%s?%s"%(baseUrl, ps) | 388 url = "%s?%s"%(baseUrl, ps) |
| 389 return url | 389 return url |
| 394 | 394 |
| 395 | 395 |
| 396 def getInfo_xml(self,url,mode): | 396 def getInfo_xml(self,url,mode): |
| 397 """returns info about the document as XML""" | 397 """returns info about the document as XML""" |
| 398 if not self.digilibBaseUrl: | 398 if not self.digilibBaseUrl: |
| 399 self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" | 399 self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" |
| 400 | 400 |
| 401 docinfo = self.getDocinfo(mode=mode,url=url) | 401 docinfo = self.getDocinfo(mode=mode,url=url) |
| 402 pt = getattr(self.template, 'info_xml') | 402 pt = getattr(self.template, 'info_xml') |
| 403 return pt(docinfo=docinfo) | 403 return pt(docinfo=docinfo) |
| 404 | 404 |
