Back to index

plone3  3.1.7
base.py
Go to the documentation of this file.
00001 from Acquisition import Explicit
00002 
00003 from Products.ZCTextIndex.ParseTree import ParseError
00004 
00005 
00006 class DummyContext(Explicit):
00007 
00008     def __init__(self):
00009         self.context = None
00010 
00011 
00012 class DummyTool(Explicit):
00013 
00014     def __init__(self, name):
00015         self.name = name
00016 
00017 
00018 class DummyType(object):
00019 
00020     def __init__(self, title):
00021         self.title = title
00022 
00023     def Title(self):
00024         return self.title
00025 
00026 
00027 class DummyTypeTool(dict):
00028 
00029     def __init__(self):
00030         self['Document'] = DummyType('Page')
00031         self['Event'] = DummyType('Event')
00032 
00033     def listContentTypes(self):
00034         return self.keys()
00035 
00036 
00037 class Response(dict):
00038 
00039     def getHeader(self, value):
00040         return 'header %s' % value
00041 
00042 
00043 class Request(dict):
00044 
00045     debug = False
00046     response = Response()
00047 
00048     def __init__(self, form=None):
00049         self.form = form
00050 
00051 
00052 class Brain(object):
00053 
00054     Title = 'BrainTitle'
00055     is_folderish = True
00056 
00057     def __init__(self, rid):
00058         self.rid = rid
00059 
00060     def getPath(self):
00061         return self.rid
00062 
00063 
00064 class DummyCatalog(dict):
00065 
00066     def __init__(self, values):
00067         for r in values:
00068             self[r] = Brain(r)
00069 
00070     def __call__(self, **values):
00071         if 'SearchableText' in values:
00072             st = values['SearchableText']
00073             if st.startswith('error'):
00074                 raise ParseError
00075         return self.values()
00076 
00077     @property
00078     def _catalog(self):
00079         return self
00080 
00081     def getrid(self, value):
00082         return value in self and value or None