Python和App Engine项目结构 [英] Python and App Engine project structure

查看:92
本文介绍了Python和App Engine项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对python和app引擎比较陌生,刚刚完成我的第一个项目。
它包含几个* .py文件(通常是网站上每个页面的py文件)以及每个py文件的相应的temple文件。
另外,我有一个大的PY文件,它有许多页面通用的许多函数,我还声明了db.Model的类(即数据存储种类)。



我的问题是安排这些文件的约定是什么(如果有的话)。
如果我用数据存储类创建了一个model.py,它应该在不同的包中吗?
我应该在哪里放置我的模板文件和处理每个页面的所有py文件(它们应该与一个大的常见PY文件位于同一个目录中)?



谢谢,

b
$ b p> Joel

解决方案

我通常以这种方式组织我的项目:

 项目
main.py
自述文件
模型文件
bar.py
foo.py
浏览文件
foolist.hml
barlist.hml
控制器
controller1.py
controller2.py
api
controllerapi.py
帮助器
utilities.py
lib
extfoo.py
db
foo.db
test
test.py

看看这个帖子;这是一篇关于如何构建项目的非常棒的文章(不是python,但并不重要)。


I am relatively new to python and app engine, and I just finished my first project. It consists of several *.py files (usually py file for every page on the site) and respectively temple files for each py file. In addition, I have one big PY file that has many functions that are common to a lot of pages, in I also declared the classes of db.Model (that is the datastore kinds).

My question is what is the convention (if there is one) of arranging these files. If I create a model.py with the datastore classes, should it be in different package? Where should I put my template files and all of the py files that handle every page (should they be in the same directory as the one big common PY file)?

I have tried to look for MVC and such implementations online but there are very few.

Thanks,

Joel

解决方案

I usually organize my projects in this way:

project 
  main.py
  README
  models
      bar.py
      foo.py
  views
      foolist.hml
      barlist.hml
  controllers
      controller1.py
      controller2.py
  api
      controllerapi.py
  helpers
      utilities.py
  lib
      extfoo.py
  db
     foo.db
  test
     test.py

Look at this post; it's a really great article on how to structure a project (not in python but it does not matter).

这篇关于Python和App Engine项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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