473,847 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving to Python from PHP - 3 questions

Hi everyone,

I've been planning to move to Python from PHP for some time now. I use
PHP extensively for web scripting, with mod_php, Apache, and a DB (I
would characterize my knowledge of PHP as advanced). Here are three
stumbling blocks I've experienced, for which I couldn't seem to find
any helpful information via Google:

1) Mod_python on OSX. I use a Mac as my primary development
environment, so I need mod_python to get anything done. Compiling
mod_python from source fails under OSX 10.3, and mod_python does not
appear to be included in Fink. I've found plenty of other questions
about this on other mailing lists, but so far no conclusive answers -
is mod_python on OSX currently a dead-end?

2) Session management. Cookie-based sessions in PHP are pretty
transparent, with a small library of basic functions that do 95% of
what anyone may need to store session data in serialized files and
associate them with cookies. I've seen python code that accomplishes
this, but so far no pre-built server-side session management modules.

3) Structured request variables. PHP has a really handy feature where
request variables with name like "foo[]", "foo[bar]", or
"foo[bar][baz]" are automatically structured into nested associative
arrays. I can see that the python cgi module will make a list of
MiniFieldStorag e objects when more than one variable with the same name
is provided, but that's about the extent of it that I've seen.

2 & 3 are problems I can solve on my own, but they're so transparently
automatic in PHP that it's a real pleasure to use them. I can probably
implement my own fixes, but I'd rather not have to. Alternatively, are
these just "PHP-isms" for which python has a more native, more
appropriate response?

An "RTFM" answer with a URL for the M would be great. :)

Thank you,
-mike.

------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca http://mike.teczno.com/contact.html

Jul 18 '05 #1
11 1696
Hi,
2) Session management. Cookie-based sessions in PHP are pretty
transparent, with a small library of basic functions that do 95% of
what anyone may need to store session data in serialized files and
associate them with cookies. I've seen python code that accomplishes
this, but so far no pre-built server-side session management modules.
The python-based zope application server has session management. Togther
with a built-in user and access rights management.
3) Structured request variables. PHP has a really handy feature where
request variables with name like "foo[]", "foo[bar]", or
"foo[bar][baz]" are automatically structured into nested associative
arrays. I can see that the python cgi module will make a list of
MiniFieldStorag e objects when more than one variable with the same name
is provided, but that's about the extent of it that I've seen.
This can be done in zope if you name a variable <name>:list. That then will
give you the variable as list regardless of the number of occurences.

An "RTFM" answer with a URL for the M would be great. :)


For zope: http://www.zope.org/

But there are plenty of other python http frameworks. The mod_python is
AFAIK the most basic and primitive one. But build on top of it or fully
python-based you have plenty of options. Google is your friend - this NG
features similar discussions every other week.
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
> The python-based zope application server has session management.
Togther
with a built-in user and access rights management.
...
This can be done in zope if you name a variable <name>:list. That then
will
give you the variable as list regardless of the number of occurences.


Thank you. My impression of Zope in the past has been that it does what
I need, along with 10,000 other things I don't (built in WebDAV
server?!), but clearly I owe it another chance. I've been initially
attracted to mod_python because of its raw simplicity and its apparent
similarity to mod_php and mod_perl, which I am familiar with. I'll give
Zope a try.

------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca http://mike.teczno.com/contact.html

Jul 18 '05 #3
> Thank you. My impression of Zope in the past has been that it does what
I need, along with 10,000 other things I don't (built in WebDAV
server?!), but clearly I owe it another chance. I've been initially
The apache has a built in webdav server too - is that a reason _not_ to use
it? If you don't want a feature, don't use it. You can turn them off, btw.

But what you might not be aware of is that zope does not store its
templates, scripts and files in general in the filesystem as php does, but
as objects in the zodb database. So webdav and ftp are other views to that
objects that allow you to load and save these files using "normal" editors
and tools, not only the web-interface of zope. The advantage of this
approach is that versioning of content - regardless of it's type - is
built-in. Can be a life-saver sometimes :)
attracted to mod_python because of its raw simplicity and its apparent
similarity to mod_php and mod_perl, which I am familiar with.


