Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blueprint #100

Open
cheungpat opened this issue Nov 23, 2016 · 0 comments
Open

Blueprint #100

cheungpat opened this issue Nov 23, 2016 · 0 comments

Comments

@cheungpat
Copy link
Contributor

Using decorator like this is not python-y IMHO:

def register_message_hooks(settings):
    @skygear.before_save("message", async=False)
    def message_before_save_handler(record, original_record, conn):
        return handle_message_before_save(record, original_record, conn)

This makes all functions indent by one level, and this is required because we do not want a registration side effect when defining cloud functions.

The solution is IMHO blueprint like flask. Decorator registers cloud functions to a blueprint, and all cloud functions in a blueprint are registered to the registry. Like this:

blueprint = skygear.create_blueprint('blueprint_name')
@blueprint.before_save("message", async=False)
def message_before_save_handler(record, original_record, conn):
    return handle_message_before_save(record, original_record, conn)

def includeme(settings):
    skygear.register_blueprint(blueprint)  # or skygear.register_blueprint('blueprint_name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants