[Twisted-Python] confused on combining different py moduels to make a twisted app

Andy Fundinger Andy at NewWorldElectric.com
Sun Jan 25 07:52:37 MST 2009


That's a somewhat general question, but consider this as a solution,
in __init__.py for that package imports one or more classes from each
of the other modules.  Then, within init.py create a root object (a
resource if you're using http) and let it instantiate each of the
classes as sub-objects (children if you're using http).  That would
let you access all the functions and continue exploring, though it's
not a good design in general.

It's hard to be more specific without knowing what sort of design
you'd like to wind up with.  This is one of those questions where the
honest answer is "however you want to do it."  You may want to study
some of the examples to see the kinds of design typically used in
twisted applications and adopt one of those until you get more
comfortable.

Andy Fundinger

On Mon, Jan 19, 2009 at 5:46 AM, Krishnakant <hackingkk at gmail.com> wrote:
> hello hackers,
> I am a new comer to twisted and find it very interesting.
> By the way I got my previous problem solved regarding returning lists.
>
> Now I have another confusion.
>
> I have a lot of modules (.py) which I wish to combine and create a
> server application in twisted.
> for example I have organisation.py which gets and sets organisation
> related data in the application.
>
> there is a vendor.py for getting and setting vendor related data and
> such other modules related to inventory.
> Now, I understand that we can publish one object at a time and listen to
> the incoming requests on the given port with the reactor running.
> But I want to use these other modules together with the main module.
> How can i create a package for such a situation?
>
> I have the __init__.py file in the folder to make a python package,
> What I can't understand is how can I register all the classes in the
> different files to listen for function calls from the client?
> I am confused on managing the entry point so to say.
> happy hacking.
> Krishnakant.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>



-- 
Blog:  http://channel3b.wordpress.com
Second Life Name:  Ciemaar Flintoff

How could you possibly think typing 'import skynet' was a good idea?
http://xkcd.com/521/




More information about the Twisted-Python mailing list