Skip to main content

simplify service layer for python

Project description

Simplify Service Layer

helper for declarative backend service layer.

UseCase Example

class UserService extends Service {

    def __init__(self, UserRepository user_repository):
        self.user_repository = user_repository

    """
    names declaration be used in validation error message
    """
    @staticmethod
    def getNames():
        return {
            # basic example
            'token' => 'authorized token',
            # dictionary type data key must have '[...]' for subkey naming
            'auth_user' => 'authorized user[...]',
            # nested bound name with '{{keyName}}'
            'user_profile' => 'profile[...] for {{auth_user}}',
        }

    """
    callbacks declaration be run after validation check is passed
    """
    @staticmethod
    def getCallbacks():
        # called after `auth_user` validation check is passed
        def auth_user__session(auth_user):
            # session
            Session.setData('auth_user', auth_user)

        # called after `auth_user` validation check is passed
        def auth_user__logging(auth_user):
            # logging
            Log.write('user id:'+auth_user.getId()+' logged in')

    """
    loaders declaration be used for loading data
    """
    @staticmethod
    def getLoaders():
        # injected `user_repository` value take from instance properties
        # injected `jwe` value take from loaded data
        def auth_user(jwe, user_repository):
          return user_repository.findById(jwe.sid)

        # injected `token` value take from init input token parameter
        def jwe(token):
          return new JWE(token)

        # result key must be exists
        # result key is output value of service.run
        def result(auth_user):
          return auth_user

    """
    rule lists declaration be used for validation check
    """
    @staticmethod
    def getRuleLists():
        return {
          # ...
        }
}

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

simplify_service_layer_base-0.4.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

simplify_service_layer_base-0.4.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file simplify_service_layer_base-0.4.3.tar.gz.

File metadata

  • Download URL: simplify_service_layer_base-0.4.3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for simplify_service_layer_base-0.4.3.tar.gz
Algorithm Hash digest
SHA256 1d15101e25c63115576cce585be0c07dc8b815b179daa1f44656bfcc881f055e
MD5 05eb356fdb07a4efe3da0f8070f59b27
BLAKE2b-256 871b8026fefc515fc7d1d6f5ebb00fb5fd3b61ab059cfab19a90a7501dd6f31d

See more details on using hashes here.

File details

Details for the file simplify_service_layer_base-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for simplify_service_layer_base-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b470f559519167164d4b47735a71b3dbfcf7d02949f932de128fdffea4f96b32
MD5 ec6f2f82b5396c3f9618a251c94e0049
BLAKE2b-256 59d23aea34adbd720708886a084250a3ce339ecf302072bcfdb9e350652f4b81

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