Jaime, for DI please look at pyramid_services. It is actually more service
locator but if you squint it is basically DI when you avoid passing the
request between services. It is the closest to DI that I have seen for
Pyramid without actually munging the view arguments.

https://pypi.python.org/pypi/pyramid_services

On Sat, Mar 25, 2017 at 5:56 PM, Jaime Sangcap <[email protected]> wrote:

> Hi Steve,
>
> Thank you for the reference, looks great to help me go along. Sorry if I
> didn't make myself clear enough on my post.
>
> Regarding the dependency injection/service container, what I mean is that
> when a view callable depends on a service to fulfill its job, in PHP I
> usually inject it dependencies in constructor
>
> public function __construct($taskRepository, $orgChart)
> {
>     $this->taskRepository = $taskRepository;
>     $this->orgChart = $orgChart;
> }
>
> the arguments will be resolved by the service container via configuration.
>
> in pyramid I'm thinking if its possible to do the same way like
>
> def my_view(request, taskRepository, orgChart):
>     task = taskRepository.findByid(request.params["taskId"])
>     // do more work
>     return task
>
> notice that the taskRepository and orgChart are injected as arguments, not
> sure if its possible or something related to ZCML?
>
> The common thing I see is that you will add it in the registry so you can
> use it inside the view method body like
>
> request.taskRepository.findById. But Im not sure if its easily testable.
>
>
> On Sunday, March 26, 2017 at 2:17:49 AM UTC+4, Steve Piercy wrote:
>>
>> Hi Jaime,
>>
>> Welcome to Pyramid!  You'll find that the community is helpful.
>>
>> As with all projects under the Pylons Project, requesting
>> support follows our guidelines.  Pyramid has some specific
>> community guidelines and resources:
>> https://trypyramid.com/community.html
>> https://trypyramid.com/resources.html
>>
>> TDD/BDD/DDD is outside Pyramid's and the Pylons Project's
>> realms, although there exist implementations of such practices
>> within Python that may be useful.  Sorry, I don't have specific examples.
>>
>> I'm not really clear what you mean by Dependency Injection /
>> Service Container.  Do you mean a package manager / using
>> virtual environments?
>>
>> For server setup, we have a relevant section in the Pyramid
>> Community Cookbook.
>> http://docs.pylonsproject.org/projects/pyramid_cookbook/en/l
>> atest/deployment/index.html
>>
>> If you have specific questions, we can direct you to appropriate
>> resources or help you understand things that are different
>> between Python and PHP.  Sometimes it helps if you say, "I used
>> X in PHP, which helped me do A, B, and C.  Is there something
>> similar in Python?"
>>
>> --steve
>>
>>
>>
>> On 3/25/17 at 2:39 PM, [email protected] (Jaime Sangcap) pronounced:
>>
>> >Permission to Post.
>> >
>> >Hi all! Coming from a PHP background, I'm just starting out
>> >with python and very eager to learn pyramid as it seems a
>> >pretty solid framework.
>> >
>> >I'm wondering if someone is interested in mentoring/coaching
>> >maybe to build an app to demo how to customize pyramid and
>> >explain further. The documentation is actually great but
>> >sometimes I run into some points where I need to know how to
>> >translate what I'm doing from PHP into pythonic way, dependency
>> >injection for example.
>> >
>> >I know you guys are really busy doing amazing things so I don't
>> >expect it to be free, but not too expensive neither :)
>> >Of course free offers are welcome maybe I can contribute back
>> >on your project later on :)
>> >
>> >My subject of interest if possible are
>> >- TDD/BDD/DDD
>> >- Dependency Injection / Service Container
>> >- Basic Server setup (like nginx to reverse proxy python?)
>> >
>>
>> ------------------------
>> Steve Piercy, Soquel, CA
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/pylons-discuss/145b0c08-6843-49f6-80c7-d65afe7320cc%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/145b0c08-6843-49f6-80c7-d65afe7320cc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAKdhhwFyo7eFs3mSh-YX%2BztM%3DrxSw6DVj%3Dme-qMpr5%3DO6U6X%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to