RE: Class Dependancy Injection



Thanks Steve that's good to here. I'll give it a shot this evening and if I
have any problems then 'I'll be back';-)

Rawlins

-----Original Message-----
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk@xxxxxxxxxx
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk@xxxxxxxxxx]
On Behalf Of Steve Holden
Sent: 13 April 2007 17:32
To: python-list@xxxxxxxxxx
Subject: Re: Class Dependancy Injection

Robert Rawlins - Think Blue wrote:
Hey again guys,



I'm looking to get an answer about dependency injection in python
classes, what is the best way to deal with this?



For instance, in my application I have a configuration bean which
contains all the applications configuration information. Now in one of
other classes I need access to those configuration settings. What I
would have done in my ColdFusion/JAVA type applications is create an
instance of the configuration bean, and then pass that in as an argument
to the constructor for my other class, then have the other class set
that as a 'self' variable. Then from within my class I can access the
configuration details like self.config.getName() and it would return the
name of the application.

How is this best handled in python, can I still inject dependencies as a
constructor argument like that? If so then is there anything in
particular I need to watch out for that may cause me trouble?

That indeed sounds like the best way to proceed. You should find that,
modulo the language differences, the technique works in just the same
way. You shouldn't anticipate trouble.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com

--
http://mail.python.org/mailman/listinfo/python-list

.



Relevant Pages

  • Re: Missing Mouse - still..
    ... I was hoping to use "last known good configuration" but can't select ... Thanks Rob and Steve for the help but unfortunately, for me anyway, things aren't too much better. ... however I am not overly sure as regarding the IRQ settings. ... checked that the correct drivers are present in the troublesome computer, ...
    (microsoft.public.win2000.general)
  • Re: OT - Outlook Express help please
    ... Steve J writes ... The big problem is that the 1 that's not working is my primary address - identically configured to all my other addresses at that domain and sending from the same client with the same configuration. ... The only response from BT's helpdesk so far has been to point me at a Microsoft page explaining what a 553 error is, despite me explaining the problem in detail and including headers from ... e-mail news dot will at lancre dot net ...
    (uk.sci.weather)
  • Re: Windows XP
    ... Steve wrote: ... > software change may have caused this. ... > choose the most recent good configuration by pressing ...
    (microsoft.public.security.virus)
  • RE: Office 2007 Enterprise Installation
    ... Suggest you do a search on 'Configuration' in the Office/Setup group of this ... "Steve S" wrote: ... where they look like they are installing and configuring themselves. ... I would like to open the Office applications and send an email/check for ...
    (microsoft.public.office.misc)
  • Re: Class Dependancy Injection
    ... I’m looking to get an answer about dependency injection in python classes, what is the best way to deal with this? ... in my application I have a configuration bean which contains all the applications configuration information. ... You shouldn't anticipate trouble. ...
    (comp.lang.python)