[Tutor] Running two different python applications from one module

Norman Khine norman at khine.net
Sat Jun 2 17:17:09 CEST 2007


Thank you for your reply.

I have just found your book, it looks very good and I will look at sub
processes examples.

What I am trying to do is that I want to create a python module within
itools http://www.ikaaro.org/itools CMS that creates an object based on
a form input that has a post method in the zope application.

I can do this using this method, but I was wondering if I can by-pass
this and execute it from within the itools module.

The zope application basically creates trial shops, from BizarSoftware
as per this scrip

http://www.bizarsoftware.com.au/resource_centre/create_trial_shop.py

I want to replace the <form action="create_trial_shop" method="post"> to
be executed from within the python2.5


I have something like:

    def create(self, user):
        root = self.get_root()
        users = root.get_handler('users')

        firstname = user.get_property('ikaaro:firstname')
        lastname = user.get_property('ikaaro:lastname')
        email = user.get_property('ikaaro:email')

        # Create the user
        if user is None:
            email = context.get_form_value('ikaaro:email')
            firstname = context.get_form_value('ikaaro:firstname')
            lastname = context.get_form_value('ikaaro:lastname')
            users = root.get_handler('users')
            user = users.set_user(email)
            user.set_property('ikaaro:firstname', firstname)
            user.set_property('ikaaro:lastname', lastname)
            key = generate_password(30)
            user.set_property('ikaaro:user_must_confirm', key)
        user_id = user.name

....

once the user has come to this point, I would like to push the
firstname, lastname and email to the
http://www.bizarsoftware.com.au/resource_centre/create_trial_shop.py
script which runs on python2.4 and I am not sure how to deal with it
within my create class.

Cheers

Norman


Alan Gauld wrote:
> "Norman Khine" <norman at khine.net> wrote
> 
>> I would like to write a script using python 2.5 to interact with a 
>> Zope
>> application that is running on python 2.4.3
>>
>> Can I call the python 2.4.3 module from within the python 2.5, if so 
>> how?
> 
> You can generally import modules from older versions into
> newer versions if the module is implemented in pure Python.
> Where it gets messier is if the module is built in C. There
> you generally need a library compiled for your version.
> 
>> For example, my script is in /home/me/python2.4/create.py
>> and within my /home/me/python2.5/servers.py
>>
>> When running server.py I would like to run the create.py and then
>> continue with my application in the python2.5
> 
> Your use of the term 'run' is confusing. What exactly do you mean?
> You could:
> 1) use os.system to execute it as a separate process in a separate 
> shell
> 2) use execfile to run it as a separate process (in the same shell?)
> 3) use import to load it into your program and execute its functuions
>     within your process. In this case you need your sys.path to
>     include the python  2.4 folder
> 
> And other options on top of that. What do you actually want to do?
> 
>> Can someone show me an example from the interpreter or as a module 
>> that
>> does this.
> 
> You can see examples of running subproceses in the OS topic of my 
> tutorial.
> 
> HTH,
> 





More information about the Tutor mailing list