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 -i https://test.pypi.org/simple/ 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.5.tar.gz (6.8 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.5-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: forthright_django-0.0.5.tar.gz
  • Upload date:
  • Size: 6.8 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.5.tar.gz
Algorithm Hash digest
SHA256 673b0f137551c06d33dccebfba2a9ed870eb2270b2a250bb17ca1a872b76aa7d
MD5 2c83b97eeaaf05528245f7b8936a6de6
BLAKE2b-256 945a6d18e9e0a02f703f72e32c101af2282eb262bc624890513de6ed739ed7d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for forthright_django-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5515535f40a8f845ec1da1c8ed0fce0cb4b26084a623e2a9fc8ab958287b7fab
MD5 2e1f7447abd36753148108a8b4cad9a0
BLAKE2b-256 4ade3c5faee60b660373d5604e79546a8d7ccc94d6306e365ab1ca294032d772

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