Skip to content

Commit

Permalink
Fix an issue in _create_pantherdb_session()
Browse files Browse the repository at this point in the history
  • Loading branch information
AliRn76 committed Jan 24, 2024
1 parent 8779ee5 commit aea54dc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions docs/docs/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.8.1
- Fix an issue in `_create_pantherdb_session()`

### 3.8.0
- Handle WebSocket connections when we have multiple workers with `multiprocessing.Manager`

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/serializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ Use panther `ModelSerializer` to write your serializer which will use your `mode
return Response(data=request.validated_data, status_code=status.HTTP_202_ACCEPTED)
```

### Notes:
## Notes
1. In the example above `UserModelSerializer` only accepts the values of `fields` attribute

2. In default the `UserModelSerializer.fields` are same as `User.fields` but you can change their default and make them required with `required_fields` attribute

3. If you want uses `required_fields` you have to put them in `fields` too.
3. If you want to use `required_fields` you have to put them in `fields` too.

4. `fields` attribute is `required` when you are using `ModelSerializer` as `metaclass`

Expand Down
2 changes: 1 addition & 1 deletion panther/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from panther.main import Panther # noqa: F401

__version__ = '3.8.0'
__version__ = '3.8.1'


def version():
Expand Down
5 changes: 2 additions & 3 deletions panther/cli/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def info_api(request: Request):
models_py = """from panther.db import Model
"""

serializers_py = """from pydantic import BaseModel
serializers_py = """from panther.serializer import ModelSerializer
"""

throttling_py = """from datetime import timedelta
Expand Down Expand Up @@ -70,8 +70,7 @@ async def info_api(request: Request):
URLs = 'core.urls.url_routing'
""" % datetime.now().date().isoformat()

env = """
SECRET_KEY = '%s'
env = """SECRET_KEY='%s'
""" % generate_secret_key()

main_py = """from panther import Panther
Expand Down
5 changes: 4 additions & 1 deletion panther/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ def _create_mongodb_session(self, db_url: str) -> None:
self._session: Database = self._client.get_database()

def _create_pantherdb_session(self, db_url: str) -> None:
params = {'db_name': db_url, 'return_dict': True}
if config['pantherdb_encryption']:
try:
import cryptography
except ModuleNotFoundError as e:
import_error(e, package='cryptography')
self._session: PantherDB = PantherDB(db_url, return_dict=True, secret_key=config['secret_key'])
else:
params['secret_key'] = config['secret_key']
self._session: PantherDB = PantherDB(**params)

def close(self) -> None:
if self._db_name == 'mongodb':
Expand Down

0 comments on commit aea54dc

Please sign in to comment.