Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs - add detail to custom backend and pagination #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/custom_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,21 @@ Another way to provide a custom backend using flask proxy could be:

import MyCustomBackend
from flask import current_app
from medallion import application_instance, set_config
from medallion import application_instance, set_config, register_blueprints

MyCustomBackend.init() # Do some setup before attaching to application... (Imagine other steps happening here)

with application_instance.app_context():
current_app.medallion_backend = MyCustomBackend

# Do some other stuff...
set_config(application_instance, {...})
set_config(application_instance, "backend", {
"backend": {
"module": "mypackage.with_backends",
"module_class": "MyCustomBackend",
}
})
register_blueprints(application_instance)
application_instance.run()

How to use a different authentication library
Expand All @@ -109,7 +115,7 @@ If you need or prefer a library different from ``Flask-HTTPAuth``, you can overr
.. code-block:: python

from flask import current_app
from medallion import application_instance, auth, set_config, init_backend
from medallion import application_instance, auth, set_config, init_backend, register_blueprints

# This is a dummy implementation of Flask Auth that always returns false
dummy_auth = class DummyAuth(object):
Expand All @@ -128,6 +134,7 @@ If you need or prefer a library different from ``Flask-HTTPAuth``, you can overr

set_config(application_instance, {...})
init_backend(application_instance, {...})
register_blueprints(application_instance)
application_instance.run()

How to use a different backend to control users
Expand All @@ -139,7 +146,7 @@ Our implementation of a users authentication system is not suitable for a produc

import MyCustomDBforUsers
from flask import current_app
from medallion import application_instance, set_config
from medallion import application_instance, set_config, register_blueprints

# This is a dummy implementation of Flask Auth that always returns false
dummy_auth = class DummyAuth(object):
Expand All @@ -163,4 +170,5 @@ Our implementation of a users authentication system is not suitable for a produc
current_app.users_config = db # This will make it available inside the Flask instance in case you decide to perform changes to the internal blueprints.

init_backend(application_instance, {...})
register_blueprints(application_instance)
application_instance.run()
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Welcome to medallion's documentation!

compatibility
custom_backend
page_size
mongodb_schema
contributing

Expand Down
30 changes: 30 additions & 0 deletions docs/page_size.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Custom Page Size
=========================

How to set pagination limits
---------------------------------

To specify a pagination limit with medallion you should call ``set_config``
when creating your application.

.. code-block:: python

from medallion import application_instance, set_config

set_config(application_instance, "taxii", {"taxii": {"max_page_size": 100}})


How to access the pagination limit
-------------------------------

From within your application, you can then access the configured pagination limit
through the ``current_app`` object.

.. code-block:: python

from medallion import current_app

page_size = current_app.taxii_config["max_page_size"]