From bb621b0f458f56669062741f62cc0f70911f7b6f Mon Sep 17 00:00:00 2001 From: Matteo Lodi <30625432+mlodic@users.noreply.github.com> Date: Mon, 19 Sep 2022 16:16:45 +0200 Subject: [PATCH] added python publish and fix to connection handling --- .github/workflows/pythonpublish.yml | 26 ++++++++++++++++++++++++++ djongo/base.py | 11 +++++------ setup.py | 8 +++++--- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/pythonpublish.yml diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml new file mode 100644 index 00000000..21f2f01d --- /dev/null +++ b/.github/workflows/pythonpublish.yml @@ -0,0 +1,26 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/djongo/base.py b/djongo/base.py index ba6766d7..714ba6f7 100644 --- a/djongo/base.py +++ b/djongo/base.py @@ -169,12 +169,11 @@ def get_new_connection(self, connection_params): # To prevent leaving unclosed connections behind, # client_conn must be closed before a new connection # is created. - if self.client_connection is not None: - self.client_connection.close() - logger.debug('Existing MongoClient connection closed') - - self.client_connection = Database.connect(db=name, **connection_params) - logger.debug('New Database connection') + if self.client_connection: + logger.debug('Using already existing connection') + else: + self.client_connection = Database.connect(db=name, **connection_params) + logger.debug('New Database connection') database = self.client_connection[name] self.djongo_connection = DjongoClient(database, es) diff --git a/setup.py b/setup.py index 73cb63e0..8a4b789f 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,8 @@ LONG_DESCRIPTION = """ +This is a Fork from Certego S.R.L. + Use Mongodb as a backend database for your django project, without changing a single django model! @@ -84,7 +86,7 @@ def find_version(*file_paths): install_requires = [ 'sqlparse==0.4.2', - 'pymongo>=3.2.0,<4.0.0', + 'pymongo>=3.2.0,<5.0.0', 'django>=2.1', ] @@ -92,13 +94,13 @@ def find_version(*file_paths): install_requires.append("dataclasses") setup( - name='djongo', + name='djongo-certego', version=find_version("djongo", "__init__.py"), include_package_data=True, packages=packages, url='https://www.djongomapper.com/', license='AGPL', - author='doableware', + author='Certego S.R.L.', author_email='support@doableware.com', description=( 'Driver for allowing Django to use MongoDB as the database backend.'),