DAOCLOUD
推荐学习书目
Python Cookbook
Using Google App Engine
推荐下载
Latest Google App Engine SDK
其他兼容技术
AppScale
kayue

GAE folder structure / autoload

  •  
  •   kayue · Dec 19, 2010 · 5055 views
    This topic created in 5628 days ago, the information mentioned may be changed or developed.
    请问一下 GAE 能够做到 php zend framework 那样的 class autoload 和 folder structure 吗?

    例如:

    views/
    views/index.html
    views/register.html
    views/login.html
    views/profile.html
    modules/
    modules/user.py
    controllers/
    controllers/index.py
    controllers/register.py
    controllers/login.py
    controllers/profile.py
    5 replies    1970-01-01 08:00:00 +08:00
    darasion
        1
    darasion  
       Dec 19, 2010
    python 的 django 框架好像就有你说的 “ folder structure ” ,因为我看 jaiku 的源码里边就是这么写的。GAE 可以使用 django 。

    至于 class autoload ,不用那么强求吧?python 好像没这么写的。不过可以用星号来导入一个模块的所有类和方法什么的,例如:

    import path.to.module.*
    darasion
        2
    darasion  
       Dec 19, 2010
    啊,错了 ,是这样:

    from path.to.module import *
    keakon
        3
    keakon  
       Dec 19, 2010
    不知道你问的具体是什么意思。

    class autoload是说修改了文件后,会自动重新加载吗?答案是不一定。改自己的源代码会自动加载,改SDK不一定会。此外云端是没法改源码的。

    folder structure是指源代码可以按文件夹分类么?你按照Python的要求写成包结构就行了,也就是必须包含__init__.py,哪怕是空文件也行。至于views,如果里面没有Python文件,可以不使用包。
    kayue
        4
    kayue  
    OP
       Dec 19, 2010
    autoload 是指自动 import 所需的 classes
    在 php 下可以利用 magic method 自动 call include($path_to_file)
    darasion
        5
    darasion  
       Dec 19, 2010
    @kayue 试过 php 的autoload,但 python 不这么写,并且python类的用法跟 php 类的用法差别其实挺大的,仔细体会体会吧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1026 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:04 · PVG 07:04 · LAX 16:04 · JFK 19:04
    ♥ Do have faith in what you're doing.