Back to index

plone3  3.1.7
Classes | Functions
wicked.fieldevent.meta Namespace Reference

Classes

class  NewLineTokens
class  IATFieldDecoratorDirective
class  IATSchemaFieldsImplementDirective

Functions

def decorate_at_field
def monkey_getset
def schemafields_implement
def schemafields_provide
def cleanup_schemafields_provide
def cleanup_decorate_at_field
def cleanUp
def test_suite

Function Documentation

Definition at line 159 of file meta.py.

Here is the call graph for this function:

Definition at line 150 of file meta.py.

00150 
00151 def cleanup_decorate_at_field():
00152     # unmonkey!
00153     global _fieldclass_monkies 
00154     for class_ in _fieldclass_monkies:
00155         class_.get = class_.__original_get
00156         class_.set = class_.__original_set
00157     _fieldclass_monkies = []
00158 

Here is the caller graph for this function:

Definition at line 143 of file meta.py.

00143 
00144 def cleanup_schemafields_provide():
00145     global _schemafields_marked
00146     for implements, schema, fieldnames in _schemafields_marked:
00147         schemafields_provide(implements, schema, fieldnames, cleanup=True)
00148     _schemafields_marked=[]
00149 

Here is the call graph for this function:

Here is the caller graph for this function:

def wicked.fieldevent.meta.decorate_at_field (   _context = None,
  fieldclass = None,
  zcml = True 
)

Definition at line 67 of file meta.py.

00067 
00068 def decorate_at_field(_context=None, fieldclass=None, zcml=True):
00069     if not fieldclass in _fieldclass_monkies:
00070 
00071         # register adapters to call original methods
00072 
00073         _get=fieldclass.get
00074         _set=fieldclass.set    
00075         
00076         @implementer(IFieldValue)
00077         @adapter(fieldclass, wicked.fieldevent.IFieldRenderEvent)
00078         def field_value(field, event):
00079             return _get(field, event.instance, **event.kwargs)
00080 
00081         @implementer(IFieldValueSetter)
00082         @adapter(fieldclass, wicked.fieldevent.IFieldStorageEvent)
00083         def field_value_set(field, event):
00084             _set(field, event.instance, event.value, **event.kwargs)
00085 
00086         if zcml:
00087             # do proper zopeish config
00088             zope.component.zcml.adapter(_context, (field_value,))
00089             zope.component.zcml.subscriber(_context,
00090                                            factory=field_value_set,
00091                                            provides=IFieldValueSetter)
00092             _context.action(
00093                 discriminator = (fieldclass, monkey_getset),
00094                 callable = monkey_getset,
00095                 args = (fieldclass,)
00096                 )
00097         else:
00098             # hook it up no delay
00099             monkey_getset(fieldclass)
00100             provideAdapter(field_value)
00101             provideSubscriptionAdapter(field_value_set)
00102 
00103 
_fieldclass_monkies=[]

Here is the call graph for this function:

Definition at line 104 of file meta.py.

00104 
00105 def monkey_getset(fieldclass):
00106     global _fieldclass_monkies
00107     _get=fieldclass.get
00108     _set=fieldclass.set    
00109     fieldclass.set = store
00110     fieldclass.get = render
00111     fieldclass.__original_get=_get
00112     fieldclass.__original_set=_set
00113     _fieldclass_monkies.append(fieldclass)
00114 

Here is the caller graph for this function:

def wicked.fieldevent.meta.schemafields_implement (   _context = None,
  atclass = None,
  implements = None,
  fields = [],
  zcml = True 
)

Definition at line 115 of file meta.py.

00115 
00116 def schemafields_implement(_context=None, atclass=None, implements=None, fields=[], zcml=True):
00117     if zcml:
00118         _context.action(
00119             discriminator = None,
00120             callable = provideInterface,
00121             args = ('', implements)
00122             )
00123     schemafields_provide(implements, atclass.schema, fields)        
00124 
00125 
_schemafields_marked=[]

Here is the call graph for this function:

def wicked.fieldevent.meta.schemafields_provide (   implements,
  schema,
  fieldnames,
  cleanup = False 
)

Definition at line 126 of file meta.py.

00126 
00127 def schemafields_provide(implements, schema, fieldnames, cleanup=False):
00128     action = noLongerProvides
00129     if not cleanup:
00130         global _schemafields_marked
00131         if (implements, schema, fieldnames) in _schemafields_marked:
00132             return
00133         _schemafields_marked.append((implements, schema, fieldnames))
00134         action = alsoProvides
00135 
00136     for name in fieldnames:
00137         field=schema[name]
00138         try:
00139             action(field, implements)
00140         except ValueError:
00141             pass
00142 

Here is the caller graph for this function:

Definition at line 169 of file meta.py.

00169 
00170 def test_suite():
00171     import unittest
00172     from zope.testing import doctest
00173     from zope.testing.cleanup import cleanUp
00174 
00175     def setUp(tc):
00176         # clean slate!
00177         cleanUp()
00178         provideHandler(wicked.fieldevent.notifyFieldEvent)
00179 
00180     def tearDown(tc):
00181         cleanUp()
00182 
00183     globs=globals()
00184     globs.update(locals())
00185     
00186     optflags = doctest.REPORT_ONLY_FIRST_FAILURE | doctest.ELLIPSIS
00187     meta = doctest.DocFileTest("meta.txt",
00188                              package="wicked.fieldevent",
00189                              globs=globs,
00190                              setUp=setUp,
00191                              tearDown=tearDown,
00192                              optionflags=optflags)
00193     
00194     return unittest.TestSuite((meta,))

Here is the call graph for this function: