Libraries

These libraries have been developed as part of SVNPlace.

attrdict

Deep convert a dictionary into objects with attributes.

Unlike AttrDict, this is a conversion, instead of live.

safeeval

Evaluate a python expression safely. Safely here means:

  • avoid access beyond what has been supplied
  • avoid DOS by time limiting enumerations
  • avoid DOS by size-limiting multiplied structures

safesubst

Take a string and substtute f-string-like sections using safeeval.

deep_update

Deeply merge a dictionary into another deep structure which may include lists.

a = {
    'one': 'hello',
    'two': [
        1,
        {
            'three': 'sunny',
        },
        'bother',
    ],
    'four': 'houses',
}

b = {
    'two':{
        1: {
            'three': 'rainy',
        }
    }
}

c = deep_updated(a, b) gives...

c = {
    'one': 'hello',
    'two': [
        1,
        {
            'three': 'rainy',
        },
        'bother',
    ],
    'four': 'houses',
}

deepsafesubts

Deeply safesubst a dictionary.

proxy

Mimic another object to allow additions without affecting the original, but changes to the original to affect the original. The mimicing is good enough, for example, for Djando's db.models.model to be fooled.

buildfromdict

Build objects from a dict, allowing more flexibility in object preparation than only __init__ kwargs.

api and api_api

Add your api to a Django website. These were the goals:

  • simple to set up
  • simple to add site API calls
  • security model similar to AWS
  • simple to use from the client side
  • support for multiple languages for the client
  • simple to use from the site's web pages
  • docstring-based method documentation

additional, unplanned benefits:

  • improved site testability
  • improved interactivity of site web page

api

This is the site-side library. Add this as an application to your Django website, tie in the automatically generated views, create your api methods, and you're good to go.

Follow up by adding a UI for your users to manage their policies, roles and keys and your site's API acquires the sophistication of AWS.

api_api

This is the client-side library. It can be used for your site as is, or wrapped to create a custom API.