Back to index

plone3  3.1.7
faux_objects.py
Go to the documentation of this file.
00001 """ Simple, importable content classes.
00002 
00003 $Id: faux_objects.py 71199 2006-11-20 11:03:29Z yuppie $
00004 """
00005 
00006 from OFS.PropertyManager import PropertyManager
00007 from OFS.SimpleItem import SimpleItem
00008 from zope.interface import implements
00009 
00010 
00011 class TestSimpleItem(SimpleItem):
00012     pass
00013 
00014 class TestSimpleItemWithProperties(SimpleItem, PropertyManager):
00015     pass
00016 
00017 KNOWN_CSV = """\
00018 one,two,three
00019 four,five,six
00020 """
00021 
00022 from Products.GenericSetup.interfaces import ICSVAware
00023 class TestCSVAware(SimpleItem):
00024     implements(ICSVAware)
00025     _was_put = None
00026     _csv = KNOWN_CSV
00027 
00028     def as_csv(self):
00029         return self._csv
00030 
00031     def put_csv(self, text):
00032         self._was_put = text
00033 
00034 KNOWN_INI = """\
00035 [DEFAULT]
00036 title = %s
00037 description = %s
00038 """
00039 
00040 from Products.GenericSetup.interfaces import IINIAware
00041 class TestINIAware(SimpleItem):
00042     implements(IINIAware)
00043     _was_put = None
00044     title = 'INI title'
00045     description = 'INI description'
00046 
00047     def as_ini(self):
00048         return KNOWN_INI % (self.title, self.description)
00049 
00050     def put_ini(self, text):
00051         self._was_put = text
00052 
00053 KNOWN_DAV = """\
00054 Title: %s
00055 Description: %s
00056 
00057 %s
00058 """
00059 
00060 from Products.GenericSetup.interfaces import IDAVAware
00061 class TestDAVAware(SimpleItem):
00062     implements(IDAVAware)
00063     _was_put = None
00064     title = 'DAV title'
00065     description = 'DAV description'
00066     body = 'DAV body'
00067 
00068     def manage_FTPget(self):
00069         return KNOWN_DAV % (self.title, self.description, self.body)
00070 
00071     def PUT(self, REQUEST, RESPONSE):
00072         self._was_put = REQUEST.get('BODY', '')
00073         stream = REQUEST.get('BODYFILE', None)
00074         self._was_put_as_read = stream.read()