djblets.extensions.resources¶
- class ExtensionResource(extension_manager)¶
Bases:
WebAPIResourceProvides information on installed extensions.
- model¶
alias of
RegisteredExtension
- fields = {'author': {'description': 'The author of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'author_url': {'description': "The author's website.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'can_disable': {'description': 'Whether or not the extension can be disabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'can_enable': {'description': 'Whether or not the extension can be enabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'class_name': {'description': 'The class name for the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'enabled': {'description': 'Whether or not the extension is enabled.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'installed': {'description': 'Whether or not the extension is installed.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'load_error': {'description': 'If the extension could not be loaded, this will contain any errors captured while trying to load.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'loadable': {'description': 'Whether or not the extension is currently loadable. An extension may be installed but missing or may be broken due to a bug.', 'type': <class 'djblets.webapi.fields.BooleanFieldType'>}, 'name': {'description': 'The name of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'summary': {'description': "A summary of the extension's functionality.", 'type': <class 'djblets.webapi.fields.StringFieldType'>}, 'version': {'description': 'The installed version of the extension.', 'type': <class 'djblets.webapi.fields.StringFieldType'>}}¶
- name = 'extension'¶
- plural_name = 'extensions'¶
- uri_object_key = 'extension_name'¶
- uri_object_key_regex = '[.A-Za-z0-9_-]+'¶
- model_object_key = 'class_name'¶
- allowed_methods = ('GET', 'PUT')¶
- __init__(extension_manager)¶
- serialize_author_field(extension, *args, **kwargs)¶
- serialize_author_url_field(extension, *args, **kwargs)¶
- serialize_can_disable_field(extension, *args, **kwargs)¶
- serialize_can_enable_field(extension, *args, **kwargs)¶
- serialize_loadable_field(ext, *args, **kwargs)¶
- serialize_load_error_field(extension, *args, **kwargs)¶
- serialize_name_field(extension, *args, **kwargs)¶
- serialize_summary_field(extension, *args, **kwargs)¶
- serialize_version_field(extension, *args, **kwargs)¶
- get_list(**kwargs)¶
Returns the list of known extensions.
Each extension in the list has been installed, but may not be enabled.
- get_links(resources=[], obj=None, request=None, *args, **kwargs)¶
Returns a dictionary of links coming off this resource.
The resulting links will point to the resources passed in
resources, and will also provide special resources forself(which points back to the official location for this resource) and one per HTTP method/operation allowed on this resource.
- update(**kwargs)¶
Updates the state of the extension.
If
enabledis true, then the extension will be enabled, if it is not already. If false, it will be disabled.
- get_url_patterns()¶
Returns the Django URL patterns for this object and its children.
This is used to automatically build up the URL hierarchy for all objects. Projects should call this for top-level resources and return them in the
urls.pyfiles.
Returns links to the resources provided by the extension.
The result should be a dictionary of link names to a dictionary of information. The information should contain:
‘method’ - The HTTP method
‘href’ - The URL
‘title’ - The title of the link (optional)
‘resource’ - The WebAPIResource instance
‘list-resource’ - True if this links to a list resource (optional)
- class ExtensionRootResourceMixin(*args, **kwargs)¶
Bases:
objectMixin for Root Resources making use of Extension Resources.
As extensions are able to provide their own API resources, this mixin allows a root resource to generate URI templates for non built-in resources.
See also
- __init__(*args, **kwargs)¶
Initialize the extension resource mixin to listen for changes.
- get_extension_resource()¶
Return the associated extension resource.
Subclasses using this mixin must implement this method.
- Returns:
The extension resource associated with the root resource.
- Return type: