Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote some chapters of documentation, fixed some isort and flake8 issues
- Loading branch information
Showing
11 changed files
with
431 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# flake8: noqa | ||
|
||
import sys | ||
|
||
sys.path.insert(0, '../..') | ||
|
||
from django_selectel_storage import __version__ # isort:skip noqa: E731 | ||
|
||
project = 'django-selectel-storage' | ||
copyright = '2018, Mikhail Porokhovnichenko' | ||
author = 'Mikhail Porokhovnichenko' | ||
|
||
# The short X.Y version | ||
version = __version__ | ||
|
||
release = __version__ | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.doctest', | ||
] | ||
|
||
templates_path = ['_templates'] | ||
|
||
source_suffix = '.rst' | ||
|
||
master_doc = 'index' | ||
|
||
# The language for content autogenerated by Sphinx. Refer to documentation | ||
# for a list of supported languages. | ||
# | ||
# This is also used if you do content translation via gettext catalogs. | ||
# Usually you set "language" from the command line for these cases. | ||
language = None | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = [] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = None | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = 'alabaster' | ||
|
||
# Theme options are theme-specific and customize the look and feel of a theme | ||
# further. For a list of options available for each theme, see the | ||
# documentation. | ||
# | ||
# html_theme_options = {} | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] | ||
|
||
# Custom sidebar templates, must be a dictionary that maps document names | ||
# to template names. | ||
# | ||
# The default sidebars (for documents that don't match any pattern) are | ||
# defined by theme itself. Builtin themes are using these templates by | ||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', | ||
# 'searchbox.html']``. | ||
# | ||
# html_sidebars = {} | ||
|
||
|
||
# -- Options for HTMLHelp output --------------------------------------------- | ||
|
||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = 'django-selectel-storagedoc' | ||
|
||
|
||
# -- Options for manual page output ------------------------------------------ | ||
|
||
# One entry per manual page. List of tuples | ||
# (source start file, name, description, authors, manual section). | ||
man_pages = [ | ||
(master_doc, | ||
'django-selectel-storage', | ||
'django-selectel-storage Documentation', | ||
[author], 1) | ||
] | ||
|
||
|
||
# -- Options for Epub output ------------------------------------------------- | ||
|
||
# Bibliographic Dublin Core info. | ||
epub_title = project | ||
|
||
# The unique identifier of the text. This can be a ISBN number | ||
# or the project homepage. | ||
# | ||
# epub_identifier = '' | ||
|
||
# A unique identification for the text. | ||
# | ||
# epub_uid = '' | ||
|
||
# A list of files that should not be packed into the epub file. | ||
epub_exclude_files = ['search.html'] | ||
|
||
# -- Extension configuration ------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
Configuration | ||
============= | ||
|
||
Here, we assume you already: | ||
|
||
* `Have registered <https://kb.selectel.com/22063010.html>`_ an account on Selectel, | ||
* `Spent some money <https://kb.selectel.com/27821850.html>`_ there, | ||
* `Created a couple of containers <https://kb.selectel.com/23137040.html#BasicOverview-CreatingandConfiguringContainers>`_ and got credentials for it. | ||
|
||
if you haven't yet, consider doing that right now. | ||
|
||
|
||
A minimal installation | ||
---------------------- | ||
|
||
To begin using Selectel storage as your storage, you should configure | ||
your containers credentials: | ||
|
||
.. code:: python | ||
SELECTEL_STORAGES = { | ||
'default': { | ||
'USERNAME': 'xxxx_user', | ||
'PASSWORD': 'p455w0rd', | ||
'CONTAINER': 'my-data', | ||
}, | ||
'yet_another_storage': 'selectel://xxxx_user:p455w0rd2@another-container', | ||
} | ||
As you already guessed, the dictionary means you can create as much configurations | ||
as you want. Here, we have two schemas: ``default`` and ``yet_another_storage``. | ||
|
||
|
||
**You're free to use any names for schema but strongly recommended to declare | ||
a schema with name ``default``.** | ||
|
||
Also, as you already guessed again, you can specify credentials either: | ||
|
||
* As a dictionary with ``USERNAME``, ``PASSWORD`` or ``CONTAINER`` keys, or | ||
* a URL-like string with schema ``selectel://`` | ||
|
||
Please see all available configuration options below. | ||
|
||
.. attention:: | ||
Credentials in examples above are hardcoded. It really sucks, don't | ||
do that in real life. Instead, you can store these variables in the | ||
environment and extract it out of there, for example, via awesome | ||
`python-decouple <https://pypi.org/project/python-decople/>`_ package. | ||
|
||
|
||
Using django-selectel-storage as a default backend | ||
-------------------------------------------------- | ||
|
||
If you want to use the storage by default, consider adding to your ``settings.py``: | ||
|
||
.. code:: python | ||
DEFAULT_FILE_STORAGE = 'django_selectel_storage.storage.SelectelStorage' | ||
in this case, the ``default`` schema will be implicitly used. Please make sure | ||
you defined it before. | ||
|
||
|
||
Storage initialization | ||
---------------------- | ||
|
||
If you want to explicitly instantiate a storage, you should write something like that: | ||
|
||
.. code:: python | ||
# models.py | ||
from django.db import models | ||
class Post(models.Model): | ||
photo = models.ImageField(storage=storage_instance) | ||
Wondering, what ``storage_instance`` is? Well, it would be one of: | ||
|
||
.. code:: python | ||
from django_selectel_storage.storage import SelectelStorage | ||
storage_instance = SelectelStorage() | ||
storage_instance = SelectelStorage('default') | ||
storage_instance = SelectelStorage(storage='default') | ||
Please pay attention: the last three lines of code do the same thing: creates | ||
a ``SelectelStorage`` instance with using ``default`` schema. Of course, you | ||
can choose any different schema (if you've defined it of course): | ||
|
||
.. code:: python | ||
storage_instance = SelectelStorage('yet_another_storage') | ||
storage_instance = SelectelStorage(storage='yet_another_storage') | ||
We even create an instance via DSN (it's useful somewhere in ``./manage.py shell``, please don't do that in production): | ||
|
||
.. code:: python | ||
storage_instance = SelectelStorage('selectel://user:password@container_name/') | ||
storage_instance = SelectelStorage(storage='selectel://user:password@container_name/') | ||
An interesting gotcha here: if you specify a DSN (a string begins with ``selectel://``) as a first positional argument, it would | ||
act like a dsn rather as ``storage=`` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.. | ||
django-selectel-storage | ||
####################### | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
introduction | ||
install | ||
usage | ||
configuration | ||
changelog | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
Oops, something went wrong.