From 2df68b5be789a7268666882f0f8f7caa193f27cc Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Tue, 3 Oct 2006 13:07:47 +0000 Subject: [PATCH] Added formal representation of data and mime types so that synchronisation can be supported. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10513 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/File.py | 1 + product/ERP5/PropertySheet/Data.py | 46 +++++++++++++++++++++++++ product/ERP5OOo/Document/OOoDocument.py | 14 +++++--- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 product/ERP5/PropertySheet/Data.py diff --git a/product/ERP5/Document/File.py b/product/ERP5/Document/File.py index 05bfe50a82..96f286d215 100644 --- a/product/ERP5/Document/File.py +++ b/product/ERP5/Document/File.py @@ -66,6 +66,7 @@ class File(XMLObject, CMFFile): property_sheets = ( PropertySheet.Base , PropertySheet.CategoryCore , PropertySheet.DublinCore + , PropertySheet.Data ) # Declarative interfaces diff --git a/product/ERP5/PropertySheet/Data.py b/product/ERP5/PropertySheet/Data.py new file mode 100644 index 0000000000..b296f27f4c --- /dev/null +++ b/product/ERP5/PropertySheet/Data.py @@ -0,0 +1,46 @@ +############################################################################## +# +# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. +# Jean-Paul Smets <jp@nexedi.com> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# 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. +# +############################################################################## + +class Data: + """ + This property sheet defines the way to store data (file, images, etc.) + in the form of an object of any type + """ + + _properties = ( + { 'id' : 'data', + 'description' : 'An object (string, stream, etc.) which contains raw data', + 'type' : 'object', + 'default' : '', + 'mode' : 'w' }, + { 'id' : 'content_type', + 'description' : 'A string which represents the mime type of the data', + 'type' : 'string', + 'default' : 'application/unknown', + 'mode' : 'w' }, + ) diff --git a/product/ERP5OOo/Document/OOoDocument.py b/product/ERP5OOo/Document/OOoDocument.py index b026363f59..7bf1be6802 100644 --- a/product/ERP5OOo/Document/OOoDocument.py +++ b/product/ERP5OOo/Document/OOoDocument.py @@ -100,6 +100,7 @@ class OOoDocument(DMSFile, CachingMixin): property_sheets = ( PropertySheet.Base , PropertySheet.CategoryCore , PropertySheet.DublinCore + , PropertySheet.Data , PropertySheet.Version , PropertySheet.Reference , PropertySheet.Document @@ -111,9 +112,12 @@ class OOoDocument(DMSFile, CachingMixin): rx_strip=re.compile('<[^>]*?>',re.DOTALL|re.MULTILINE) rx_compr=re.compile('\s+') - searchable_attrs=DMSFile.searchable_attrs+('text_content',) + searchable_attrs=DMSFile.searchable_attrs+('text_content',) # XXX - good idea - should'n this be made more general ? - def _getServerCoordinates(self): + def _getServerCoordinates(self): # XXX - Naming - should be _getServerCoordinate or _getServerCoordinateList + # the reason why plural is not so good is because one never + # knows is plural returns a count (ie. the server has 3 coordinates) + # or if plural returns a list """ Returns OOo conversion server data from preferences @@ -275,7 +279,8 @@ class OOoDocument(DMSFile, CachingMixin): #self.setReference(meta.get('reference','')) #security.declareProtected(Permissions.View,'getOOfile') - def getOOfile(self): + def getOOfile(self): # We must be consistent - OOoDocument and OOoFile is OK + # XXX OODocument and OOFile is OK """ Return the converted OOo document. @@ -287,7 +292,8 @@ class OOoDocument(DMSFile, CachingMixin): return data security.declareProtected(Permissions.View,'hasOOfile') - def hasOOfile(self): + def hasOOfile(self): # We must be consistent - OOoDocument and OOoFile is OK + # XXX OODocument and OOFile is OK """ Checks whether we have an OOo converted file """ -- 2.30.9