Skip to content

Commit 00dcdcf

Browse files
committed
Refactor docs, and add theme
1 parent 70ba561 commit 00dcdcf

File tree

9 files changed

+483
-187
lines changed

9 files changed

+483
-187
lines changed

docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
# The short X.Y version.
5151
version = '1.0'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '1.0testing'
53+
release = '1.0(rc)'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.
@@ -99,7 +99,7 @@
9999
#html_theme_options = {}
100100

101101
# Add any paths that contain custom themes here, relative to this directory.
102-
#html_theme_path = []
102+
html_theme_path = ['theme']
103103

104104
# The name for this set of Sphinx documents. If None, it defaults to
105105
# "<project> v<release> documentation".
@@ -120,7 +120,7 @@
120120
# Add any paths that contain custom static files (such as style sheets) here,
121121
# relative to this directory. They are copied after the builtin static files,
122122
# so a file named "default.css" will overwrite the builtin "default.css".
123-
html_static_path = ['_static']
123+
html_static_path = ['static']
124124

125125
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
126126
# using the given strftime format.

docs/faq.rst

+107
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,110 @@ https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-the
176176

177177
.. _staticfiles_urlpatterns: https://docs.djangoproject.com/en/dev/howto/static-files/#staticfiles-development
178178

179+
如何在SAE上使用Uliweb
180+
----------------------
181+
182+
Thanks to limodou#gmail.com
183+
184+
uliweb的安装
185+
+++++++++++++
186+
187+
为搭建本地开发环境,你需要安装uliweb 0.0.1a7以上版本或svn中的版本, 简单的安装可以是::
188+
189+
easy_install Uliweb
190+
191+
安装后在Python环境下就可以使用uliweb命令行工具了。
192+
193+
目前Uliweb支持Python 2.6和2.7版本。3.X还不支持。
194+
195+
Hello, Uliweb
196+
+++++++++++++++++
197+
198+
让我们从最简单的Hello, Uliweb的开发开始。首先假设你已经有了sae的帐号.
199+
200+
#. 创建一个新的应用,并且选择Python环境。
201+
#. 从svn环境中checkout一个本地目录
202+
#. 进入命令行,切換到svn目录下
203+
#. 创建Uliweb项目::
204+
205+
uliweb makeproject project
206+
207+
会在当前目录下创建一个 ``project`` 的目录。这个目录可以是其它名字,不过它是和后面要使用的 ``index.wsgi`` 对应的,所以建议不要修改。
208+
209+
#. 创建 ``index.wsgi`` 文件,Uliweb提供了一个命令来做这事::
210+
211+
uliweb support sae
212+
213+
这样会在当前目录下创建一个 ``index.wsgi`` 的文件和 ``lib`` 目录。注意执行时是在svn的目录,即project的父目录中。
214+
215+
``index.wsgi`` 的内容是::
216+
217+
import sae
218+
import sys, os
219+
220+
path = os.path.dirname(os.path.abspath(__file__))
221+
project_path = os.path.join(path, 'project')
222+
sys.path.insert(0, project_path)
223+
sys.path.insert(0, os.path.join(path, 'lib'))
224+
225+
from uliweb.manage import make_application
226+
app = make_application(project_dir=project_path)
227+
228+
application = sae.create_wsgi_app(app)
229+
230+
其中 ``project`` 和 ``lib`` 都已经加入到 ``sys.path`` 中了。所以建议使用上面
231+
的路径,不然就要手工修改这个文件了。
232+
233+
#. 然后就可以按正常的开发app的流程来创建app并写代码了,如::
234+
235+
cd project
236+
uliweb makeapp simple_todo
237+
238+
这时一个最简单的Hello, Uliweb已经开发完毕了。
239+
240+
#. 如果有静态文件,则需要放在版本目录下,Uliweb提供了命令可以提取安装的app的静态文件::
241+
242+
cd project
243+
uliweb exportstatic ../static
244+
245+
#. 如果有第三方源码包同时要上传到sae中怎么办,Uliweb提供了export命令可以导出已经
246+
安装的app或指定的模块的源码到指定目录下::
247+
248+
cd project
249+
uliweb export -d ../lib #这样是导出全部安装的app
250+
uliweb export -d ../lib module1 module2 #这样是导出指定的模块
251+
252+
为什么还需要导出安装的app,因为有些app不是放在uliweb.contrib中的,比如第三方
253+
的,所以需要导出后上传。但是因为export有可能导出已经内置于uliweb中的app,所以
254+
通常你可能还需要在 ``lib`` 目录下手工删除一些不需要的模块。
255+
256+
#. 提交代码
257+
258+
访问 ``http://<你的应用名称>.sinaapp.com`` ,就可看到项目的页面了。
259+
260+
数据库配置
261+
+++++++++++++++++
262+
263+
Uliweb中内置了一个对sae支持的app,还在不断完善中,目前可以方便使用sae提供的MySql
264+
数据库。
265+
266+
然后修改 ``project/apps/settings.ini`` 在 ``GLOBAL/INSTALLED_APPS`` 最后添加::
267+
268+
[GLOBAL]
269+
INSTALLED_APPS = [
270+
...
271+
'uliweb.contrib.sae'
272+
]
273+
274+
然后为了支持每个请求建立数据库连接的方式,还需要添加一个Middleware在settings.ini中::
275+
276+
[MIDDLEWARES]
277+
transaction = 'uliweb.orm.middle_transaction.TransactionMiddle'
278+
db_connection = 'uliweb.contrib.sae.middle_sae_orm.DBConnectionMiddle'
279+
280+
其中第一行是事务支持的Middleware你也可以选择使用。
281+
282+
这样就配置好了。而相关的数据库表的创建维护因为sae不能使用命令行,所以要按sae的
283+
文档说明通过phpMyAdmin来导入。以后Uliweb会増加相应的维护页面来做这事。
284+
285+

0 commit comments

Comments
 (0)