Registering Services Best Practices

54 views
Skip to first unread message

Vincent Catalano

unread,
Aug 29, 2015, 5:27:00 PM8/29/15
to pylons-...@googlegroups.com
I'm trying to figure out the best way to register a large number services for my Pyramid app. I'm using the Pyramid Services library (https://github.com/mmerickel/pyramid_services) and I'm registering all my services within my app's main function. The problem that I'm starting to realize is that all this services initialization code in my main function is getting unwieldy. At this point, I'm trying to figure out a better way to register services that's a bit more modular.

Ideally, I would like my app to automatically register services when the given package is included in my app, however, I'm not sure on the best way to do this. One thought I had was to use the ApplicationCreated event and register the services based on this callback, but this just doesn't seem right (plus I'm not sure Pyramid Services can register service *after* the app has been initialized).

Thanks for any direction you can offer.

-Vincent

--
Vincent Catalano
Software Engineer and Web Developer,
(520).603.8944

Bert JW Regeer

unread,
Aug 31, 2015, 11:46:52 AM8/31/15
to pylons-...@googlegroups.com
You can create separate packages and call config.include(‘.some.service’) for example, and it will call the includeme() function inside your .some.service package.
> --
> 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 pylons-discus...@googlegroups.com.
> To post to this group, send email to pylons-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.

Jonathan Vanasco

unread,
Aug 31, 2015, 2:10:09 PM8/31/15
to pylons-discuss
Is your concern code maintenance or performance?

Bert's suggestion would be cleaner -- and I believe you could even just drop things in your `.ini` -- but it will still execute during the main setup.

Vincent Catalano

unread,
Aug 31, 2015, 3:25:11 PM8/31/15
to pylons-...@googlegroups.com
My primary concern is code maintenance. Bert's suggestion looks like it will solve my problem perfectly.

On Mon, Aug 31, 2015 at 11:10 AM, Jonathan Vanasco <jona...@findmeon.com> wrote:
Is your concern code maintenance or performance?

Bert's suggestion would be cleaner -- and I believe you could even just drop things in your `.ini` -- but it will still execute during the main setup.

--
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 pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages