473,394 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

May 24 '07 #1
7 1333
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

May 24 '07 #2
In article <11**********************@a35g2000prd.googlegroups .com>,
digimotif <di*******@gmail.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?
May 24 '07 #3
>
* 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
May 24 '07 #4
On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmail.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.

May 24 '07 #5
On May 25, 5:24 am, aspineux <aspin...@gmail.comwrote:
On 24 mai, 19:33, Szabolcs Nagy <nszabo...@gmail.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

May 24 '07 #6
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...@gmail.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

May 30 '07 #7
On May 30, 11:24 am, digimotif <digimo...@gmail.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...@gmail.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_pythonto 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
May 30 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Gonnerman | last post by:
I'll be quick. Here's a transcript: C:\usr\WConio-1.5>python setup.py build --compiler=mingw32 running build running build_py running build_ext building '_WConio' extension writing...
12
by: JD | last post by:
This is another Python problem, I think might be unrelated to the earlier bug I found, and eventually figured out how to report it to Sourceforge. This is related to a question I have about...
13
by: Heather Stovold | last post by:
Wow - deciding to program in python sure requires a lot of decisions! So far: I've decided on python for the programming language. I've decided on wxpython for the GUI.... I've decided on...
14
by: Kevin Walzer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm a Tcl/Tk developer who has been dabbling with Python for some time, but had not seen a compelling reason to really learn the language....
7
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
0
by: juncus | last post by:
Hi, Perhaps this is not the right forum to post this, but I am having trouble installing pyParallel. When I try to do the usual "python setup.py build" or "python setup.py install", I get the...
3
by: seberino | last post by:
Anyone have any good advice to someone interested in learning about innards of Python implementation? e.g. What is best place to start? Where can I get a 10,000 ft. overview of general...
6
by: PythonBiter | last post by:
Hi everyone, I'm very new in this Group as well Python language. I want to learn Python. So could you please advice me, and guide me how can i become master in Python ! Thanks, Partha
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.