|
Indexation Word sous Windows: msg#00325web.zope.cps.general.french
Bonjour, Après des jours de "prise de tête", j'abandonne ! J'appelle à l'aide ! Quand j'insère un document Word dans CPS, l'insertion dure très... très... très longtemps : le lecteur de disquette du serveur est sollicité 4 ou 5 fois ????? Puis finalement, l'insertion se termine (sur un serveur lent genre PIII-800, cela se termine par un time-out) ! J'ai ré-installé CPS 3.3.4-2 sur trois machine différentes (toutes fraichement installées) et le même problème se produit systématiquement (bien sur, les extensions pour python win32 sont aussi installées). J'ai désactivé le lecteur de disquette dans le bios en croyant que ça résoudrait ces problèmes de lenteur : QUE NENNI ! Les insertions se passent bien pour les fichiers XLS et PPT car les transforms sont basés sur des binaires externes qui font bien leur bouleau a priori. Par contre, pour Word, on utilise le script Office_com qui permet de "scripter" Word pour qu'il fasse un enregistrement au format HTML du fichier DOC inséré. Le problème doit bien se situer dans ces scripts mais je ne connais pas Python et je ne comprend que l'idée générale du script. Alors là, je ne sais plus quoi faire ! Help please ! Le script Word_to_html.py que j'utilise est le suivant : from Products.PortalTransforms.interfaces import itransform EXTRACT_BODY = 1 EXTRACT_STYLE = 0 FIX_IMAGES = 1 IMAGE_PREFIX = "img_" import os if os.name == 'posix': try: import PyUNO from office_uno import document except: from office_wvware import document else: from office_com import document from os.path import basename class word_to_html: __implements__ = itransform __name__ = 'word_to_html' inputs = ('application/msword',) output = 'text/html' def name(self): return self.__name__ def convert(self, data, cache, **kwargs): orig_file = basename((kwargs.get('filename') or 'unknown.doc')) doc = document(orig_file, data) doc.convert() html = doc.html() path, images = doc.subObjects(doc.tmpdir) objects = {} if images: doc.fixImages(path, images, objects) doc.cleanDir(doc.tmpdir) cache.setData(html) cache.setSubObjects(objects) return cache def register(): return word_to_html() Le script Office_com.py que j'utilise est le suivant : import win32api import pythoncom from win32com.client import constants, Dispatch from Products.PortalTransforms.libtransforms.commandtransform \ import commandtransform from Products.PortalTransforms.libtransforms.utils import bodyfinder, scrubHTML class document(commandtransform): def __init__(self, name, data): """Initialization: create tmp work directory and copy the document into a file""" commandtransform.__init__(self, name) name = self.name() if not name.endswith('.doc'): name += ".doc" self.tmpdir, self.fullname = self.initialize_tmpdir(data, filename=name) def convert(self): pythoncom.CoInitialize() try: word = Dispatch("Word.Application") word.Visible = 0 doc = word.Documents.Open(self.fullname) #Let's set up some html saving options for this document word.ActiveDocument.WebOptions.RelyOnCSS = 1 word.ActiveDocument.WebOptions.OptimizeForBrowser = 1 word.ActiveDocument.WebOptions.BrowserLevel = 0 word.ActiveDocument.WebOptions.OrganizeInFolder = 0 word.ActiveDocument.WebOptions.UseLongFileNames = 1 word.ActiveDocument.WebOptions.RelyOnVML = 0 word.ActiveDocument.WebOptions.AllowPNG = 1 #And then save the document into HTML doc.SaveAs(FileName="%s.htm" % (self.fullname), FileFormat=8) #TODO -- Extract Metadata (author, title, keywords) so we #can populate the dublin core #Converter will need to be extended to return a dict of #possible MD fields doc.Close() word.Quit() finally: win32api.Sleep(1000) #Waiting for Word to close pythoncom.CoUninitialize() def html(self): htmlfile = open(self.fullname + '.htm', 'r') html = htmlfile.read() htmlfile.close() html = scrubHTML(html) body = bodyfinder(html) return body ## This function has to be done. It's more difficult to delete the temp ## directory under Windows, because there is sometimes a directory in it. ## def cleanDir(self, tmpdir): _______________________________________________ cps-users-fr Adresse de la liste : cps-users-fr-FQDHc1wsLCVb90+sfpvX0g@xxxxxxxxxxxxxxxx Gestion de l'abonnement : <http://lists.nuxeo.com/mailman/listinfo/cps-users-fr> |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: WorkFlow: 00325, Anahide Tchertchian |
|---|---|
| Next by Date: | Re: Re: CPS-users-fr] Re: fsrecover.py pour packer le data.fs: 00325, misstie LB |
| Previous by Thread: | CPS-users-fr] Re: fsrecover.py pour packer le data.fsi: 00325, LAROSE |
| Next by Thread: | RE : RE : RE : Ne pas afficher un champ d'un Schema (suite): 00325, Piton Marco |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |