Skip to main content

A Django app to call server functions directly from the client.

Project description

forthright-django

forthright-django is a Django app to allow developers to directly call server functions from the client.

Quick start

  1. pip install forthright-django

  2. Add forthright-django to INSTALLED_APPS in your django project settings.py:

    INSTALLED_APPS = [
        ...,
        'forthright_django',
    ]
    
  3. Include the forthright-django URLconf in your django project urls.py:

    urlpatterns = [
        path('forthright/', include('forthright_django.urls')),
        ...,
    ]
    
  4. Instantiate a forthright_server object and export your server functions. For example, place examples/server_functions.py in your django project folder, and import this file in urls.py

    from . import server_functions

  5. Now you can instantiate a forthright_client object on the client and directly call the server functions that you exported. For example, examples/client.py

All together, here's an example django project:

example_django_project

And corresponding client:

example_client

Limitations

You can only pass arguments by value, not by reference. For example, if an argument is a list, the server function will receive a copy of that list.

If an argument is a custom object, the class definition must be present in both the client code and the server code.

Warning: By default, this code deserializes pickled data on the server which is unsafe. There is an optional Safe Mode to instead send data with json, but this will prevent you from sending custom objects. To turn on Safe Mode, set safe_mode=True when instantiating both forthright_server and forthright_client:

frs = forthright_server(safe_mode=True)

frc = forthright_client(url, safe_mode=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forthright_django-0.0.6.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forthright_django-0.0.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file forthright_django-0.0.6.tar.gz.

File metadata

  • Download URL: forthright_django-0.0.6.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.1

File hashes

Hashes for forthright_django-0.0.6.tar.gz
Algorithm Hash digest
SHA256 57fc8f43e6669827b75b4b625a449a447af8b0247de8bfdad21b1b87fc7ced21
MD5 33fcccd8fd60af58effb1c94bfdfc45f
BLAKE2b-256 a6bc29eb85b8cc4937cbb5a0f269e0de929984e20bb9ccfe2b7f9e016330bcd6

See more details on using hashes here.

File details

Details for the file forthright_django-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for forthright_django-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2cb2a7ef6ba7eabb77aba25d38e4c6dcd2b1795a617cc98858ca0ca7bbc1377e
MD5 e133a57163ef122368343b2c81b03f2c
BLAKE2b-256 ec734f1cae0098b7af68fc78f70edd1e55ed086de0d7491f1c67a98ab78eb67e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page