从PHP迁移到Python - 3个问题 [英] Moving to Python from PHP - 3 questions

查看:89
本文介绍了从PHP迁移到Python - 3个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我一直计划从PHP迁移到Python一段时间了。我广泛使用

PHP进行Web脚本编写,使用mod_php,Apache和DB(我将b * b表示我对PHP的高级知识)。这里有三个我经历过的b
绊脚石,我无法通过Google找到

任何有用的信息:

1)OSX上的Mod_python。我使用Mac作为我的主要开发

环境,所以我需要mod_python来完成任何事情。从源代码编译

mod_python在OSX 10.3下失败,而mod_python没有
似乎包含在Fink中。我在其他邮件列表上发现了很多其他问题

,但到目前为止还没有确凿的答案 -

OSX上的mod_python目前是一个死胡同吗? br />

2)会话管理。 PHP中基于Cookie的会话非常透明,带有一个基本功能的小型库,可以完成95%的b
,任何人可能需要将会话数据存储在序列化文件中

将它们与cookie相关联。我已经看到python代码完成了这个,但到目前为止还没有预构建的服务器端会话管理模块。


3)结构化请求变量。 PHP有一个非常方便的功能,其中

请求变量,其名称类似于foo [],foo [bar]或

" foo [巴] [巴兹] QUOT;自动构造成嵌套的关联

数组。我可以看到,当提供多个具有相同名称的变量

时,python cgi模块将列出

MiniFieldStorage对象,但这是关于我见过的程度。


2& 3是我自己可以解决的问题,但它们是如此透明地在PHP中自动地使用它们是非常愉快的。我可以

实现我自己的修复,但我宁愿不必。或者,这些仅仅是PHP-isms。哪个python有更原生的,更多的b $ b b适当的响应?


一个RTFM用M的URL回答会很棒。 :)


谢谢,

-mike。


---------- --------------------------------------------

michal migurski-联系信息,博客和pgp密钥:

sf / ca http://mike.teczno.com/contact.html

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
MiniFieldStorage 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

推荐答案


2)会话管理。 PHP中基于Cookie的会话相当透明,有一个基本功能的小型库,可以完成95%的任何人在序列化文件中存储会话数据所需的内容,并将它们与cookie相关联。我见过python代码完成了这个,但到目前为止还没有预构建的服务器端会话管理模块。


基于python的zope应用服务器具有会话管理功能。 Togther

,内置用户和访问权限管理。

3)结构化请求变量。 PHP有一个非常方便的功能,其中
请求变量的名称类似于foo [],foo [bar]或
foo [bar] [baz]"自动构造成嵌套的关联数组。我可以看到,当提供了多个具有相同名称的变量时,python cgi模块将列出一个MiniFieldStorage对象的列表,但这是关于我的程度。看到。


如果您命名变量< name>:list,则可以在zope中完成。然后,无论出现的次数如何,

都会将变量作为列表给出。

一个RTFM。用M的URL回答会很棒。 :)
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
MiniFieldStorage 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. :)




对于zope: http: //www.zope.org/


但是还有很多其他的python http框架。 mod_python是

AFAIK最基本和最原始的一个。但建立在它之上或完全基于python的
你有很多选择。谷歌是你的朋友 - 这个NG

每隔一周都有类似的讨论。

-

问候,


Diez B. Roggisch



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


>基于python的zope应用服务器具有会话管理。
> The python-based zope application server has session management.
Togther
具有内置用户和访问权限管理。
...
这可以做到在zope中,如果您将变量命名为< name>:list。然后
会将变量作为列表给出,无论出现的次数如何。
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.




谢谢。我过去对Zope的印象是,它确实需要我需要的其他一些东西,以及其他10,000件我不需要的东西(内置WebDAV

服务器?!) ,但显然我欠了另一个机会。我最初被mod_python所吸引,因为它原始的简单性和与mod_php和mod_perl相似的明显的

,我很熟悉。我会试试

Zope。


--------------------- ---------------------------------

michal migurski-联系信息,博客和pgp key:

sf / ca http:// mike。 teczno.com/contact.html



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


>谢谢。我过去对Zope的印象是它做了我需要的
> Thank you. My impression of Zope in the past has been that it does what
以及我不需要的其他10,000件事(内置WebDAV服务器?!),但显然我欠它的另一个机会。我最初是


apache也有一个内置的webdav服务器 - 这是一个_not_使用

的原因吗?如果你不想要一个功能,不要使用它。你可以关闭它们,顺便说一句。


但你可能不知道的是zope不存储它的

模板,脚本和文件像php一样在文件系统中,但是作为zodb数据库中的对象的
。所以webdav和ftp是那些允许你使用正常加载和保存这些文件的对象的其他视图。编辑

和工具,不仅仅是zope的web界面。这种

方法的优点是内容的版本控制 - 无论它的类型如何 - 都是内置的
。有时可以节省生命:

吸引到mod_python,因为它原始的简单性和它与mod_php和mod_perl的明显相似性,我很熟悉。
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.




这当然是创建动态内容的最简单方法。但是有一个很好的区别在于python和php:php起初是一个网络开发者工具,它的功能直接导致了这一点。 python oth是一种

通用编程语言 - 它当然适用于web

开发,但不限于此。有些人也想使用php

作为通用编程语言 - 但是,它的设计已经受到其主要目的的影响。所以,例如你得到会话状态处理

免费 - 或多或少_all_ web-apps今天需要它们。

-

问候,


Diez B. Roggisch



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


这篇关于从PHP迁移到Python - 3个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