Entity Request API

pyaella.server.api.model_edit_get(request)

Get (read) an Entity for a Model.

HTTP action GET

/m/edit/ModelName

Returns result_repr structured JSON of the entity.

pyaella.server.api.model_edit_put(request)

Put (update) Entity for a Model.

HTTP action PUT

/m/edit/ModelName

Any matching field in the supplied form-encoded data will update the corresponding field of the entity. The data must include either the entity’s key or id.

Returns result_repr structured JSON of the updated entity.

pyaella.server.api.model_edit_post(request)

Post (create) a new Entity for a Model.

HTTP action: POST

/m/edit/ModelName

Form-encoded data must not include key or id. All required fields for the model must be included and be the correct data type.

If override_method is included in the data and the value is PUT, the Put action will be called, however, an id or key must be included. This override is implemented to help clients that can’t support HTTP PUTs.

If override_method is included in the data and the value is DELETE, the Delete action will be called, and entity key is required.

If the model has POST hooks implemented in a Mixin, the hooks will be called.

Returns result_repr structured JSON of the new entity.

pyaella.server.api.model_edit_delete(request)

Delete the Entity for the Model.

HTTP action: DELETE

/m/edit/ModelName

Delete the entity. The form-encoded data must include the entity’s key

Returns JSON {‘status’:’OK’, ‘action’:’DELETE’, ‘entity_id’:[int]}

pyaella.server.api.model_search_get(request)

Search for an Entity for a Model

HTTP action: GET

/m/search/ModelName/filter_params_1=val/filter_params_2=val

/m/search/ModelName/starts_with=[filter_params_1=val]

Returns collected result_repr structured JSON of the matching entities.

pyaella.server.api.xmodel_upsert(request)

Update/Insert Entities for Model.

HTTP action: POST

Raw request body data is JSON formatted

JSON formatted argument example

{
'UserXUserTypeLookup':{
    'User': {
        'id':1,
        'key':'4c'
    },
    'UserTypeLookup': {
        'id':2,
        'key':'e4'
    }
}

Result format example

xrossable data = {
    u'UserTypeLookup': {
        u'id': 2, u'key': u'e4'
    }, 
    u'User': {
        u'id': 1, 
        u'key': u'4c'
    }
}

Returns result_repr structured JSON of the updated entity.

'{"UserXUserTeam": 
    {"User": {"phone_number": null, "last_name": "Mathews",
        "key": "4nbq", "pin": null, "address1": null,
        "address2": null, "is_active": null, "post_code": null,
        "country_code": "USA", "device_tokens": null,
        "password": null, "email_address": "mat@miga.me",
        "id": 10000, "city": null, 
        "first_name": "Mat", "open_id": null,
        "access_token": null,
        "region": null, "user_name": "mat"}, 
    "UserTeam": {"team_manager_id": 10000, "name": "Test Team",
        "key": "43", "id": 2}}}'
pyaella.server.api.make_result_repr(model, results, msg='', force_json=False, **kwds)
{model_name, entity_field_names, length, results, messages}
class pyaella.server.api.HttpMethodOverrideMiddleware(application)

WSGI middleware for overriding HTTP Request Method.

Examines the POST body for the value of ‘_method’ in a form-encoded POST or X-HTTP-Method-Override for an XML or JSON POST.

Middleware intercepts the POST and changes it to a GET,PUT, or DELETE before the Pyramid app receives it. So the HTTP request arrives as a POST to the server and gets around the URI length issue but is transformed into a request with the correct verb just before it hits the app for processing.

class pyaella.server.api.WebRoot(request)

default Root

class pyaella.server.api.AdminContext(request)

Administration context

/a/

class pyaella.server.api.ModelContext(request)

Model context

/m/

class pyaella.server.api.CompositeContext(request)

Composite context

/c/

class pyaella.server.api.LookupTableContext(request)

Lookup Table context

/lut/

class pyaella.server.api.XModelContext(request)

Associated Models context

/x/

class pyaella.server.api.UploadContext(request)

Upload context

/up/