時候不早了,廢話也不多說了。開始吧!
1. paster create --template=pylons minispider
2. MySQL,建立數據庫minispider








3. The Model
1) 修改development.ini,代碼如下:
?1
#
?2
#?minispider?-?Pylons?development?environment?configuration
?3
#
?4
#?The?%(here)s?variable?will?be?replaced?with?the?parent?directory?of?this?file
?5
#
?6
[DEFAULT]
?7
debug?=?true
?8
email_to?=?you@yourdomain.com
?9
smtp_server?=?localhost
10
error_email_from?=?paste@localhost
11
12
[server:main]
13
use?=?egg:Paste#http
14
host?=?0.0.0.0
15
port?=?5000
16
17
[app:main]
18
use?=?egg:minispider
19
cache_dir?=?%(here)s/data
20
session_key?=?minispider
21
session_secret?=?somesecret
22
23
#?If?you'd?like?to?fine-tune?the?individual?locations?of?the?cache?data?dirs
24
#?for?Myghty,?the?Cache?data,?or?the?Session?saves,?un-comment?the?desired
25
#?settings?here:
26
#myghty_data_dir?=?%(here)s/data/templates
27
#cache_data_dir?=?%(here)s/data/cache
28
#session_data_dir?=?%(here)s/data/sessions
29
30
#?Specify?the?database?for?SQLObject?to?use?via?pylons.database.PackageHub.
31
#?%(here)?may?include?a?':'?character?on?Windows?environments;?this?can
32
#?invalidate?the?URI?when?specifying?a?SQLite?db?via?path?name.?Refer?to?the
33
#?SQLObject?documentation?for?a?special?syntax?to?preserve?the?URI.
34
#sqlobject.dburi?=?sqlite:%(here)s/somedb.db
35
sqlobject.dburi?=?mysql://root:123456@localhost:3306/minispider
36
37
#?WARNING:?*THE?LINE?BELOW?MUST?BE?UNCOMMENTED?ON?A?PRODUCTION?ENVIRONMENT*
38
#?Debug?mode?will?enable?the?interactive?debugging?tool,?allowing?ANYONE?to
39
#?execute?malicious?code?after?an?exception?is?raised.
40
#set?debug?=?false
第35行為添加的部分。
?2

?3

?4

?5

?6

?7

?8

?9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

2)在models目錄下,建立msmodel.py,代碼如下:






















4.The view
在templates文件夾下建立ms文件夾,在ms文件中建立list.myt,代碼如下:





















5.The controller
命令行運行:
cd minispider
paster controller ms
將controllers文件夾下ms.py修改,代碼如下:












6. run
命令行運行:
paster serve --reload development.ini
ok,訪問:http://127.0.0.1:5000/ms
結果類似:
What | Where | When |
Baidu | Baidu | 2006-12-05 22:18:12 |
2006-12-05 22:18:42 |
初試,功能之強大,操作之簡便,初見端倪。
|
|
歡迎大家訪問我的個人網站 萌萌的IT人
1. 表中必須含有自增的id字段?
2. 表名不可以是user?如何解決?