Thread: Python as SSI?

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0

    Python as SSI?


    Does anyone else wish or know of a way to use python like javascript? I mean all a browser needs to do is to be able to read or interperate the language right. Anyone know how that could be done. Basically using python as an alternative to javascript. I just find python goes so well with html and even web programming in general, it seems so effortless. Can python be used with html to create DHTML pages.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    103
    Rep Power
    11
    Originally Posted by caroundw5h
    Does anyone else wish or know of a way to use python like javascript? I mean all a browser needs to do is to be able to read or interperate the language right. Anyone know how that could be done. Basically using python as an alternative to javascript. I just find python goes so well with html and even web programming in general, it seems so effortless. Can python be used with html to create DHTML pages.
    sorry i cant be of specific help,but i do know it's possible.what you want is to search for is Jython.maybe one of These Threads will help point ya in the right direction.or i'll bet www.jython.org is a good place to start
    It is not important if the glass is half full or half empty.What is important,is who has been drinking from MY glass?!?!?
  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    On Windows with IE:
    This is broken (for me at least)...
    You must have Python installed on the client machine and also the win32all package.
    Run:
    \Python23\Lib\site-packages\win32comext\axclient\client\pyscript_regex.py

    This registers Python with IE.

    Then check out the demo at:
    C:\Python23\Lib\site-packages\win32c...nt\ie\demo.htm

    Mozilla is also supposed to support Python as a client side scripting language.
    Grim
    Last edited by Grim Archon; March 21st, 2004 at 03:57 AM.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    My two cent... were i agree with you 100% about Python being a great language for web development in general!

    As a client side langugae, DHTML with Python would be rather limiting since the number of people with Python installed isn't all that high. (for that matter perl would have the same problems).

    What you would be doing is saying "if you want to view this page properly then go get Python and win32all, install them, do some setup and you can" heheh. And even then you're only targeting Windows and IE .

    To make the idea work you would need:

    1. Python packaged with the browser. In this case why not Python applets too (like in Jython).
    2. Make your own installer for all the different browsers and etc. (prob requires some C/C++ ) Although if you just made a little installer for IE i'm sure people would start using it, if only for local stuff (for now).

    It'd be a great idea if it could work but as things are right now it really would break a website. But (yes theres always a but) if we're talking intranet and you have some controle over what people run to view the page then go for it . Could be awesum!!!

    Sorry if i'm bursting bubbles here,

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Originally Posted by netytan
    My two cent... were i agree with you 100% about Python being a great language for web development in general!

    As a client side langugae, DHTML with Python would be rather limiting since the number of people with Python installed isn't all that high. (for that matter perl would have the same problems).

    What you would be doing is saying "if you want to view this page properly then go get Python and win32all, install them, do some setup and you can" heheh. And even then you're only targeting Windows and IE .

    To make the idea work you would need:

    1. Python packaged with the browser. In this case why not Python applets too (like in Jython).
    2. Make your own installer for all the different browsers and etc. (prob requires some C/C++ ) Although if you just made a little installer for IE i'm sure people would start using it, if only for local stuff (for now).

    It'd be a great idea if it could work but as things are right now it really would break a website. But (yes theres always a but) if we're talking intranet and you have some controle over what people run to view the page then go for it . Could be awesum!!!

    Sorry if i'm bursting bubbles here,

    Mark.
    No your not bursting my bubble. In fact your encouraging me. Thank you all. I code in C as well and I would love to attempt a problem like that. I just find python so efficent it seems a waste that it isn't supported by the browsers. I"M gonna check it out some more, but thank you all for your answers.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Python + Win32All is a fully compliant ActiveScripting language so in theory can be used as a scripting language for IE, just like JScript or VBScript.

    HOWEVER there are two problems with this. This first is that it would restrict your users to those running IE and have Python & Win32All installed.

    The second and much bigger problem is that it doesn't work. It used to, but not any more.

    The reason it doesn't work is to do with security. When running in IE, Python uses the restricted execution module 'rexec' to stop anyone writing malicious code that could damage your system. However with the introduction of the new type system in 2.2 the rexec module became broken, and has been disabled in 2.3. This is probably why it did not work for Grim.

    You could delve into the COM client code and remove the rexec restrictions to enable Python in IE on your own system. This would allow you to use python for browser scripting, but only on your own computer. This could be useful if you wanted to prototype code in Python before translating it to Javascript.

    Other posters have mentioned using Jython as an alternative. I think there is some mileage in this, but the Jython code would run as an applet so I don't think it would be able to manipulate the DOM the way Javascript can. Even if it could, there is no guarantee that your users' browsers would be running a version of Java that was compatible with Jython - many browsers nowadays give the option of installing without Java.

    Sadly, I think that for the forseeable future the only viable option for browser scripting is to use Javascript. Even if say Microsoft decided to bundle Python with their next release of IE (unlikely at best) then there would still be tens of millions of browsers out there that did not support it.

    Sad, I know.

    Dave - The Developers' Coach
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    From what i know of Jython this isn't really a problem since to run a Jython applet Jython converts to Java source code which can then be compiled to a pure Java applet. That said i've never actually got a Jython applet to compile... but then i have very little interest in Java as a hole so .

    But then, as a way of running Python on a system without Python, Jython is a very nice, compact way to run Python!

    A nice little restricted execution module that i played around with a while ago:

    http://www.procoders.net/pythonstuff/SandBox/

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo