Diff for /cdli/cdli_files.py between versions 1.78 and 1.80

version 1.78, 2007/04/27 14:42:28 version 1.80, 2007/09/03 11:10:04
Line 28  import copy Line 28  import copy
 import codecs  import codecs
 import sys  import sys
   
   def unicodify(s):
       """decode str (utf-8 or latin-1 representation) into unicode object"""
       if not s:
           return u""
       if isinstance(s, str):
           try:
               return s.decode('utf-8')
           except:
               return s.decode('latin-1')
       else:
           return s
   
   def utf8ify(s):
       """encode unicode object or string into byte string in utf-8 representation.
          assumes string objects to be utf-8"""
       if not s:
           return ""
       if isinstance(s, str):
           return s
       else:
           return s.encode('utf-8')
   
   
 def generateXMLReturn(hash):  def generateXMLReturn(hash):
     """erzeugt das xml file als returnwert fuer uploadATFRPC"""      """erzeugt das xml file als returnwert fuer uploadATFRPC"""
   
Line 1514  def manage_addCDLIFileObject(self,id,vC= Line 1537  def manage_addCDLIFileObject(self,id,vC=
   
     # First, we create the file without data:      # First, we create the file without data:
     self._setObject(id, CDLIFileObject(id,title,'',content_type, precondition))      self._setObject(id, CDLIFileObject(id,title,'',content_type, precondition))
     self._getOb(id).versionComment=str(vC)      fob = self._getOb(id)
     self._getOb(id).time=time.localtime()      fob.versionComment=str(vC)
           fob.time=time.localtime()
     setattr(self._getOb(id),'author',author)      setattr(fob,'author',author)
       
           
     # Now we "upload" the data.  By doing this in two steps, we      # Now we "upload" the data.  By doing this in two steps, we
     # can use a database trick to make the upload more efficient.      # can use a database trick to make the upload more efficient.
   
     if file and not from_tmp:      if file and not from_tmp:
         self._getOb(id).manage_upload(file)          fob.manage_upload(file)
     elif file and from_tmp:      elif file and from_tmp:
         self._getOb(id).manage_upload_from_tmp(file)          fob.manage_upload_from_tmp(file)
     if content_type:      if content_type:
         self._getOb(id).content_type=content_type          fob.content_type=content_type
   
       logging.debug("reindex1: %s"%repr(self))
     self.reindex_object()      self.reindex_object()
     self._getOb(id).reindex_object()      logging.debug("reindex2: %s in %s"%(repr(fob), repr(fob.default_catalog)))
       fob.reindex_object()
   
     if REQUEST is not None:      if REQUEST is not None:
         REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')          REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
           
   
 class CDLIFile(extVersionedFile,CatalogAware):  class CDLIFile(extVersionedFile,CatalogAware):
     """CDLI file"""      """CDLI file"""
           
Line 2249  class CDLIRoot(Folder): Line 2274  class CDLIRoot(Folder):
         """get lines with word  fromFileId"""          """get lines with word  fromFileId"""
                   
         file=self.showFile(fileId)          file=self.showFile(fileId)
         tagStr="""<span class="found">%s</span>"""          tagStr=u'<span class="found">%s</span>'
         ret=[]          ret=[]
                   
         if regExp: # wenn regexp dann generiere alle worte aus der list die der regexp entsprechen          if regExp: # wenn regexp dann generiere alle worte aus der list die der regexp entsprechen
Line 2258  class CDLIRoot(Folder): Line 2283  class CDLIRoot(Folder):
             wordlist=[word]              wordlist=[word]
                           
         for line in file.split("\n"):          for line in file.split("\n"):
               line = unicodify(line)
             found=False              found=False
             for word in wordlist:              for word in wordlist:
                 if line.find(word)>-1: #word ist gefunden dann makiere und breche die Schleife ab                  if line.find(word)>-1: #word ist gefunden dann makiere und breche die Schleife ab
Line 2275  class CDLIRoot(Folder): Line 2301  class CDLIRoot(Folder):
             if not found: #word wurde nicht gefunden keine makierung              if not found: #word wurde nicht gefunden keine makierung
                         ret.append(line)                          ret.append(line)
                                                   
         return "<br>\n".join(ret)          return u'<br>\n'.join(ret)
   
     def URLquote(self,str):      def URLquote(self,str):
         """quote url"""          """quote url"""

Removed from v.1.78  
changed lines
  Added in v.1.80


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>