-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use decorators to set a service definition #33
Comments
shiroyuki
added a commit
that referenced
this issue
Nov 15, 2018
shiroyuki
added a commit
that referenced
this issue
Nov 15, 2018
… Dorian Pula and a few people I discussed with at PyCon Canada 2018 Sprint Session for critical feedback.
In the 3.0.0-dev.1 release, the code will look like this. from imagination import service
from imagination.decorator.config import (default_id_by_fully_qualify_class_name,
default_id_by_shorten_fully_qualify_class_name,
default_id_by_qualify_class_name,
default_id_by_class_name,
Parameter as PrimitiveParameter,
Service as ServiceParameter)
@service.registered(
params=[
PrimitiveParameter('Panda', 'name'),
ServiceParameter(SimpleSampleService, 'simple_sample', default_id_by_class_name),
],
default_service_id_generator=default_id_by_class_name
)
class Foo:
# ... However, the end goal should be something like: @generate_service_id(by_class_name)
@inject(SimpleSampleService, 'simple_sample')
@define(name='Panda')
@service.registered
class Foo:
simple_sample:SimpleSampleService
# ... |
The commit c3b994c should resolve the basic requirement for this issue. Until there is a proper documentation, please check out https://github.com/shiroyuki/Imagination/blob/master/test/v3/test_imagination_decorator_config.py for sample usage. |
Service scanning is required for this task. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While XML is a powerful ML, not many people like working with XML. So, there are a few feedbacks on how writing service definition can be improved.
Instead of using XML, we borrow the idea of component scanning from Spring Beans by allowing developers to define the definitions in Python (beside #21).
This is borrowed the idea from Flask and the presumably discontinued Spring-Python.
The text was updated successfully, but these errors were encountered: