PDFDocument/0040755000000000000000000000000007472030336011674 5ustar rootrootPDFDocument/CVS/0040755000000000000000000000000007471035542012332 5ustar rootrootPDFDocument/CVS/Root0100644000000000000000000000001207471035542013166 0ustar rootroot/home/cvs PDFDocument/CVS/Repository0100644000000000000000000000001507471035542014425 0ustar rootrootHTMLDocument PDFDocument/CVS/Entries0100644000000000000000000000067407471035542013672 0ustar rootroot/IHTMLDocument.py/1.2/Fri Aug 17 16:41:38 2001// /LICENSE.txt/1.1.1.1/Tue May 8 14:09:12 2001// /__init__.py/1.2/Tue Jul 31 11:39:26 2001// /parser.py/1.1.1.1/Tue May 8 14:09:09 2001// /refresh.txt/1.1.1.1/Tue May 8 14:09:09 2001// D/dtml//// D/tests//// D/www//// /Makefile/1.4/Thu Aug 23 09:38:28 2001// /README.txt/1.3/Thu Aug 23 09:39:32 2001// /version.txt/1.3/Thu Aug 23 09:39:38 2001// /HTMLDocument.py/1.7/Thu Aug 23 10:11:02 2001// PDFDocument/www/0040755000000000000000000000000007471035542012523 5ustar rootrootPDFDocument/www/CVS/0040755000000000000000000000000007471035542013156 5ustar rootrootPDFDocument/www/CVS/Root0100644000000000000000000000001207471035542014012 0ustar rootroot/home/cvs PDFDocument/www/CVS/Repository0100644000000000000000000000002107471035542015246 0ustar rootrootHTMLDocument/www PDFDocument/www/CVS/Entries0100644000000000000000000000005707471035542014511 0ustar rootroot/icon.gif/1.1.1.1/Tue May 8 14:09:12 2001// D PDFDocument/www/icon.gif0100644000000000000000000000017507471035542014142 0ustar rootrootGIF89aÂPPP€€ÀÀÀÿÿÿ€€€€€€!ù,BxÜ®ðB+™!J[çf G( …Üà+!T3õƵl p™çN@ }´]oóSâ’•ãÆ]\Øì ’êz;PDFDocument/PDFDocument.pyc0100644000000000000000000002272407472025061014524 0ustar rootroot*ë *è /dev/nulls%s.txti(sselfspdf_srcsdatastempfilesmktempstmpdirsossmkdirsopensidsfdswritesclosescmdssystemsremove(sselfscmdsdatasfd((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pys_parses "  csd²³x@tid|iƒd³r#}´tid|i|fƒqWµtid|iƒdS(Ns%sis%s/%s(sosslistdirsselfstmpdirsfnsremovesrmdir(sselfsfn((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pys__del__²s !()s__doc__s meta_typesiconspdf_srcsbodysraw_textstextesNones index_htmlsPropertyManagersmanage_optionss Cacheables HistoricalsClassSecurityInfossecuritys _metadatastitlesauthors publisherssources descriptionskeywordsssummarys _propertiess__ac_permissions__s__init__s updateStatesHTMLFilesglobalssmanage_editFormsmanages manage_mains manage_edits manage_uploadsPUTs manage_FTPgets document_srcs__call__sPrincipiaSearchSources_parses__del__(((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pys PDFDocuments2     H !!E-      s dtml/addFormsKindskindcs€½¾| o t|dƒoW¿|i}Á|tti|dƒÃti|dƒÄti|dƒƒd}nÅ|SdS(Nsfilenames/s\s:i(sidshasattrsfilesfilenamesmaxsstringsrfind(sidsfilesfilename((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pyscookId½s  !scsÇÈÊt|ƒ}Ët||ƒ}Ìt|ƒtdƒj oÍ|iƒ}nÏtd|d|d|ƒ}Ð|i ||ƒ}Ñ|t j oxÒyÒ|i ƒ}WnÓÓ|d}nXÔ|djoÔd|t|ƒf}nÕ|ii|dƒnÖdSd S( s3Add a PDFDocument object with the contents of file.ssidstitlesfilesURL1s Add and Edit s%s/%ss /manage_mainN(sstrsidscookIdsfilestypesreads PDFDocumentstitlesobsselfs _setObjectsREQUESTsNonesDestinationURLsussubmitsquotesRESPONSEsredirect(sselfsidstitlesfilesREQUESTssubmitsusob((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pysaddPDFDocumentÇs ()s__doc__s __version__sOFS.SimpleItems SimpleItemsItem_w__name__sOFS.PropertyManagersPropertyManagers OFS.Caches Cacheables OFS.Historys Historicals"Products.ZCatalog.CatalogAwarenesss CatalogAwares AcquisitionsDateTime.DateTimesDateTimes AccessControlsClassSecurityInfosgetSecurityManagersGlobalssHTMLsHTMLFilesDTMLFiles MessageDialogsInitializeClasssurllibsquotesresstrings tracebacks IPDFDocumentsosstempfilescgisImplicits PDFDocumentsglobalssaddPDFDocumentFormscookIdsNonesaddPDFDocument(soss __version__sPropertyManagers IPDFDocumentscookIdsHTMLsres tracebacks PDFDocumentsHTMLFilestempfilesgetSecurityManagers Acquisitions MessageDialogsDTMLFiles Historicals CatalogAwares SimpleItemsDateTimesInitializeClasssaddPDFDocumentsClassSecurityInfosquotesstringsItem_w__name__s CacheablesaddPDFDocumentFormscgi((sJ/home/Zope-2.4.4-linux2-x86/lib/python/Products/PDFDocument/PDFDocument.pys?s(  (.›  PDFDocument/dtml/0040755000000000000000000000000007471051733012637 5ustar rootrootPDFDocument/dtml/CVS/0040755000000000000000000000000007471035542013272 5ustar rootrootPDFDocument/dtml/CVS/Root0100644000000000000000000000001207471035542014126 0ustar rootroot/home/cvs PDFDocument/dtml/CVS/Repository0100644000000000000000000000002207471035542015363 0ustar rootrootHTMLDocument/dtml PDFDocument/dtml/CVS/Entries0100644000000000000000000000030707471035542014623 0ustar rootroot/addForm.dtml/1.1.1.1/Tue May 8 14:09:13 2001// /editForm.dtml/1.1.1.1/Tue May 8 14:09:13 2001// /tidy.dtml/1.1.1.1/Tue May 8 14:09:13 2001// /uploadForm.dtml/1.1.1.1/Tue May 8 14:09:13 2001// D PDFDocument/dtml/addForm.dtml0100644000000000000000000000176107471035542015077 0ustar rootroot
Id
File
PDFDocument/dtml/uploadForm.dtml0100644000000000000000000000151007471035542015623 0ustar rootroot Upload <dtml-var title_or_id>

Upload

Id
Title

PDFDocument/dtml/editForm.dtml0100644000000000000000000000375607471051400015271 0ustar rootroot

You may edit the source for this document using the form below. You may also upload the source for this document from a local file. Click the browse button to select a local file to upload.

Title
  
File  
PDFDocument/__init__.pyc0100644000000000000000000000332207471051411014141 0ustar rootroot*ë IRä Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. PDFDocument/__init__.py0100644000000000000000000000165007472030303013776 0ustar rootroot# import PDFDocument from ZClasses import createZClassForBase createZClassForBase(PDFDocument.PDFDocument, globals(), 'ZPDFDocument', 'PDF Document') def initialize(context): "Initialize the PDFDocument product" context.registerClass( PDFDocument.PDFDocument, permission='Add PDFDocuments', constructors=( PDFDocument.addPDFDocumentForm, PDFDocument.addPDFDocument, ), icon="www/icon.gif" ) def PUT_factory( self, name, typ, body ): from OFS.Image import Image, File from OFS.DTMLDocument import DTMLDocument if typ == 'application/pdf': ob = PDFDocument.PDFDocument('', __name__=name) elif typ in ('text/xml', 'text/plain'): ob = DTMLDocument('', __name__=name) elif typ[:6] == 'image/': ob = Image(name, '', body, content_type=typ) else: ob = File(name, '', body, content_type=typ) return ob import webdav.NullResource webdav.NullResource.NullResource._default_PUT_factory = PUT_factory PDFDocument/PDFDocument.py0100644000000000000000000001407007472030336014355 0ustar rootroot# """PDFDocuments """ __version__='$Revision: 1.7 $'[11:-2] from OFS.SimpleItem import SimpleItem, Item_w__name__ from OFS.PropertyManager import PropertyManager from OFS.Cache import Cacheable from OFS.History import Historical from Products.ZCatalog.CatalogAwareness import CatalogAware import Acquisition from DateTime.DateTime import DateTime from AccessControl import ClassSecurityInfo, getSecurityManager from Globals import HTML, HTMLFile, DTMLFile, MessageDialog, InitializeClass from urllib import quote import re, string, traceback from IPDFDocument import IPDFDocument import os, tempfile, cgi class PDFDocument(CatalogAware, SimpleItem, Acquisition.Implicit, PropertyManager, Historical, Cacheable, Item_w__name__): """PDF Documents""" meta_type = 'PDFDocument' icon = 'p_/dtmldoc' pdf_src = body = raw_text = '' texte = '' index_html = None # Prevent accidental acquisition (XXX ???) manage_options = ( ( {'label':'Edit', 'action':'manage_main'}, {'label':'View', 'action':''}, ) + PropertyManager.manage_options + Cacheable.manage_options + Historical.manage_options ) security = ClassSecurityInfo() _metadata = ['title', 'author', 'publisher', 'source', 'publication_date', 'description', 'keywords', 'summary'] title = author = publisher = source = description = keywords = summary = '' _properties = ( {'id':'title', 'type': 'string', 'mode': 'w'}, {'id':'source', 'type': 'string', 'mode': 'w'}, ) __ac_permissions__=( ('Change PDF Documents', ('manage_editForm', 'manage', 'manage_main', 'manage_edit', 'manage_upload', 'PUT', 'manage_historyCopy', 'manage_beforeHistoryCopy', 'manage_afterHistoryCopy', ) ), ) # # Constructor # def __init__(self, id='', title='', file='', __name__=''): if __name__ and not id: self._setId(__name__) else: self._setId(id) self.pdf_src = file self.title = id[:-4] # self._parse() def updateState(self): self._parse() self.ZCacheable_invalidate() self.reindex_object() manage_editForm = HTMLFile('dtml/editForm', globals()) manage = manage_main = manage_editForm def manage_edit(self, data, title='', SUBMIT='Change', dtpref_cols='50', dtpref_rows='20', REQUEST=None): """ Replaces a Documents contents with Data. """ if title: self.title = title if type(data) is not type(''): data = data.read() self.pdf_src = data self.updateState() if REQUEST: message="Content changed." return self.manage_main(self,REQUEST,manage_tabs_message=message) def manage_upload(self, file='', REQUEST=None): """Replace the contents of the document with the text in file.""" if type(file) is not type(''): file=file.read() self.pdf_src = file self.updateState() if REQUEST: message="Content uploaded." return self.manage_main(self,REQUEST,manage_tabs_message=message) def PUT(self, REQUEST, RESPONSE): "Handle HTTP/FTP PUT requests." self.dav__init(REQUEST, RESPONSE) self.pdf_src = REQUEST.get('BODY', '') self.updateState() RESPONSE.setStatus(204) return RESPONSE def manage_FTPget(self): "Get PDF source for FTP download" return self.pdf_src def document_src(self, REQUEST=None, RESPONSE=None): """Return unprocessed document source.""" if RESPONSE is not None: RESPONSE.setHeader('Content-Type', 'application/pdf') return self.pdf_src def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): "View document" if RESPONSE is not None: RESPONSE.setHeader('Content-Type', 'application/pdf') return self.pdf_src def PrincipiaSearchSource(self): # print self._parse() return open("%s/%s.txt" % (self.tmpdir, self.id[:-4])).read() def _parse(self): data = self.pdf_src self.tmpdir = tempfile.mktemp() os.mkdir('%s' % self.tmpdir) fd = open("%s/%s" % (self.tmpdir, self.id), "w") fd.write(data) fd.close() print self.id cmd = "cd '%s' && pdftotext '%s' 2> /dev/null" \ % (self.tmpdir, self.id) os.system(cmd) print cmd print "%s.txt" % (self.id[:-4]) os.remove("%s/%s" % (self.tmpdir,self.id)) # self.texte = open("%s/%s.txt" % (self.tmpdir, self.id[:-4])).read() # return self.texte def __del__(self): for fn in os.listdir("%s" % self.tmpdir): os.remove("%s/%s" % (self.tmpdir, fn)) os.rmdir("%s" % self.tmpdir) InitializeClass(PDFDocument) addPDFDocumentForm = HTMLFile('dtml/addForm', globals(), Kind='PDFDocument', kind='PDFDocument') def cookId(id, file): if not id and hasattr(file, 'filename'): filename = file.filename #title = title or filename id = filename[max( string.rfind(filename, '/'), string.rfind(filename, '\\'), string.rfind(filename, ':'),)+1:] return id def addPDFDocument(self, id, title='', file='', REQUEST=None, submit=None): """Add a PDFDocument object with the contents of file.""" id = str(id) id = cookId(id, file) if type(file) is not type(''): file = file.read() ob = PDFDocument(id=id, title=title, file=file) id = self._setObject(id, ob) if REQUEST is not None: try: u = self.DestinationURL() except: u = REQUEST['URL1'] if submit == " Add and Edit ": u = "%s/%s" % (u, quote(id)) REQUEST.RESPONSE.redirect(u + '/manage_main') return '' # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # vim:et:ts=2:ai PDFDocument/IPDFDocument.pyc0100644000000000000000000000120107471037520014622 0ustar rootroot*ë "?ä