It certainly is the most simple way to create dynamic content. But there is
a big difference between python and php: php started as a web-developers
tool, and it's features are a direct consequence of that. python oth is a
general purpose programming language - it is certainly suited for web
development, but not limited to. There are people who also want to use php
as general purpose programming language - but nevertheless, its design has
been influenced by its main purpose. So you e.g. get session state handling
"for free" - as more or less _all_ web-apps today need them.
--
Regards,

Diez B. Roggisch
Jul 18 '05 #4
Michal Migurski wrote:
Thank you. My impression of Zope in the past has been that it does what
I need, along with 10,000 other things I don't (built in WebDAV
server?!), but clearly I owe it another chance. I've been initially
attracted to mod_python because of its raw simplicity and its apparent
similarity to mod_php and mod_perl, which I am familiar with. I'll give
Zope a try.


Personally, I'd have to say that your impression was right. Once you
start using Zope, you'll start to feel locked in. Sure, it does a lot
for you, but it's also a big investment.

I can't really help you to get mod_python working on OS X, but
concerning your other two points, did you notice these two sections in
the documentation?

http://modpython.org/live/current/do...yapi-sess.html

http://modpython.org/live/current/do...mprequest.html

mod_python and Zope are not your only options by far. In fact, they're
at completely opposite ends of the spectrum; mod_python being low-level
in that you are in control of everything and have the necessary tools to
build a framework, and Zope being the highest-level in that it does tons
of stuff for you. There are dozens of frameworks in between.

If you do manage to get mod_python working, I suggest taking a look at
Vampire as well: http://www.dscpl.com.au/projects/vampire/
I have had good experience with it. Once you start using mod_python
you'll realize you can really go anywhere you want; and that's not
necessarily a good thing. Vampire points you in a nice direction (I
don't want to say 'the right' direction).

--
Brian Beck
Adventurer of the First Order
Jul 18 '05 #5
Maybe this can help you get it working on OS X:
http://thread.gmane.org/gmane.comp.p...od-python/4039

But as stated in my other post, you may want to take a look at your
other options first. Web development with Python is really nothing like
PHP, unless you really want it to be.

--
Brian Beck
Adventurer of the First Order
Jul 18 '05 #6
Michal Migurski wrote:
Thank you. My impression of Zope in the past has been that it does what
I need, along with 10,000 other things I don't (built in WebDAV
server?!), but clearly I owe it another chance. I've been initially
attracted to mod_python because of its raw simplicity and its apparent
similarity to mod_php and mod_perl, which I am familiar with. I'll give
Zope a try.


I am moving my band's website from an antiquated and horrible PHPNuke
site to a Python-based site, and so have done quite a bit of research
about this (though I never considered myself a PHP expert). Here's what
I've come up with...

Zope is excellent (especially with Plone), but if you are not building
applications that require lots of levels of access and permissions and
collaborations, as well as the 10,000 other things you speak of, you
probably would like something simpler than Zope, such as CherryPy or
Quixote. Both are excellent and light-weight frameworks that give you
session support and easy access to request variables (as well as full
access to the entire Python language). Conceptually, the two are very
close, but I am slightly more biased towards CherryPy lately. Quixote
has better built in form support, but now that I've discovered FormKit,
this seems to becoming a non-issue. Also, both are pure Python so
should run anywhere Python does (though Quixote has a C extension, it
will fallback to a somewhat slower pure-Python version if your platform
cannot compile the extension).

There are other good frameworks out there, like Nevow and Webware, but
have a somewhat larger conceptual overhead which doesn't rest as easy
with me. You'll also want to probably look at some of the templating
kits, of which Cheetah and/or ElementTree work best for me. (Well,
ElementTree isn't exactly a templating kit - it's a general-purpose XML
tookit - but it is easily used for templating.)

General Python web programming:
http://www.python.org/topics/web/

Frameworks/toolkits:
[CherryPy] http://www.cherrypy.org/
[Quixote] http://www.mems-exchange.com/software/quixote
[FormKit] http://dalchemy.com/opensource/formkit/
[Cheetah] http://www.cheetahtemplate.org/
[ElementTree] http://effbot.org/zone/element-index.htm
[Nevow] http://nevow.com/
[Webware] http://www.webwareforpython.org/

