[Python-au] Re: python-au Digest, Vol 5, Issue 10

Jimmy jbou5922 at bigpond.net.au
Mon Dec 1 12:47:18 CET 2003


Cheers mate - I've just caught up with some stuff about integrating with COM
which backs up what you said. Unfortunately I ran out of time to come back
with a viable development plan on this project. But it looks like it might
get going in a few months. I'll give you a bell if we need someone.

Jim
----- Original Message ----- 
From: <python-au-request at python.net>
To: <python-au at python.net>
Sent: Sunday, November 30, 2003 10:00 PM
Subject: python-au Digest, Vol 5, Issue 10


> Send python-au mailing list submissions to
> python-au at starship.python.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://starship.python.net/mailman/listinfo/python-au
> or, via email, send a message with subject or body 'help' to
> python-au-request at starship.python.net
>
> You can reach the person managing the list at
> python-au-owner at starship.python.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-au digest..."
>
>
> Today's Topics:
>
>    1. Re: Calling two Python Scripts from another script PartII
>       (Duane Hennessy)
>    2. Re: python-au Digest, Vol 5, Issue 9 (Duane Hennessy)
>    3. Re: Request for advice (Paul Sorenson)
>    4. Re: Request for advice (Richard Jones)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 29 Nov 2003 22:05:56 +1000
> From: Duane Hennessy <duaneh at connexus.net.au>
> Subject: [Python-au] Re: Calling two Python Scripts from another
> script PartII
> To: python-au at python.net
> Message-ID: <3FC88BA4.80201 at connexus.net.au>
> Content-Type: text/plain; charset="us-ascii"
>
> An HTML attachment was scrubbed...
> URL:
http://starship.python.net/pipermail/python-au/attachments/20031129/6300c1f3/attachment.html
>
> ------------------------------
>
> Message: 2
> Date: Sat, 29 Nov 2003 22:51:15 +1000
> From: Duane Hennessy <duaneh at connexus.net.au>
> Subject: [Python-au] Re: python-au Digest, Vol 5, Issue 9
> To: python-au at python.net
> Message-ID: <3FC89643.6080008 at connexus.net.au>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> James,
>     I developed a python program to run through a web browser (actually
> IE 5.5) so what I did was create a Python COM which provided functions
> to the web page using VBScript to access the COM. Basically I had a
> python program set up in the background which ran on its own fine but
> created a Python COM interface to receive data via VBScript in the page
> and send back results as HTML code or delimited strings which I then
> broke down using Javascript (you could use VBScript but I prefer
> Javascript for web pages). Some quick example code would be like the
> following.
>
> ######## web page code starts here ########
> <script language = 'VBScript'>
>     'Create the object for the page to use
>     Dim Warehouse
>     Set Warehouse = CreateObject("Warehouse.Application") ' Python COM
> set up
>
>     Sub ShowItems()
>         'Show chosen items. I just wrote in trousers but you would
> capture this via a web page control etc.
>         window.innerHTML = Warehouse.show_items("trousers")
>     End Sub
>
>     Sub SaveItems(Item, SizeOne, SizeTwo)
>         'Save an item and it's sizes etc. Example of sending data to a
> COM to use.
>         Warehouse.save_sizes(Item,SizeOne,SizeTwo)
>     End Sub
>
> </script>
>
> ######## web page code ends here ########
>
>
> ######## python COM code starts here ########
> class Inventory:
>     'Class registered as a COM for translating requests and returns to a
> web page'
>     _public_methods_ = ['show_items','save_sizes']    # list of methods
> you want to make available to programs using the COM.
>     _reg_progid_ = 'Warehouse.Application'        # the COM id which we
> load in the web page
>     _reg_clsid_ = '{1562C973-CBEB-469D-9A96-54C6CF44490B}'  # use
> pythoncom.CreateGuid() to get the class id.
>
>     def  show_items(self,w_item):
>         # note if you pass data via a web page it will be in Unicode
> format and causes Python to cause errors so I convert the passed arguments
>         # before doing anything further with them. If you are not
> passing arguments though you don't need this obviously.
>         w_item = str(w_item);
>
>         # set up a variable to return the HTML code to return to the web
> page
>         html_return = '<table id = \'return_items\'>'
>
>         # use a method to capture whatever data you want to return and
> write it into a web code format eg, table.
>         # code to get items here... eg maybe you are dragging the item
> from a database etc.
>         for item_name in item_list:
>             html_return += '<tr>
>             html_return += '<td>%s</td>' % item_name
>             html_return += '</tr>'
>
>         # return the result to the web page
>         html_return += '</table>'
>         return html_return
>
>     def save_sizes(item,size_one,size_two):
>         # note if you pass data via a web page it will be in Unicode
> format and causes Python to cause errors so I convert the passed arguments
>         # before doing anything further with them.
>         item = str(item)
>         size_one = int(size_one)
>         size_two = int(size_two)
>
>         # code to save the item sizes here, could be a database or
> anything, you get it though.
>
> if __name__ == '__main__':
>     print 'Registering COM server'
>     import win32com.server.register
>     win32com.server.register.UseCommandLine(Inventory) # note the
> command line is the name of the class
>
> ######## python COM code ends here ########
>
> Basically that is it. Things to note are,  the web page will pass any
> arguments you pass to the Python COM in unicode format and I recommend
> that you convert them as a first step in the method should you have any
> errors during the Python code. Can't remember the error I received and I
> didn't receive it for all methods in which I passed strings, integers to
> a Python method via the COM only a few. Check it out anyway.
>     Basically any changes you make to the rest of the programs modules
> are automatically reflected via the COM, only changes to the COM
> interface need to be re-registered if they include new methods you want
> made available to the Web page, other changes are reflected
> automatically, like changes in algorithm etc.
>
> Hope this helps, let me know if you have any problems implementing this
> into the web page and I'll see what I can do. It wasn't plain sailing
> when I first attempted this but works like a dream now.
>
> Duane Hennessy
> Tropical Queensland, Australia
>
>
> >Message: 2
> >Date: Fri, 21 Nov 2003 15:37:58 +1100
> >From: "Jimmy" <jbou5922 at bigpond.net.au>
> >Subject: [Python-au] Request for advice
> >To: <python-au at python.net>
> >Message-ID: <017001c3afe9$3d4579f0$0100000a at JIMSMACHINE>
> >Content-Type: text/plain; charset="iso-8859-1"
> >
> >Hi,
> >
> >I'm currently developing a prototype in Python, that has the potential to
> >make the transition to being part of a long term commercial development.
The
> >prototype basically performs all of the business logic thats required,
but
> >simply takes interactively typed or text file based input and simply
prints
> >the required data. What's required is simply to plug the input and output
> >information into some sort of form, preferably browser based. Can anyone
> >point me to any documentation that outlines the techniques for connecting
> >python classes and routines to web-based forms. This software will
initially
> >run standalone, so embedding this code in a Zope style framework is
probably
> >going to be an overkill. This is a pretty time critical development, so
I'd
> >prefer an approach that's as simple and easy as possible.
> >
> >Any advice on this, or knowledge of suitable products that make this
process
> >easy would be greatly appreciated. I'd like to introduce python as an
> >integral part of the development process for this concern, rather than
them
> >surrendering all to Microsoft.
> >
> >Thanks
> >James Bourke
> >
> >
> >
> >
> >
> >
> >------------------------------
> >
> >Message: 3
> >Date: Sat, 29 Nov 2003 20:06:51 +1100
> >From: JOHN KIRK <softscan at dodo.com.au>
> >Subject: [Python-au] Newcastle Work Offered
> >To: python-au at python.net
> >Message-ID: <3FC861AB.8000909 at dodo.com.au>
> >Content-Type: text/plain; charset=us-ascii; format=flowed
> >
> >Hi,
> >I am based in Newcastle N.S.W. and need someone to teach me Python and
> >oversee some game development  I am doing.
> >Anyone out there interested ?
> >John
> >
> >
> >
> >
> >
> >
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 30 Nov 2003 09:41:32 +1100
> From: "Paul Sorenson" <sourceforge at metrak.com>
> Subject: Re: [Python-au] Request for advice
> To: <python-au at python.net>
> Message-ID: <003d01c3b6c9$efc458d0$c48b0fcb at home.classware.com.au>
> Content-Type: text/plain; charset="iso-8859-1"
>
> ----- Original Message -----
> From: "Jimmy" <jbou5922 at bigpond.net.au>
> To: <python-au at python.net>
> Sent: Friday, November 21, 2003 3:37 PM
> Subject: [Python-au] Request for advice
>
>
> > I'm currently developing a prototype in Python, that has the potential
to
> > make the transition to being part of a long term commercial development.
> The
> > prototype basically performs all of the business logic thats required,
but
> > simply takes interactively typed or text file based input and simply
> prints
> > the required data. What's required is simply to plug the input and
output
> > information into some sort of form, preferably browser based. Can anyone
> > point me to any documentation that outlines the techniques for
connecting
> > python classes and routines to web-based forms. This software will
> initially
> > run standalone, so embedding this code in a Zope style framework is
> probably
> > going to be an overkill. This is a pretty time critical development, so
> I'd
> > prefer an approach that's as simple and easy as possible.
>
> You need something that handles CGI.  There are dozens of "frameworks" for
> python code, at least one has already been recommended.  They each have
> their pros and cons.
>
> After using one or two of these systems, I have come full circle and just
> write the CGI code directly in python.  You will find examples in the
> standard module: 'cgi' and I think cookie is a standard module if you want
> to keep state information from one page/session to the next.  If you would
> like to edit your pages with an html editor then this could cause some
> grief.  Some of the frameworks will be easier in this regard.  If you just
> use vi or some text editor then it is hard to beat.
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 30 Nov 2003 11:43:41 +1100
> From: Richard Jones <richardjones at optushome.com.au>
> Subject: Re: [Python-au] Request for advice
> To: "Paul Sorenson" <sourceforge at metrak.com>, <python-au at python.net>
> Message-ID: <200311301143.47702.richardjones at optushome.com.au>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Sun, 30 Nov 2003 09:41 am, Paul Sorenson wrote:
> > You need something that handles CGI.  There are dozens of "frameworks"
for
> > python code, at least one has already been recommended.  They each have
> > their pros and cons.
>
> These are listed on the python website as a topic guide, via:
>
>    http://python.org/topics/
>
> at:
>
>    http://www.python.org/cgi-bin/moinmoin/WebProgramming
>
>
>       Richard
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: not available
> Type: application/pgp-signature
> Size: 189 bytes
> Desc: signature
> Url :
http://starship.python.net/pipermail/python-au/attachments/20031130/9fa57349/attachment.pgp
>
> ------------------------------
>
> _______________________________________________
> python-au maillist  -  python-au at starship.python.net
> http://starship.python.net/mailman/listinfo/python-au
>
>
> End of python-au Digest, Vol 5, Issue 10
> ****************************************
>





More information about the python-au mailing list