Skip to content

Commit 67a2359

Browse files
authored
Merge branch 'main' into operations
2 parents 7d9b48e + e747973 commit 67a2359

File tree

17 files changed

+372
-34
lines changed

17 files changed

+372
-34
lines changed

.github/workflows/release-python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ jobs:
3939
outputs:
4040
version: ${{ steps.pre-publish.outputs.version }}
4141
steps:
42-
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
42+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@0e9d3008f418020d3039c45e633e887829110d9b # v3
4343
with:
4444
app_id: ${{ vars.APP_ID }}
4545
private_key: ${{ secrets.APP_PRIVATE_KEY }}
46-
- uses: mongodb-labs/drivers-github-tools/setup@v2
46+
- uses: mongodb-labs/drivers-github-tools/setup@0e9d3008f418020d3039c45e633e887829110d9b # v3
4747
with:
4848
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
4949
aws_region_name: ${{ vars.AWS_REGION_NAME }}
5050
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
5151
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
52-
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@v2
52+
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@0e9d3008f418020d3039c45e633e887829110d9b # v3
5353
id: pre-publish
5454
with:
5555
dry_run: ${{ env.DRY_RUN }}
@@ -99,17 +99,17 @@ jobs:
9999
attestations: write
100100
security-events: write
101101
steps:
102-
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
102+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@0e9d3008f418020d3039c45e633e887829110d9b # v3
103103
with:
104104
app_id: ${{ vars.APP_ID }}
105105
private_key: ${{ secrets.APP_PRIVATE_KEY }}
106-
- uses: mongodb-labs/drivers-github-tools/setup@v2
106+
- uses: mongodb-labs/drivers-github-tools/setup@0e9d3008f418020d3039c45e633e887829110d9b # v3
107107
with:
108108
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
109109
aws_region_name: ${{ vars.AWS_REGION_NAME }}
110110
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
111111
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
112-
- uses: mongodb-labs/drivers-github-tools/python/post-publish@v2
112+
- uses: mongodb-labs/drivers-github-tools/python/post-publish@0e9d3008f418020d3039c45e633e887829110d9b # v3
113113
with:
114114
following_version: ${{ env.FOLLOWING_VERSION }}
115115
product_name: ${{ env.PRODUCT_NAME }}

django_mongodb_backend/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import copy
22
import time
3+
import warnings
34