For more comparisons of some of the various frameworks:
[PyWebOff] http://pyre.third-bit.com/pyweb/index.html
[Python Web Shootout (older)] http://www.colorstudy.com/docs/shootout.html

--
Soraia: http://www.soraia.com

Jul 18 '05 #7
>> Thank you. My impression of Zope in the past has been that it does
what I need, along with 10,000 other things I don't (built in WebDAV
server?!), but clearly I owe it another chance. I've been initially
attracted to mod_python because of its raw simplicity and its
apparent similarity to mod_php and mod_perl, which I am familiar
with. I'll give Zope a try.


I am moving my band's website from an antiquated and horrible PHPNuke
site to a Python-based site, and so have done quite a bit of research
about this (though I never considered myself a PHP expert). Here's
what I've come up with...

[snip]

This is awesome, quote a bit to chew on. Thank you Joe!

------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca http://mike.teczno.com/contact.html

Jul 18 '05 #8
Joe Francia wrote:
You'll also want to probably look at some of the templating kits, of which Cheetah and/or
ElementTree work best for me. (Well, ElementTree isn't exactly a templating kit - it's a
general-purpose XML tookit - but it is easily used for templating.)


if you want element-based templating, see:

http://lesscode.org/projects/kid/

</F>

Jul 18 '05 #9
Michal Migurski wrote:
The python-based zope application server has session management. Togther
with a built-in user and access rights management.
...
This can be done in zope if you name a variable <name>:list. That then
will
give you the variable as list regardless of the number of occurences.

Thank you. My impression of Zope in the past has been that it does what
I need, along with 10,000 other things I don't (built in WebDAV
server?!),


Our web designer just *loves* it (and ZopePageTemplat es too, since they
work quite ok with it's favorite html editor...). Might not be useful to
you, but...
but clearly I owe it another chance. I've been initially
attracted to mod_python because of its raw simplicity and its apparent
similarity to mod_php and mod_perl, which I am familiar with. I'll give
Zope a try.


Zope is a great product, but hard to get into, and it's sometime just
too big and fat for some simple things. So while it may be worth giving
it a try, I would not recommend it for all and any project.

Now when it comes to session management and the like, there are many
other libs/frameworks/etc based on mod_python.

This might be a good start :
http://www.python.org/topics/web/

HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Jul 18 '05 #10

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

Similar topics

220
19242
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
0
2221
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to python-help, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the helpers. The most comprehensive overview of python.org help resources is at ...
114
9909
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
1
1317
by: Dark Cowherd | last post by:
Hi, We program in Delphi in our shop and are generally very happy with it. We are now looking at cross-platform options especially for middle tier and web server. I have been doing a lot of reading and testing of Python, I am falling in love with the language :-) But seems to be be very difficult for what I am trying to do :-(
9
4604
by: Norm Goertzen | last post by:
I've posted a previous question about IDEs and got some good feedback, thanks, but it does seem that everyone has their own favourite IDE -- in other words, no IDE was repeatedly recommended. So, is there any data on the popularity of IDEs (most users), or is there a chart comparing the most popular versions. I'M NOT AFRAID TO SPEND SOME MONEY TO GET THE RIGHT IDE (but I don't want to change products once I've chosen).
16
2267
by: Kenneth McDonald | last post by:
For unfortunate reasons, I'm considering switching back to Win XP (from OS X) as my "main" system. Windows has so many annoyances that I can only compare it to driving in the Bay Area at rush hour (OS X is like driving in Portland at rush hour--not as bad, but getting there), but there are really only a couple of things that are really, absolutely preventing me from making the switch. Number one is the lack of a decent command line and...
3
3040
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another MouseHover event. To get a Mousehover I must leave and reenter the control. I'd like to get an event each time the cursor stops moving.
2
3250
by: 63q2o4i02 | last post by:
Hi, I'm using python 2.4 and windows XP. I have two packages in the windows version of python in site-packages. They are PyVisa and ctypes, and both live in c:\python24\lib\site-packages I'd like to move these to the cygwin version of python on the same system. I tried copying the PyVisa and ctypes directorices (including
8
7992
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying to catch up again with Python. I am now appearing for Job Interviews these days and I am wondering if anybody of you appeared for a Python Interview. Can you please share the questions you were asked. That will be great help to me.
0
10648
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10341
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7883
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4529
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3164
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.