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.2.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.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simplify_service_layer_base-0.4.2.tar.gz
Algorithm Hash digest
SHA256 a2507b58987adc1573c8b34fc0e44ace675efb8ed6cb812167ce36f6affa8c66
MD5 b4b1dbdfa3523268c6c9fdb3a15b8c4c
BLAKE2b-256 f835e54a6a2bc670a61b7dc987d450299ab2f70b69b8f8c42a73a44be7711e76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simplify_service_layer_base-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 723c5c450d85a8ae264a0e9f19dbfe782e16a655073f9f7e617d286dae506aca
MD5 4f85326860fa5bbc283157dfa5afba10
BLAKE2b-256 9a527547f463ee477fd2e05c069179fef6fccf0b3e9e72582a263b6707ec4657

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