Back to index

plone3  3.1.7
filtercore.py
Go to the documentation of this file.
00001 ##########################################################
00002 #
00003 # Licensed under the terms of the GNU Public License
00004 # (see docs/LICENSE.GPL)
00005 #
00006 # Copyright (c) 2005:
00007 #   - The Open Planning Project (http://www.openplans.org/)
00008 #   - Whit Morriss <whit at www.openplans.org>
00009 #   - and contributors
00010 #
00011 ##########################################################
00012 from general import dummy
00013 from wicked.factories import ContentCacheManager     
00014 
00015 def fakecacheiface(cached):
00016     def call(*args):
00017         return args[0]
00018     def set(*args):
00019         return "<link cached>"
00020     methods = dict(__call__=call, set=set) 
00021     cacheman=type('dummy',
00022                   (dict,), methods)()
00023     cacheman.update(cached)
00024     return cacheman
00025 
00026 class query(object):
00027     
00028     brains = ['We are brains!']
00029     
00030     def scopedSearch(self):
00031         if self.chunk != 'dud':
00032             return self.brains
00033         
00034     def configure(self, chunk, normalized, scope):
00035         self.chunk = chunk
00036         self.normalized = normalized
00037         self.scope = scope
00038         
00039     def search(self):
00040         if self.chunk != 'dud' and self.chunk != 'scoped':
00041             return self.brains
00042 
00043 def argchug(rets):
00044     def function(*args, **kwargs):
00045         return rets
00046     
00047 def fakefilter():
00048     def conf(*args, **kw):
00049         self = list(args).pop()
00050         [setattr(self, k, v) for k, v in kw.items()]
00051         return kw
00052     conf = classmethod(conf)
00053     kdict = dict(configure=conf, scope='/scope/')
00054     wfilter = dummy(kdict, name='wfilter')
00055     wfilter.query_iface = query()
00056     wfilter.getMatch = argchug(('uid', 'link'))
00057     wfilter.resolver = query()
00058     wfilter.section=hash(wfilter)
00059     wfilter.cache=ContentCacheManager(dummy(dict()))
00060     return wfilter