GithubHelp home page GithubHelp logo

django-appwrite's Introduction

django-appwrite's People

Contributors

khashashin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

lapnd

django-appwrite's Issues

`log_error(e)` Logging Implementation Causes Secondary Exception

Content:

Problem Description:

When using the log_error(e) function, an incorrect logging format is causing another exception instead of logging the intended error message.

Current Implementation:

def log_error(e):
    import logging
    logger = logging.getLogger('django')
    logger.error('Error: ', e)

Issue:

The current logging implementation does not correctly format the error message with the exception e. This results in a secondary exception being raised during the logging process.

Proposed Solution:

To address this issue, the error logging string should be formatted with a placeholder (%s) to include the exception message.

def log_error(e):
    import logging
    logger = logging.getLogger('django')
    logger.error('Error: %s', e)

Retrieving information about user teams and creating groups in Django

  1. Retrieve the information about the teams of the user. This involves accessing data from the Appwrite Server and retrieving information about the teams to which the user belongs.
  2. Check if the groups with the same name already exist in Django. This step involves searching the Django database for groups with the same name as the teams retrieved from the Appwrite Server.
  3. Create the group if it does not exist. If a group with the same name as the team does not exist in the Django database, a new group should be created with that name.
  4. Assign the user to the group accordingly. Based on the information retrieved about the teams, the user should be assigned to the corresponding group in Django. This step involves linking the user's information to the group in the Django database.

Before starting the process of retrieving the information about user teams, checking if the groups with the same name exist, and assigning users to those groups, it's important to make sure that this task is necessary by checking property in the APPWRITE object in the Django settings.

Optimize User Retrieval Logic in middleware.py and authentication.py

Currently, the logic to retrieve or create a user relies on the filter method followed by first. This approach might not be as performant as using the get method directly, especially since this logic is executed frequently.

Recommendation

Consider using the get method, which is typically more efficient for retrieving single records, and handle the User.DoesNotExist exception for cases where the user is not present in the database. This will likely improve the performance of the user retrieval process.

Current Implementation

# middleware.py
# Get the Django user by its email
user = User.objects.filter(username=email).first()

# If the user doesn't exist, create it
if not user:
    User.objects.create_user(
        username=email,
        password=password,
        email=email)
# authentication.py
# Get or create a corresponding Django user
django_user = User.objects.filter(username=email).first()
if not django_user:
    User.objects.create_user(username=email, password=password, email=email)

Possible Solution

# middleware.py
try:
    # Try to get the Django user by its email
    user = User.objects.get(username=email)
except User.DoesNotExist:
    # If the user doesn't exist, create it
    User.objects.create_user(
        username=email,
        password=password,
        email=email)
# authentication.py
try:
    # Try to get the corresponding Django user
    django_user = User.objects.get(username=email)
except User.DoesNotExist:
    # If the user doesn't exist, create it
    User.objects.create_user(username=email, password=password, email=email)

The docs doesn't specify which values are required

So I have been checking the code of this plugin.
And it looks like the PROJECT_API_KEY is not begin used at all.
So you could just provide empty string and it will be still running.

So maybe it's worth to mention in the docs that this particular setting is there only for future
usecases like the groups/memberships check for permission or something?.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.