def __call__(self, form):
     graph_xml = form.request.form['data']
     graph = SetobjectGraph(form.request, graph_xml)
     graph.save()
     plan_id = form.request.form['plan_identifier']
     obj = GenericSet()
     obj.plan_identifier = str(plan_id)
     obj.title = plan_id
     obj.klass = str(form.request.form['klass'])
     obj.table_identifier = str(form.request.form['table_identifier'])
     form.adder.add(obj)
     return form.redirect(form.url(obj))
def init_application(event):
    application = event.object
    if not IDatashackle.providedBy(application):
        # no datashackle grok application
        return          

    # Site needs to be setted manually at this point.
    # Otherwise the framework does not notify the catalog to index the newly
    # created propertyform
    setSite(application)
        
    configfolder = Folder()
    configfolder.title = _(u'Configuration')
    application['configuration'] = configfolder
    # Deny view, edit permission to role dolmen.Owner (which is the default role for our restricted users).
    role_permission = IRolePermissionManager(configfolder)
    role_permission.denyPermissionToRole('dolmen.content.View', 'dolmen.Owner')
    #role_permission.grantPermissionToRole('dolmen.content.View', 'zope.Manager')
    role_permission.denyPermissionToRole('dolmen.content.Edit', 'dolmen.Owner')
    #role_permission.grantPermissionToRole('dolmen.content.Edit', 'zope.Manager')



    metaconfig = Folder()
    metaconfig.title = _(u'Meta configuration')
    configfolder['meta'] = metaconfig
    ignore_enumeration(metaconfig, 'zope.Everybody') 
 
    
    #users = Users()
    #users.title = _(u'Users')
    #configfolder['users'] = users

    set_ = GenericSet()
    set_.title = u'p2_model'
    set_.plan_identifier = 'p2_model'
    set_.table_identifier = 'p2_model'
    set_.table_key_field = 'plan_identifier'
    metaconfig['p2_model'] = set_

    set_ = GenericSet()
    set_.title = u'p2_form'
    set_.plan_identifier = 'p2_form'
    set_.table_identifier = 'p2_form'
    set_.table_key_field = 'form_identifier'
    metaconfig['p2_form'] = set_
 
    archetypes = GenericSet()
    archetypes.title = _(u'p2_archetype')
    archetypes.plan_identifier = 'p2_archetype'
    archetypes.table_identifier = 'p2_archetype'
    archetypes.table_key_field = 'id'
    metaconfig['p2_archetypes'] = archetypes
    
    linkageforms = GenericSet()
    linkageforms.title = u'p2_linkage'
    linkageforms.plan_identifier = 'p2_linkage'
    linkageforms.table_identifier = 'p2_linkage'
    linkageforms.table_key_field = 'id'
    metaconfig['p2_linkage'] = linkageforms
    
    set_ = GenericSet()
    set_.title = u'p2_relation'
    set_.plan_identifier = 'p2_relation'
    set_.table_identifier = 'p2_relation'
    set_.table_key_field = 'id'
    metaconfig['p2_relation'] = set_

    widget = GenericSet()
    widget.title = u'p2_widget'
    widget.plan_identifier = 'p2_widget'
    widget.table_identifier = 'p2_widget'
    widget.table_key_field = 'widget_identifier'
    metaconfig['p2_widget'] = widget
    
    set_ = GenericSet()
    set_.title = u'p2_span'
    set_.plan_identifier = 'p2_span'
    set_.table_identifier = 'p2_span'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_span_embeddedform'
    set_.plan_identifier = 'p2_span_embeddedform'
    set_.table_identifier = 'p2_span_embeddedform'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span_embeddedform'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_span_fileupload'
    set_.plan_identifier = 'p2_span_fileupload'
    set_.table_identifier = 'p2_span_fileupload'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span_fileupload'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_span_alphanumeric'
    set_.plan_identifier = 'p2_span_alphanumeric'
    set_.table_identifier = 'p2_span_alphanumeric'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span_alphanumeric'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_span_checkbox'
    set_.plan_identifier = 'p2_span_checkbox'
    set_.table_identifier = 'p2_span_checkbox'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span_checkbox'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_span_dropdown'
    set_.plan_identifier = 'p2_span_dropdown'
    set_.table_identifier = 'p2_span_dropdown'
    set_.table_key_field = 'span_identifier'
    metaconfig['p2_span_dropdown'] = set_
    
    set_ = GenericSet()
    set_.title = u'p2_countries'
    set_.plan_identifier = 'p2_countries'
    set_.table_identifier = 'p2_country'
    set_.table_key_field = 'id'
    metaconfig['p2_span_countries'] = set_