need advice on building core code for python and PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • digimotif

    #1

    need advice on building core code for python and PHP

    All,
    I'm currently working with a small development company on a PHP
    application they already have. There are several processing tasks
    that could be scripted in Python and run in the background to modify a
    database, instead of the way they have it now, which waits for a
    webpage to return from processing.

    There is also the possibility of building client gui applications that
    work with the database as well, so I'm looking for a way I could
    create a code base that enables us to use the same functions and
    objects over and over again while building interfaces in Python, or
    PHP, or whatever.

    Is there a way I could code the base (core) code in Python and have
    PHP call it? I've really liked using SQLAlchemy and there are other
    great things like Pylons I could integrate for various tasks, but I
    first have to move some functionality out of PHP and into something
    more "universal" . What would you recommend?

    Any ideas are appreciated.

    Brian

  • Szabolcs Nagy

    #2
    Re: need advice on building core code for python and PHP

    Is there a way I could code the base (core) code in Python and have
    PHP call it? I've really liked using SQLAlchemy and there are other
    * quick and dirty solution:
    in a shell:
    $ python yourscript.py <pipe_in >pipe_out
    in the php script:
    fwrite(pipe_in, input_data);
    results = fread(pipe_out, sizeof_results) ;

    * simple and nice solution:
    do not ever use php

    Comment

    • Cameron Laird

      #3
      Re: need advice on building core code for python and PHP

      In article <1180025115.704 410.250890@a35g 2000prd.googleg roups.com>,
      digimotif <digimotif@gmai l.comwrote:
      >All,
      >I'm currently working with a small development company on a PHP
      >application they already have. There are several processing tasks
      >that could be scripted in Python and run in the background to modify a
      >database, instead of the way they have it now, which waits for a
      >webpage to return from processing.
      >
      >There is also the possibility of building client gui applications that
      >work with the database as well, so I'm looking for a way I could
      >create a code base that enables us to use the same functions and
      >objects over and over again while building interfaces in Python, or
      >PHP, or whatever.
      >
      >Is there a way I could code the base (core) code in Python and have
      >PHP call it? I've really liked using SQLAlchemy and there are other
      >great things like Pylons I could integrate for various tasks, but I
      >first have to move some functionality out of PHP and into something
      >more "universal" . What would you recommend?

      Comment

      • digimotif

        #4
        Re: need advice on building core code for python and PHP

        >
        * simple and nice solution:
        do not ever use php
        I'd like not to use it at all, but there's already been quite a bit of
        work done with it and I'm sure I won't be able to have it all removed
        at one time. I REALLY don't like debugging PHP especially after all
        the stuff I've done with Python. I find it much easier to test Python
        code as I go and I end up with fewer bugs to fix later. I'll work to
        remove the need for PHP a little at a time.

        Thanks for the tips, I'll look into it and I'm interested in any other
        ideas out there.

        Brian


        Comment

        • aspineux

          #5
          Re: need advice on building core code for python and PHP

          On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmai l.comwrote:
          Is there a way I could code the base (core) code in Python and have
          PHP call it? I've really liked using SQLAlchemy and there are other
          >
          * quick and dirty solution:
          in a shell:
          $ python yourscript.py <pipe_in >pipe_out
          in the php script:
          fwrite(pipe_in, input_data);
          results = fread(pipe_out, sizeof_results) ;
          >
          * simple and nice solution:
          do not ever use php
          Write a CGI wrapper around your python script, and publish it using
          mod_python.
          And make the appropriate http requests from PHP.





          Comment

          • Graham Dumpleton

            #6
            Re: need advice on building core code for python and PHP

            On May 25, 5:24 am, aspineux <aspin...@gmail .comwrote:
            On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmai l.comwrote:
            >
            Is there a way I could code the base (core) code in Python and have
            PHP call it? I've really liked using SQLAlchemy and there are other
            >
            * quick and dirty solution:
            in a shell:
            $ python yourscript.py <pipe_in >pipe_out
            in the php script:
            fwrite(pipe_in, input_data);
            results = fread(pipe_out, sizeof_results) ;
            >
            * simple and nice solution:
            do not ever use php
            >
            Write a CGI wrapper around your python script, and publish it using mod_python.
            And make the appropriate http requests from PHP.
            You do not need mod_python to host CGI scripts written in Python, they
            are two separate things.

            Depending on the complexity of what you are doing, you might be better
            off writing a backend server in Python that incorporates an XML-RPC
            server. Your PHP script can then use XML-RPC client to communicate to
            the backend Python server to do the real work. Over time you could
            even transition your web pages to being done in Python instead. In
            doing this your back end Python server doesn't have to change, you
            just make XML-RPC calls from the Python code for the web pages in
            place of where you would be doing it with PHP initially. You also
            wouldn't be restricted to web based front ends, you could also use GUI
            based front end as well.

            Graham

            Comment

            • digimotif

              #7
              Re: need advice on building core code for python and PHP

              On May 24, 5:01 pm, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
              wrote:
              On May 25, 5:24 am, aspineux <aspin...@gmail .comwrote:
              >
              >
              >
              On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmai l.comwrote:
              >
              Is there a way I could code the base (core) code in Python and have
              PHP call it? I've really liked using SQLAlchemy and there are other
              >
              * quick and dirty solution:
              in a shell:
              $ python yourscript.py <pipe_in >pipe_out
              in the php script:
              fwrite(pipe_in, input_data);
              results = fread(pipe_out, sizeof_results) ;
              >
              * simple and nice solution:
              do not ever use php
              >
              Write a CGI wrapper around your python script, and publish it using mod_python.
              And make the appropriate http requests from PHP.
              >
              You do not need mod_python to host CGI scripts written in Python, they
              are two separate things.
              >
              Depending on the complexity of what you are doing, you might be better
              off writing a backend server in Python that incorporates an XML-RPC
              server. Your PHP script can then use XML-RPC client to communicate to
              the backend Python server to do the real work. Over time you could
              even transition your web pages to being done in Python instead. In
              doing this your back end Python server doesn't have to change, you
              just make XML-RPC calls from the Python code for the web pages in
              place of where you would be doing it with PHP initially. You also
              wouldn't be restricted to web based front ends, you could also use GUI
              based front end as well.
              >
              Graham
              This sounds more like the direction I should go. Is XML-RPC the only
              technology allowing this sort of setup? If I understand correctly, it
              would basically mean going to a three tiered application approach.
              I'd have the database, the python xml-rpc server, and the gui/web
              interfaces. I'd also want to make sure I'm implementing technology
              that will scale well.

              Brian

              Comment

              • Graham Dumpleton

                #8
                Re: need advice on building core code for python and PHP

                On May 30, 11:24 am, digimotif <digimo...@gmai l.comwrote:
                On May 24, 5:01 pm, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
                wrote:
                >
                >
                >
                On May 25, 5:24 am, aspineux <aspin...@gmail .comwrote:
                >
                On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmai l.comwrote:
                >
                Is there a way I could code the base (core) code in Python and have
                PHP call it? I've really liked using SQLAlchemy and there are other
                >
                * quick and dirty solution:
                in a shell:
                $ python yourscript.py <pipe_in >pipe_out
                in the php script:
                fwrite(pipe_in, input_data);
                results = fread(pipe_out, sizeof_results) ;
                >
                * simple and nice solution:
                do not ever use php
                >
                Write a CGI wrapper around your python script, and publish it usingmod_python .
                And make the appropriate http requests from PHP.
                >
                You do not needmod_pythont o host CGI scripts written in Python, they
                are two separate things.
                >
                Depending on the complexity of what you are doing, you might be better
                off writing a backend server in Python that incorporates an XML-RPC
                server. Your PHP script can then use XML-RPC client to communicate to
                the backend Python server to do the real work. Over time you could
                even transition your web pages to being done in Python instead. In
                doing this your back end Python server doesn't have to change, you
                just make XML-RPC calls from the Python code for the web pages in
                place of where you would be doing it with PHP initially. You also
                wouldn't be restricted to web based front ends, you could also use GUI
                based front end as well.
                >
                Graham
                >
                This sounds more like the direction I should go. Is XML-RPC the only
                technology allowing this sort of setup? If I understand correctly, it
                would basically mean going to a three tiered application approach.
                I'd have the database, the python xml-rpc server, and the gui/web
                interfaces. I'd also want to make sure I'm implementing technology
                that will scale well.
                There is also Pyro, but by using that you limit yourself to Python
                clients as far as I know whereas XML-RPC has clients for lots of
                different languages. Other more complicated options are Corba and SOAP
                frameworks.

                Graham


                Comment

                Working...