def initialize_sanitized_properties( context, resource_type, resource_name, properties): properties = properties.split(',') properties = dict([(p.strip(), '<script>foo</script>') for p in properties]) print properties handle_named_example_resource( context, resource_type, resource_name, **properties)
def initialize_sanitized_properties( context, resource_type, resource_name, properties): properties = properties.split(',') properties = dict([ (p.strip(), '<script>foo{}</script>'.format(resource_type)) for p in properties ]) handle_named_example_resource( context, resource_type, resource_name, **properties)
def post_collection_of_resources(context): """Iterate over a table where the first two columns are `type` and `name`. Successive columns are for properties to be set on the resource before posting it to the relevant collection. """ for row in context.table: resource_type = row[0] name = row[1] properties = dict([(heading, row[heading]) for heading in row.headings[2:]]) handle_named_example_resource(context, resource_type, name, **properties) handle_post_named_example(context, name) handle_get_example_resource(context, name)
def create_category(context, name, category_type): handle_named_example_resource(context, 'Category', name, type=category_type)
def create_option(context, name, role): handle_named_example_resource(context, 'Option', name, role=role)
def named_example_resource(context, resource_type, example_name, **kwargs): handle_named_example_resource(context, resource_type, example_name, **kwargs)
def named_example_from_json(context, resource_type, example_name): text = handle_template_text(context, context.text) json_obj = json.loads(text) handle_named_example_resource(context, resource_type, example_name, **json_obj)
def create_option(context, name, role): handle_named_example_resource(context, "Option", name, role=role)
def create_role_from_json(context, role_name): json_obj = json.loads(context.text) handle_named_example_resource(context, Role, role_name, **json_obj)
def named_example_from_json(context, resource_type, example_name): text = handle_template_text(context, context.text) json_obj = json.loads(text) handle_named_example_resource( context, resource_type, example_name, **json_obj)
def create_category(context, name, scope): handle_named_example_resource(context, 'Category', name, scope_id=int(scope))