Back to index

plone3  3.1.7
Classes | Functions | Variables
Archetypes.ClassGen Namespace Reference

Classes

class  GeneratorError
class  Generator
class  ClassGenerator

Functions

def generateCtor
def generateZMICtor

Variables

list AT_GENERATE_METHOD = []
dictionary _modes
tuple _cg = ClassGenerator()
 generateClass = _cg.generateClass
 generateMethods = _cg.generateMethods

Class Documentation

class Archetypes::ClassGen::GeneratorError

Definition at line 32 of file ClassGen.py.


Function Documentation

def Archetypes.ClassGen.generateCtor (   name,
  module 
)

Definition at line 197 of file ClassGen.py.

00197 
00198 def generateCtor(name, module):
00199     # self is a App.FactoryDispater, Destination() is the real folder
00200     ctor = """
00201 def add%(name)s(self, id, **kwargs):
00202     from zope.event import notify
00203     from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
00204     obj = %(name)s(id)
00205     notify(ObjectCreatedEvent(obj))
00206     self._setObject(id, obj)
00207     obj = self._getOb(id)
00208     obj.initializeArchetype(**kwargs)
00209     notify(ObjectModifiedEvent(obj))
00210     return obj.getId()
00211 """ % {'name' : name}
00212     exec ctor in module.__dict__
00213     return getattr(module, "add%s" % name)

Here is the caller graph for this function:

def Archetypes.ClassGen.generateZMICtor (   name,
  module 
)

Definition at line 214 of file ClassGen.py.

00214 
00215 def generateZMICtor(name, module):
00216     zmi_ctor = """
00217 def manage_add%(name)s(self, id, REQUEST=None):
00218     ''' Constructor for %(name)s '''
00219     kwargs = {}
00220     if REQUEST is not None:
00221         kwargs = REQUEST.form.copy()
00222         del kwargs['id']
00223     id = add%(name)s(self, id, **kwargs)
00224     obj = self._getOb(id)
00225     manage_tabs_message = 'Successfully added %(name)s'
00226     if REQUEST is not None:
00227         url = obj.absolute_url()
00228         REQUEST.RESPONSE.redirect(url + '/manage_edit%(name)sForm?manage_tabs_message=' + manage_tabs_message)
00229     return id
00230 """ % {'name':name}
00231     exec zmi_ctor in module.__dict__
00232     return getattr(module, "manage_add%s" % name)
00233 

Here is the caller graph for this function:


Variable Documentation

Definition at line 234 of file ClassGen.py.

Initial value:
00001 {
00002     'r' : { 'prefix'   : 'get',
00003             'attr'     : 'accessor',
00004             'security' : 'read_permission',
00005             },
00006     'm' : { 'prefix'   : 'getRaw',
00007             'attr'     : 'edit_accessor',
00008             'security' : 'write_permission',
00009             },
00010     'w' : { 'prefix'   : 'set',
00011             'attr'     : 'mutator',
00012             'security' : 'write_permission',
00013             },
00014 
00015     }

Definition at line 16 of file ClassGen.py.

Definition at line 13 of file ClassGen.py.

Archetypes.ClassGen.generateClass = _cg.generateClass

Definition at line 235 of file ClassGen.py.

Archetypes.ClassGen.generateMethods = _cg.generateMethods

Definition at line 236 of file ClassGen.py.