45
import django
56
from django.conf import settings
67
from django.core.exceptions import ImproperlyConfigured, ValidationError
78
from django.db.backends.utils import logger
9+
from django.utils.deprecation import RemovedInDjango60Warning
810
from django.utils.functional import SimpleLazyObject
911
from django.utils.text import format_lazy
1012
from django.utils.version import get_version_tuple
@@ -33,6 +35,11 @@ def parse_uri(uri, *, db_name=None, options=None, test=None):
3335
Convert the given uri into a dictionary suitable for Django's DATABASES
3436
setting.
3537
"""
38+
warnings.warn(
39+
'parse_uri() is deprecated. Put the connection string in DATABASES["HOST"] instead.',
40+
RemovedInDjango60Warning,
41+
stacklevel=2,
42+
)
3643
uri = pymongo_parse_uri(uri)
3744
host = None
3845
port = None

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"python": ("https://docs.python.org/3/", None),
5252
"atlas": ("https://www.mongodb.com/docs/atlas/", None),
5353
"manual": ("https://www.mongodb.com/docs/manual/", None),
54+
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
5455
}
5556

5657
# -- Options for HTML output -------------------------------------------------

docs/contents.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Table of contents
1515
howto/index
1616
faq
1717
releases/index
18-
internals
18+
internals/index
1919

2020
Indices
2121
=======

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Miscellaneous
6161
=============
6262

6363
- :doc:`releases/index`
64-
- :doc:`internals`
64+
- :doc:`internals/index`
6565

6666
.. Keep this toctree in sync with contents.rst.
6767
@@ -75,4 +75,4 @@ Miscellaneous
7575
howto/index
7676
faq
7777
releases/index
78-
internals
78+
internals/index
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
======================================
2+
Reporting bugs and requesting features
3+
======================================
4+
5+
.. Important::
6+
7+
Please :ref:`report security issues privately <reporting-security-issues>`.
8+
9+
.. _issue-tracker:
10+
11+
Issue tracker
12+
=============
13+
14+
To report a bug or request a new feature in Django MongoDB Backend, please open
15+
an issue in our issue tracker, JIRA:
16+
17+
1. Create a `JIRA account <https://jira.mongodb.org/>`_.
18+
19+
2. Navigate to the `Python Integrations project
20+
<https://jira.mongodb.org/projects/INTPYTHON/>`_.
21+
22+
3. Click **Create Issue**. Please provide as much information as possible about
23+
the issue and the steps to reproduce it.
24+
25+
Bug reports in JIRA for this project can be viewed by everyone.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
============
2+
Coding style
3+
============
4+
5+
Please follow these coding standards when writing code.
6+
7+
.. _coding-style-pre-commit:
8+
9+
Pre-commit checks
10+
=================
11+
12+
`pre-commit <https://pre-commit.com>`_ is a framework for managing pre-commit
13+
hooks. These hooks help to identify simple issues before committing code for
14+
review. By checking for these issues before code review it allows the reviewer
15+
to focus on the change itself, and it can also help to reduce the number of CI
16+
runs.
17+
18+
To use the tool, first install ``pre-commit`` and then the git hooks:
19+
20+
.. code-block:: bash
21+
22+
$ python -m pip install pre-commit
23+
$ pre-commit install
24+
25+
On the first commit ``pre-commit`` will install the hooks, these are installed
26+
in their own environments and will take a short while to install on the first
27+
run. Subsequent checks will be significantly faster. If an error is found an
28+
appropriate error message will be displayed. If the error was with ``ruff`` (a
29+
tool to standardize code formatting), then it will go ahead and fix it for you.
30+
Review the changes and re-stage for commit if you are happy with them.
31+
32+
.. seealso::
33+
34+
The guidelines from Django's :ref:`Python style guide<coding-style-python>`
35+
are generally applicable.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=================
2+
Contributing code
3+
=================
4+
5+
So you'd like to write some code or documentation to improve Django MongoDB
6+
Backend? Here are some resources:
7+
8+
.. toctree::
9+
10+
coding-style
11+
unit-tests
12+
writing-documentation
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
==========
2+
Unit tests
3+
==========
4+
5+
Django MongoDB Backend uses the Django test suite, located in
6+
``django-repo/tests``, as well as additional tests of its own, located in the
7+
``tests`` directory of the Django MongoDB Backend repository.
8+
9+
The tests use the testing infrastructure that ships with Django. See
10+
:doc:`django:topics/testing/overview` for an explanation of how to write new
11+
tests.
12+
13+
.. _running-unit-tests:
14+
15+
Running the unit tests
16+
======================
17+
18+
First, `fork Django MongoDB Backend on GitHub
19+
<https://github.com/mongodb/django-mongodb-backend/fork>`__.
20+
21+
Second, create and activate a Python virtual environment:
22+
23+
.. code-block:: bash
24+
25+
$ python -m venv .venv
26+
$ source .venv/bin/activate
27+
28+
Third, clone your fork and install it:
29+
30+
.. code-block:: bash
31+
32+
$ git clone https://github.com/YourGitHubName/django-mongodb-backend.git
33+
$ cd django-mongodb-backend
34+
$ pip install -e .
35+
36+
Next, get and install a copy of MongoDB's Django fork. This fork has some
37+
test suite adaptions for Django MongoDB Backend. There is a branch for each
38+
feature release of Django (e.g. ``mongodb-5.2.x`` below).
39+
40+
.. code-block:: bash
41+
42+
$ git clone https://github.com/mongodb-forks/django.git django-repo
43+
$ cd django-repo
44+
$ git checkout -t origin/mongodb-5.2.x
45+
$ python -m pip install -e .
46+
$ python -m pip install -r tests/requirements/py3.txt
47+
48+
Next, start :doc:`a local instance of mongod
49+
<manual:tutorial/manage-mongodb-processes>`.
50+
51+
Then, create a test settings file, ``django-repo/tests/test_mongo.py``::
52+
53+
from test_sqlite import *
54+
55+
DATABASES = {
56+
"default": {
57+
"ENGINE": "django_mongodb_backend",
58+
"NAME": "django",
59+
# Needed if connecting to the Atlas test VM.
60+
"OPTIONS": {"directConnection": True},
61+
},
62+
"other": {
63+
"ENGINE": "django_mongodb_backend",
64+
"NAME": "django1",
65+
"OPTIONS": {"directConnection": True},
66+
},
67+
}
68+
69+
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
70+
71+
Finally, you can run the test script in the Django repository:
72+
73+
$ ./tests/runtests.py --settings=test_mongo basic
74+
75+
This runs the tests in ``django-repo/tests/basic``. You can also specify a
76+
directory in ``django-mongodb-backend/tests``. All of these directories
77+
have an underscore suffix (e.g. ``queries_``) to distinguish them from Django's
78+
own test directories.
79+
80+
.. warning::
81+
82+
Don't try to invoke ``runtests.py`` without specifying any test apps
83+
(directories) as running all the tests at once will take hours.
84+
85+
.. seealso::
86+
87+
:doc:`Django's guide to running its test suite
88+
<django:internals/contributing/writing-code/unit-tests>`.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
=====================
2+
Writing documentation
3+
=====================
4+
5+
The documentation uses the `Sphinx <https://www.sphinx-doc.org/>`_
6+
documentation system.
7+
8+
How the documentation is organized
9+
==================================
10+
11+
The documentation is organized into several categories:
12+
13+
* :doc:`Tutorials </intro/index>` take the reader by the hand through a series
14+
of steps to create something.
15+
16+
The important thing in a tutorial is to help the reader achieve something
17+
useful, preferably as early as possible, in order to give them confidence.
18+
19+
Explain the nature of the problem we're solving, so that the reader
20+
understands what we're trying to achieve. Don't feel that you need to begin
21+
with explanations of how things work - what matters is what the reader does,
22+
not what you explain. It can be helpful to refer back to what you've done and
23+
explain afterward.
24+
25+
* :doc:`Topic guides </topics/index>` aim to explain a concept or subject at a
26+
fairly high level.
27+
28+
Link to reference material rather than repeat it. Use examples and don't be
29+
reluctant to explain things that seem very basic to you - it might be the
30+
explanation someone else needs.
31+
32+
Providing background context helps a newcomer connect the topic to things
33+
that they already know.
34+
35+
* :doc:`Reference guides </ref/index>` contain technical references for APIs.
36+
They describe the functioning of Django MongoDB Backend's internal machinery
37+
and instruct in its use.
38+
39+
Keep reference material tightly focused on the subject. Assume that the
40+
reader already understands the basic concepts involved but needs to know or
41+
be reminded of how Django MongoDB Backend does it.
42+
43+
Reference guides aren't the place for general explanation. If you find
44+
yourself explaining basic concepts, you may want to move that material to a
45+
topic guide.
46+
47+
* :doc:`How-to guides </howto/index>` are recipes that take the reader through
48+
steps in key subjects.
49+
50+
What matters most in a how-to guide is what a user wants to achieve.
51+
A how-to should always be result-oriented rather than focused on internal
52+
details of how Django MongoDB Backend implements whatever is being discussed.
53+
54+
These guides are more advanced than tutorials and assume some knowledge about
55+
how Django MongoDB Backendo works.
56+
57+
How to start contributing documentation
58+
=======================================
59+
60+
Clone the Django repository to your local machine
61+
-------------------------------------------------
62+
63+
If you'd like to start contributing to the docs, get the source code
64+
repository:
65+
66+
.. code-block:: bash
67+
68+
$ git clone https://github.com/mongodb/django-mongodb-backend.git
69+
70+
If you're planning to submit these changes, you might find it useful to make a
71+
fork of this repository and clone your fork instead.
72+
73+
Set up a virtual environment and install dependencies
74+
-----------------------------------------------------
75+
76+
Create and activate a virtual environment, then install the dependencies:
77+
78+
.. code-block:: bash
79+
80+
$ python -m venv .venv
81+
$ source .venv/bin/activate
82+
$ python -m pip install -e ".[docs]"
83+
84+
Build the documentation locally
85+
-------------------------------
86+
87+
You build the HTML output from the ``docs`` directory:
88+
89+
.. code-block:: bash
90+
91+
$ cd docs
92+
$ make html
93+
94+
Your locally-built documentation will be accessible at
95+
``_build/html/index.html`` and it can be viewed in any web browser.
96+
97+
Making edits to the documentation
98+
---------------------------------
99+
100+
The source files are ``.rst`` files located in the ``docs/`` directory.
101+
102+
These files are written in the reStructuredText markup language. To learn the
103+
markup, see the :ref:`reStructuredText reference <sphinx:rst-index>`.
104+
105+
To edit this page, for example, edit the file
106+
``docs/internals/contributing/writing-documentation.txt`` and rebuild the
107+
HTML with ``make html``.

0 commit comments

Comments
 (0)