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.4.tar.gz (8.4 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.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplify_service_layer_base-0.4.4.tar.gz
  • Upload date:
  • Size: 8.4 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.4.tar.gz
Algorithm Hash digest
SHA256 77e0c4a4d54e5c552cb89af411b39bbb75759e9b2c23c58473633dac7024666f
MD5 4d639f2bbbe37d631515d9b97db81b38
BLAKE2b-256 a948980ff250b302e338a7cf6211d4a1df803e5fef4a9813aa31780120cac1fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simplify_service_layer_base-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0797a6d23bd5895575f1d156cebbf458a95b545b721f106a95d06c640afc5dc0
MD5 19a5e9b6fbb0984075c7c18bcfe5b477
BLAKE2b-256 e56db9d7712d4d7d59d8c992e50e2b778be50136d72ab3e72a7d4fb456b6a7cd

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