A collection of functions used in both server and client reference implementations.
Warning
This variable will be moved to RestAuthCommon.handlers soon.
Mapping of MIME types to their respective handler implemenation. You can use this dictionary to dynamically look up a content handler if you do not know the requested content type in advance.
MIME type | handler | notes |
---|---|---|
application/json | handlers.json | default |
application/x-www-form-urlencoded | handlers.form | Only use this for testing |
application/xml | handlers.xml | not yet implemented |
If you want to provide your own implementation of a content_handler, you can add it to this dictionary with the appropriate MIME type as the key.
Marshal the object obj into a string of the MIME type content_type.
This method is just intended as a shortcut for content_handler.unmarshal(). If you intend to use a handler multiple times, it is better to instantiate a specific handler directly to save dictionary lookups and object instantiations.
Warning
This method will be deprecated soon.
Parameters: |
|
---|---|
Returns: | The string representation of the object. |
Return type: | str |
Raises error.MarshalError: | |
When the handler could not marshal the object. |
|
See also: |
Warning
This code will be moved to its own submodule soon.
Check the name of a resource for some really bad characters that shouldn’t be used anywhere in RestAuth.
This filters names containing a slash (“/”) or colon (”:”) and those starting with ‘.’. It also filters control characters etc., including those from unicode.
Parameters: | name (str) – The name to validate |
---|---|
Returns: | False if the name contains any invalid characters, True otherwise. |
Return type: | bool |
Unmarshal the string raw_data into an object of type typ. The string is assumed to be of the MIME type content_type.
This method is just intended as a shortcut for content_handler.unmarshal(). If you intend to use a handler multiple times, it is better to instantiate a specific handler directly to save dictionary lookups and object instantiations.
Warning
This method will be deprecated soon.
Parameters: |
|
---|---|
Return type: | typ |
Returns: | The unmarshalled data. The object has the type specified by the I{typ} parameter. |
Raises error.UnmarshalError: | |
When the handler was unable unmarshal the object. |
|
See also: |