def create(context, namespace_name, values, session):
 namespace = namespace_api.get(context, namespace_name, session)
 resource_type_name = values['name']
 metadef_utils.drop_protected_attrs(models.MetadefNamespaceResourceType, values)
 try:
  resource_type = resource_type_api.get(context, resource_type_name, session)
 except exc.NotFound:
  resource_type = None
  LOG.debug('Creating resource-type %s', resource_type_name)
 if (resource_type is None):
  resource_type_dict = {'name': resource_type_name, 'protected': False}
  resource_type = resource_type_api.create(context, resource_type_dict, session)
 ns_resource_type_dict = _to_db_dict(namespace['id'], resource_type['id'], values)
 new_rec = _create_association(context, namespace_name, resource_type_name, ns_resource_type_dict, session)
 return _to_model_dict(resource_type_name, new_rec)

def create ( context , namespace_name , values , session ) : namespace = namespace_api . get ( context , namespace_name , session ) resource_type_name = values [ 'name' ] metadef_utils . drop_protected_attrs ( models . MetadefNamespaceResourceType , values ) try : resource_type = resource_type_api . get ( context , resource_type_name , session ) except exc . NotFound : resource_type = None LOG . debug ( 'Creating resource-type %s' , resource_type_name ) if ( resource_type is None ) : resource_type_dict = { 'name' : resource_type_name , 'protected' : False } resource_type = resource_type_api . create ( context , resource_type_dict , session ) ns_resource_type_dict = _to_db_dict ( namespace [ 'id' ] , resource_type [ 'id' ] , values ) new_rec = _create_association ( context , namespace_name , resource_type_name , ns_resource_type_dict , session ) return _to_model_dict ( resource_type_name , new_rec )
redirect to asset/create .