quickwiki-patches-ches / quickwiki-097.patch

   1
   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
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
updating QuickWiki for Pylons 0.9.7

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,6 +1,7 @@
 syntax:glob
 .svn
 .coverage
+*.db
 *.pyc
 *.egg-info/
 *.egg-link
@@ -10,6 +11,7 @@
 container_dbm*
 *~
 build/
+data/
 dist/
 easy-install.pth
 site.py
diff --git a/MANIFEST.in b/MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,3 @@
+include quickwiki/config/deployment.ini_tmpl
 recursive-include quickwiki/public *
 recursive-include quickwiki/templates *
diff --git a/development.ini b/development.ini
--- a/development.ini
+++ b/development.ini
@@ -12,28 +12,27 @@
 
 [server:main]
 use = egg:Paste#http
-host = 0.0.0.0
+host = 127.0.0.1
 port = 5000
 
 [app:main]
 use = egg:QuickWiki
 full_stack = true
+static_files = true
+
 cache_dir = %(here)s/data
 beaker.session.key = quickwiki
 beaker.session.secret = somesecret
 
-# Specify the database for SQLAlchemy to use.
-# %(here) may include a ':' character on Windows environments; this can
-# invalidate the URI when specifying a SQLite db via path name
-sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db
-sqlalchemy.echo = true
-
 # If you'd like to fine-tune the individual locations of the cache data dirs
 # for the Cache data, or the Session saves, un-comment the desired settings
 # here:
 #beaker.cache.data_dir = %(here)s/data/cache
 #beaker.session.data_dir = %(here)s/data/sessions
 
+# SQLAlchemy database URL
+sqlalchemy.url = sqlite:///%(here)s/development.db
+
 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
 # Debug mode will enable the interactive debugging tool, allowing ANYONE to
 # execute malicious code after an exception is raised.
@@ -42,7 +41,7 @@
 
 # Logging configuration
 [loggers]
-keys = root, quickwiki
+keys = root, routes, quickwiki, sqlalchemy
 
 [handlers]
 keys = console
@@ -54,11 +53,25 @@
 level = INFO
 handlers = console
 
+[logger_routes]
+level = INFO
+handlers =
+qualname = routes.middleware
+# "level = DEBUG" logs the route matched and routing variables.
+
 [logger_quickwiki]
 level = DEBUG
 handlers =
 qualname = quickwiki
 
+[logger_sqlalchemy]
+level = INFO
+handlers =
+qualname = sqlalchemy.engine
+# "level = INFO" logs SQL queries.
+# "level = DEBUG" logs SQL queries and results.
+# "level = WARN" logs neither.  (Recommended for production systems.)
+
 [handler_console]
 class = StreamHandler
 args = (sys.stderr,)
diff --git a/docs/index.txt b/docs/index.txt
--- a/docs/index.txt
+++ b/docs/index.txt
@@ -8,5 +8,12 @@
 
     setup.py pudge
 
-For this to work you will need to download and install ``buildutils`` and
-``pudge``.
+For this to work you will need to download and install `buildutils`_,
+`pudge`_, and `pygments`_.  The ``pudge`` command is disabled by
+default; to ativate it in your project, run::
+
+    setup.py addcommand -p buildutils.pudge_command
+
+.. _buildutils: http://pypi.python.org/pypi/buildutils
+.. _pudge: http://pudge.lesscode.org/
+.. _pygments: http://pygments.org/
diff --git a/ez_setup.py b/ez_setup.py
new file mode 100644
--- /dev/null
+++ b/ez_setup.py
@@ -0,0 +1,275 @@
+#!python
+"""Bootstrap setuptools installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+    from ez_setup import use_setuptools
+    use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import sys
+DEFAULT_VERSION = "0.6c9"
+DEFAULT_URL     = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
+
+md5_data = {
+    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
+    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
+    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
+    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
+    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
+    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
+    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
+    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
+    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
+    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
+    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
+    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
+    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
+    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
+    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
+    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
+    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
+    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
+    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
+    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
+    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
+    'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
+    'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
+    'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
+    'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
+    'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
+    'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
+    'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
+    'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
+    'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
+    'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
+    'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
+    'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
+}
+
+import sys, os
+try: from hashlib import md5
+except ImportError: from md5 import md5
+
+def _validate_md5(egg_name, data):
+    if egg_name in md5_data:
+        digest = md5(data).hexdigest()
+        if digest != md5_data[egg_name]:
+            print >>sys.stderr, (
+                "md5 validation of %s failed!  (Possible download problem?)"
+                % egg_name
+            )
+            sys.exit(2)
+    return data
+
+def use_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    download_delay=15
+):
+    """Automatically find/download setuptools and make it available on sys.path
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end with
+    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
+    it is not already available.  If `download_delay` is specified, it should
+    be the number of seconds that will be paused before initiating a download,
+    should one be required.  If an older version of setuptools is installed,
+    this routine will print a message to ``sys.stderr`` and raise SystemExit in
+    an attempt to abort the calling script.
+    """
+    was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
+    def do_download():
+        egg = download_setuptools(version, download_base, to_dir, download_delay)
+        sys.path.insert(0, egg)
+        import setuptools; setuptools.bootstrap_install_from = egg
+    try:
+        import pkg_resources
+    except ImportError:
+        return do_download()       
+    try:
+        pkg_resources.require("setuptools>="+version); return
+    except pkg_resources.VersionConflict, e:
+        if was_imported:
+            print >>sys.stderr, (
+            "The required version of setuptools (>=%s) is not available, and\n"
+            "can't be installed while this script is running. Please install\n"
+            " a more recent version first, using 'easy_install -U setuptools'."
+            "\n\n(Currently using %r)"
+            ) % (version, e.args[0])
+            sys.exit(2)
+        else:
+            del pkg_resources, sys.modules['pkg_resources']    # reload ok
+            return do_download()
+    except pkg_resources.DistributionNotFound:
+        return do_download()
+
+def download_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    delay = 15
+):
+    """Download setuptools from a specified location and return its filename
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end
+    with a '/'). `to_dir` is the directory where the egg will be downloaded.
+    `delay` is the number of seconds to pause before an actual download attempt.
+    """
+    import urllib2, shutil
+    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
+    url = download_base + egg_name
+    saveto = os.path.join(to_dir, egg_name)
+    src = dst = None
+    if not os.path.exists(saveto):  # Avoid repeated downloads
+        try:
+            from distutils import log
+            if delay:
+                log.warn("""
+---------------------------------------------------------------------------
+This script requires setuptools version %s to run (even to display
+help).  I will attempt to download it for you (from
+%s), but
+you may need to enable firewall access for this script first.
+I will start the download in %d seconds.
+
+(Note: if this machine does not have network access, please obtain the file
+
+   %s
+
+and place it in this directory before rerunning this script.)
+---------------------------------------------------------------------------""",
+                    version, download_base, delay, url
+                ); from time import sleep; sleep(delay)
+            log.warn("Downloading %s", url)
+            src = urllib2.urlopen(url)
+            # Read/write all in one block, so we don't create a corrupt file
+            # if the download is interrupted.
+            data = _validate_md5(egg_name, src.read())
+            dst = open(saveto,"wb"); dst.write(data)
+        finally:
+            if src: src.close()
+            if dst: dst.close()
+    return os.path.realpath(saveto)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+def main(argv, version=DEFAULT_VERSION):
+    """Install or upgrade setuptools and EasyInstall"""
+    try:
+        import setuptools
+    except ImportError:
+        egg = None
+        try:
+            egg = download_setuptools(version, delay=0)
+            sys.path.insert(0,egg)
+            from setuptools.command.easy_install import main
+            return main(list(argv)+[egg])   # we're done here
+        finally:
+            if egg and os.path.exists(egg):
+                os.unlink(egg)
+    else:
+        if setuptools.__version__ == '0.0.1':
+            print >>sys.stderr, (
+            "You have an obsolete version of setuptools installed.  Please\n"
+            "remove it from your system entirely before rerunning this script."
+            )
+            sys.exit(2)
+
+    req = "setuptools>="+version
+    import pkg_resources
+    try:
+        pkg_resources.require(req)
+    except pkg_resources.VersionConflict:
+        try:
+            from setuptools.command.easy_install import main
+        except ImportError:
+            from easy_install import main
+        main(list(argv)+[download_setuptools(delay=0)])
+        sys.exit(0) # try to force an exit
+    else:
+        if argv:
+            from setuptools.command.easy_install import main
+            main(argv)
+        else:
+            print "Setuptools version",version,"or greater has been installed."
+            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
+
+def update_md5(filenames):
+    """Update our built-in md5 registry"""
+
+    import re
+
+    for name in filenames:
+        base = os.path.basename(name)
+        f = open(name,'rb')
+        md5_data[base] = md5(f.read()).hexdigest()
+        f.close()
+
+    data = ["    %r: %r,\n" % it for it in md5_data.items()]
+    data.sort()
+    repl = "".join(data)
+
+    import inspect
+    srcfile = inspect.getsourcefile(sys.modules[__name__])
+    f = open(srcfile, 'rb'); src = f.read(); f.close()
+
+    match = re.search("\nmd5_data = {\n([^}]+)}", src)
+    if not match:
+        print >>sys.stderr, "Internal error!"
+        sys.exit(2)
+
+    src = src[:match.start(1)] + repl + src[match.end(1):]
+    f = open(srcfile,'w')
+    f.write(src)
+    f.close()
+
+
+if __name__=='__main__':
+    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
+        update_md5(sys.argv[2:])
+    else:
+        main(sys.argv[1:])
+
+
+
+
+
+
diff --git a/quickwiki/config/deployment.ini_tmpl b/quickwiki/config/deployment.ini_tmpl
new file mode 100644
--- /dev/null
+++ b/quickwiki/config/deployment.ini_tmpl
@@ -0,0 +1,63 @@
+#
+# QuickWiki - Pylons configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = egg:QuickWiki
+full_stack = true
+static_files = true
+cache_dir = %(here)s/data
+beaker.session.key = quickwiki
+beaker.session.secret = ${app_instance_secret}
+app_instance_uuid = ${app_instance_uuid}
+
+# If you'd like to fine-tune the individual locations of the cache data dirs
+# for the Cache data, or the Session saves, un-comment the desired settings
+# here:
+#beaker.cache.data_dir = %(here)s/data/cache
+#beaker.session.data_dir = %(here)s/data/sessions
+
+# SQLAlchemy database URL
+sqlalchemy.url = sqlite:///production.db
+sqlalchemy.echo = False
+
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+# execute malicious code after an exception is raised.
+set debug = false
+
+
+# Logging configuration
+[loggers]
+keys = root
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
diff --git a/quickwiki/config/environment.py b/quickwiki/config/environment.py
--- a/quickwiki/config/environment.py
+++ b/quickwiki/config/environment.py
@@ -1,12 +1,15 @@
 """Pylons environment configuration"""
 import os
 
+from mako.lookup import TemplateLookup
 from pylons import config
+from pylons.error import handle_mako_error
 from sqlalchemy import engine_from_config
 
 import quickwiki.lib.app_globals as app_globals
 import quickwiki.lib.helpers
 from quickwiki.config.routing import make_map
+from quickwiki.model import init_model
 
 def load_environment(global_conf, app_conf):
     """Configure the Pylons environment via the ``pylons.config``
@@ -20,17 +23,23 @@
                  templates=[os.path.join(root, 'templates')])
 
     # Initialize config with the basic options
-    config.init_app(global_conf, app_conf, package='quickwiki',
-                    template_engine='mako', paths=paths)
+    config.init_app(global_conf, app_conf, package='quickwiki', paths=paths)
 
     config['routes.map'] = make_map()
-    config['pylons.g'] = app_globals.Globals()
+    config['pylons.app_globals'] = app_globals.Globals()
     config['pylons.h'] = quickwiki.lib.helpers
 
-    # Customize templating options via this variable
-    tmpl_options = config['buffet.template_options']
-
+    # Create the Mako TemplateLookup, with the default auto-escaping
+    config['pylons.app_globals'].mako_lookup = TemplateLookup(
+        directories=paths['templates'],
+        error_handler=handle_mako_error,
+        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
+        input_encoding='utf-8', default_filters=['escape'],
+        imports=['from webhelpers.html import escape'])
+    
+    # Setup SQLAlchemy database engine
+    engine = engine_from_config(config, 'sqlalchemy.')
+    init_model(engine)
+    
     # CONFIGURATION OPTIONS HERE (note: all config options will override
     # any Pylons config options)
-    config['pylons.g'].sa_engine = engine_from_config(config,
-                                                      'sqlalchemy.default.')
diff --git a/quickwiki/config/middleware.py b/quickwiki/config/middleware.py
--- a/quickwiki/config/middleware.py
+++ b/quickwiki/config/middleware.py
@@ -1,18 +1,17 @@
 """Pylons middleware initialization"""
+from beaker.middleware import CacheMiddleware, SessionMiddleware
 from paste.cascade import Cascade
 from paste.registry import RegistryManager
 from paste.urlparser import StaticURLParser
 from paste.deploy.converters import asbool
-
 from pylons import config
-from pylons.error import error_template
-from pylons.middleware import error_mapper, ErrorDocuments, ErrorHandler, \
-    StaticJavascripts
+from pylons.middleware import ErrorHandler, StatusCodeRedirect
 from pylons.wsgiapp import PylonsApp
+from routes.middleware import RoutesMiddleware
 
 from quickwiki.config.environment import load_environment
 
-def make_app(global_conf, full_stack=True, **app_conf):
+def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
     """Create a Pylons WSGI application and return it
 
     ``global_conf``
@@ -20,38 +19,51 @@
         the [DEFAULT] section of the Paste ini file.
 
     ``full_stack``
-        Whether or not this application provides a full WSGI stack (by
-        default, meaning it handles its own exceptions and errors).
-        Disable full_stack when this application is "managed" by
-        another WSGI middleware.
+        Whether this application provides a full WSGI stack (by default,
+        meaning it handles its own exceptions and errors). Disable
+        full_stack when this application is "managed" by another WSGI
+        middleware.
+
+    ``static_files``
+        Whether this application serves its own static files; disable
+        when another web server is responsible for serving them.
 
     ``app_conf``
-        The application's local configuration. Normally specified in the
-        [app:<name>] section of the Paste ini file (where <name>
+        The application's local configuration. Normally specified in
+        the [app:<name>] section of the Paste ini file (where <name>
         defaults to main).
+
     """
     # Configure the Pylons environment
     load_environment(global_conf, app_conf)
 
     # The Pylons WSGI app
     app = PylonsApp()
-
+    
+    # Routing/Session/Cache Middleware
+    app = RoutesMiddleware(app, config['routes.map'])
+    app = SessionMiddleware(app, config)
+    app = CacheMiddleware(app, config)
+    
     # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
-
+    
     if asbool(full_stack):
         # Handle Python exceptions
-        app = ErrorHandler(app, global_conf, error_template=error_template,
-                           **config['pylons.errorware'])
+        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
 
         # Display error documents for 401, 403, 404 status codes (and
         # 500 when debug is disabled)
-        app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
+        if asbool(config['debug']):
+            app = StatusCodeRedirect(app)
+        else:
+            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
 
     # Establish the Registry for this application
     app = RegistryManager(app)
 
-    # Static files
-    javascripts_app = StaticJavascripts()
-    static_app = StaticURLParser(config['pylons.paths']['static_files'])
-    app = Cascade([static_app, javascripts_app, app])
+    if asbool(static_files):
+        # Serve static files
+        static_app = StaticURLParser(config['pylons.paths']['static_files'])
+        app = Cascade([static_app, app])
+
     return app
diff --git a/quickwiki/config/routing.py b/quickwiki/config/routing.py
--- a/quickwiki/config/routing.py
+++ b/quickwiki/config/routing.py
@@ -11,16 +11,29 @@
     """Create, configure and return the routes Mapper"""
     map = Mapper(directory=config['pylons.paths']['controllers'],
                  always_scan=config['debug'])
-
+    map.minimization = False
+    
     # The ErrorController route (handles 404/500 error pages); it should
     # likely stay at the top, ensuring it can always be resolved
-    map.connect('error/:action/:id', controller='error')
+    map.connect('/error/{action}', controller='error')
+    map.connect('/error/{action}/{id}', controller='error')
 
     # CUSTOM ROUTES HERE
 
-    map.connect(':controller/:action/:title', controller='page',
-                action='index', title='FrontPage')
-    map.connect(':title', controller='page', action='index', title='FrontPage')
-    map.connect('*url', controller='template', action='view')
+    map.connect('home', '/', controller='pages', action='show',
+                title='FrontPage')
+    map.connect('pages', '/pages', controller='pages', action='index')
+    map.connect('show_page', '/pages/show/{title}', controller='pages',
+                action='show')
+    map.connect('edit_page', '/pages/edit/{title}', controller='pages',
+                action='edit')
+    map.connect('save_page', '/pages/save/{title}', controller='pages',
+                action='save', conditions=dict(method='POST'))
+    map.connect('delete_page', '/pages/delete/{title}', controller='pages',
+                action='delete')
+
+    # A bonus example - the specified defaults allow visiting
+    # example.com/FrontPage to view the page titled 'FrontPage':
+    map.connect('/{title}', controller='pages', action='show')
 
     return map
diff --git a/quickwiki/controllers/error.py b/quickwiki/controllers/error.py
--- a/quickwiki/controllers/error.py
+++ b/quickwiki/controllers/error.py
@@ -1,9 +1,12 @@
-import os.path
+import cgi
 
-import paste.fileapp
-from pylons.middleware import error_document_template, media_path
+from paste.urlparser import PkgResourcesParser
+from pylons import request
+from pylons.controllers.util import forward
+from pylons.middleware import error_document_template
+from webhelpers.html.builder import literal
 
-from quickwiki.lib.base import *
+from quickwiki.lib.base import BaseController
 
 class ErrorController(BaseController):
     """Generates error documents as and when they are required.
@@ -13,27 +16,29 @@
 
     This behaviour can be altered by changing the parameters to the
     ErrorDocuments middleware in your config/middleware.py file.
+    
     """
-
     def document(self):
         """Render the error document"""
+        resp = request.environ.get('pylons.original_response')
+        content = literal(resp.body) or cgi.escape(request.GET.get('message'))
         page = error_document_template % \
             dict(prefix=request.environ.get('SCRIPT_NAME', ''),
-                 code=request.params.get('code', ''),
-                 message=request.params.get('message', ''))
+                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
+                 message=content)
         return page
 
     def img(self, id):
         """Serve Pylons' stock images"""
-        return self._serve_file(os.path.join(media_path, 'img', id))
+        return self._serve_file('/'.join(['media/img', id]))
 
     def style(self, id):
         """Serve Pylons' stock stylesheets"""
-        return self._serve_file(os.path.join(media_path, 'style', id))
+        return self._serve_file('/'.join(['media/style', id]))
 
     def _serve_file(self, path):
         """Call Paste's FileApp (a WSGI application) to serve the file
         at the specified path
         """
-        fapp = paste.fileapp.FileApp(path)
-        return fapp(request.environ, self.start_response)
+        request.environ['PATH_INFO'] = '/%s' % path
+        return forward(PkgResourcesParser('pylons', 'pylons'))
diff --git a/quickwiki/controllers/page.py b/quickwiki/controllers/pages.py
rename from quickwiki/controllers/page.py
rename to quickwiki/controllers/pages.py
--- a/quickwiki/controllers/page.py
+++ b/quickwiki/controllers/pages.py
@@ -1,52 +1,59 @@
 import logging
+from cgi import escape
 
-from quickwiki.lib.base import *
-from quickwiki.model import Page
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+from pylons.decorators.secure import authenticate_form
+
+from quickwiki.lib.base import BaseController, render
+from quickwiki.lib.helpers import flash
+from quickwiki.model import Page, wikiwords
+from quickwiki.model.meta import Session as DBSession
 
 log = logging.getLogger(__name__)
 
-class PageController(BaseController):
+class PagesController(BaseController):
+    
+    def __init__(self):
+        self.page_q = DBSession.query(Page)
 
-    def index(self, title):
-        page_q = Session.query(Page)
-        page = page_q.filter_by(title=title).first()
-        if page:
-            c.content = page.get_wiki_content()
-            return render('/page.mako')
-        elif model.wikiwords.match(title):
-            return render('/new_page.mako')
-        abort(404)
+    def index(self):
+        c.titles = [page.title for page in self.page_q.all()]
+        return render('/pages/index.mako')
 
     def edit(self, title):
-        page_q = Session.query(Page)
-        page = page_q.filter_by(title=title).first()
+        page = self.page_q.filter_by(title=title).first()
         if page:
             c.content = page.content
-        return render('/edit.mako')
+        return render('/pages/edit.mako')
 
+    @authenticate_form
     def save(self, title):
-        page_q = Session.query(Page)
-        page = page_q.filter_by(title=title).first()
+        page = self.page_q.filter_by(title=title).first()
         if not page:
             page = Page()
             page.title = title
-        page.content = request.POST.get('content','')
-        c.title = page.title
-        c.content = page.get_wiki_content()
-        c.message = 'Successfully saved'
-        Session.save_or_update(page)
-        Session.commit()
-        return render('/page.mako')
+        # In a real application, you should validate and sanitize
+        # submitted data throughly! escape is a minimal example here.
+        page.content = escape(request.POST.get('content', ''))
+        DBSession.add(page)
+        DBSession.commit()
+        flash('Successfully saved %s!' % title)
+        redirect_to('show_page', title=title)
 
-    def list(self):
-        c.titles = [page.title for page in Session.query(Page).all()]
-        return render('/list.mako')
+    def show(self, title):
+        page = self.page_q.filter_by(title=title).first()
+        if page:
+            c.content = page.get_wiki_content()
+            return render('/pages/show.mako')
+        elif wikiwords.match(title):
+            return render('/pages/new.mako')
+        abort(404)
 
-    def delete(self):
-        page_q = Session.query(Page)
-        title = request.POST['id']
-        page = page_q.filter_by(title=title).one()
-        Session.delete(page)
-        Session.commit()
-        c.titles = page_q.all()
-        return render('/list-titles.mako')
+    def delete(self, title):
+        page = self.page_q.filter_by(title=title).one()
+        DBSession.delete(page)
+        DBSession.commit()
+        c.titles = self.page_q.all()
+        flash('Deleted %s.' % title)
+        redirect_to('pages')
diff --git a/quickwiki/controllers/template.py b/quickwiki/controllers/template.py
deleted file mode 100644
--- a/quickwiki/controllers/template.py
+++ /dev/null
@@ -1,27 +0,0 @@
-from quickwiki.lib.base import *
-
-class TemplateController(BaseController):
-
-    def view(self, url):
-        """By default, the final controller tried to fulfill the request
-        when no other routes match. It may be used to display a template
-        when all else fails, e.g.::
-
-            def view(self, url):
-                return render('/%s' % url)
-
-        Or if you're using Mako and want to explicitly send a 404 (Not
-        Found) response code when the requested template doesn't exist::
-
-            import mako.exceptions
-
-            def view(self, url):
-                try:
-                    return render('/%s' % url)
-                except mako.exceptions.TopLevelLookupException:
-                    abort(404)
-
-        By default this controller aborts the request with a 404 (Not
-        Found)
-        """
-        abort(404)
diff --git a/quickwiki/lib/app_globals.py b/quickwiki/lib/app_globals.py
--- a/quickwiki/lib/app_globals.py
+++ b/quickwiki/lib/app_globals.py
@@ -1,14 +1,15 @@
 """The application's Globals object"""
-from pylons import config
 
 class Globals(object):
+
     """Globals acts as a container for objects available throughout the
     life of the application
+
     """
 
     def __init__(self):
         """One instance of Globals is created during application
-        initialization and is available during requests via the 'g'
-        variable
+        initialization and is available during requests via the
+        'app_globals' variable
+
         """
-        pass
diff --git a/quickwiki/lib/base.py b/quickwiki/lib/base.py
--- a/quickwiki/lib/base.py
+++ b/quickwiki/lib/base.py
@@ -1,18 +1,11 @@
 """The base Controller API
 
-Provides the BaseController class for subclassing, and other objects
-utilized by Controllers.
+Provides the BaseController class for subclassing.
 """
-from pylons import c, cache, config, g, request, response, session
 from pylons.controllers import WSGIController
-from pylons.controllers.util import abort, etag_cache, redirect_to
-from pylons.decorators import jsonify, validate
-from pylons.i18n import _, ungettext, N_
-from pylons.templating import render
+from pylons.templating import render_mako as render
 
-import quickwiki.lib.helpers as h
-import quickwiki.model as model
-from quickwiki.model import Session
+from quickwiki.model import meta
 
 class BaseController(WSGIController):
 
@@ -24,8 +17,5 @@
         try:
             return WSGIController.__call__(self, environ, start_response)
         finally:
-            Session.remove()
-
-# Include the '_' function in the public names
-__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
-           or __name == '_']
+            meta.Session.remove()
+        
\ No newline at end of file
diff --git a/quickwiki/lib/helpers.py b/quickwiki/lib/helpers.py
--- a/quickwiki/lib/helpers.py
+++ b/quickwiki/lib/helpers.py
@@ -1,6 +1,11 @@
 """Helper functions
 
 Consists of functions to typically be used within templates, but also
-available to Controllers. This module is available to both as 'h'.
+available to Controllers. This module is available to templates as 'h'.
 """
-from webhelpers import *
+from webhelpers.html import escape, HTML, literal, url_escape
+from webhelpers.html.tags import *
+from webhelpers.html.secure_form import secure_form
+from webhelpers.pylonslib import Flash as _Flash
+
+flash = _Flash()
diff --git a/quickwiki/model/__init__.py b/quickwiki/model/__init__.py
--- a/quickwiki/model/__init__.py
+++ b/quickwiki/model/__init__.py
@@ -1,28 +1,32 @@
+"""The application's model objects"""
+import logging
 import re
 import sets
+from docutils.core import publish_parts
 
-from docutils.core import publish_parts
-from pylons import config
-from sqlalchemy import Column, MetaData, Table, types
-from sqlalchemy.orm import mapper
-from sqlalchemy.orm import scoped_session, sessionmaker
+import sqlalchemy as sa
+from sqlalchemy import orm
 
+from pylons import url
+from quickwiki.model import meta
 import quickwiki.lib.helpers as h
 
-# Global session manager for SQLAlchemy. Session() returns the session
-# object appropriate for the current web request.
-Session = scoped_session(sessionmaker(autoflush=True, transactional=True,
-                                      bind=config['pylons.g'].sa_engine))
 
-# Global metadata. If you have multiple databases with overlapping
-# table names, you'll need a metadata for each database.
-metadata = MetaData()
-
+docutils_safety = {'file_insertion_enabled': False, 'raw_enabled': False}
+log = logging.getLogger(__name__)
 wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)", re.UNICODE)
 
-pages_table = Table('pages', metadata,
-    Column('title', types.Unicode(40), primary_key=True),
-    Column('content', types.Unicode(), default='')
+def init_model(engine):
+    """Call me before using any of the tables or classes in the model"""
+    sm = orm.sessionmaker(bind=engine)
+
+    meta.engine = engine
+    meta.Session = orm.scoped_session(sm)
+
+
+pages_table = sa.Table('pages', meta.metadata,
+    sa.Column('title', sa.types.Unicode(40), primary_key=True),
+    sa.Column('content', sa.types.Unicode(), default='')
 )
 
 class Page(object):
@@ -31,13 +35,25 @@
     def __str__(self):
         return self.title
 
+    @orm.validates('title')
+    def validate_title(self, key, title):
+        """Assure that page titles are wikiwords"""
+        if wikiwords.match(title) is None:
+            log.warning("%s: invalid title (%s)" % (self.__class__.__name__,
+                                                    title))
+            raise ValueError("Page title must be a wikiword (CamelCase)")
+        return title
+
     def get_wiki_content(self):
-        content = publish_parts(self.content, writer_name="html")["html_body"]
+        """Convert reStructuredText content to HTML for display, and
+        create links for WikiWords.
+        """
+        content = publish_parts(self.content, writer_name='html',
+                                settings_overrides=docutils_safety)['html_body']
         titles = sets.Set(wikiwords.findall(content))
         for title in titles:
-            title_url = h.url_for(controller='page', action='index',
-                                  title=title)
+            title_url = url(controller='pages', action='show', title=title)
             content = content.replace(title, h.link_to(title, title_url))
         return content
 
-mapper(Page, pages_table)
+orm.mapper(Page, pages_table)
diff --git a/quickwiki/model/meta.py b/quickwiki/model/meta.py
new file mode 100644
--- /dev/null
+++ b/quickwiki/model/meta.py
@@ -0,0 +1,14 @@
+"""SQLAlchemy Metadata and Session object"""
+from sqlalchemy import MetaData
+
+__all__ = ['Session', 'metadata']
+
+# SQLAlchemy database engine.  Updated by model.init_model()
+engine = None
+
+# SQLAlchemy session manager.  Updated by model.init_model()
+Session = None
+
+# Global metadata. If you have multiple databases with overlapping table
+# names, you'll need a metadata for each database
+metadata = MetaData()
diff --git a/quickwiki/public/quick.css b/quickwiki/public/quick.css
--- a/quickwiki/public/quick.css
+++ b/quickwiki/public/quick.css
@@ -2,30 +2,33 @@
   background-color: #888;
   margin: 25px;
 }
-div.content{
+
+div.content {
   margin: 0;
   margin-bottom: 10px;
   background-color: #d3e0ea;
   border: 5px solid #333;
   padding: 5px 25px 25px 25px;
 }
-h1.main{
+
+h1.main {
   width: 100%;
-  border-bottom: 1px solid #000;
 }
+
 p.footer{
   width: 100%;
-  padding-top: 3px;
+  padding-top: 8px;
   border-top: 1px solid #000;
 }
-div#message{
+
+a {
+  text-decoration: none;
+}
+
+a:hover {
+  text-decoration: underline;
+}
+
+div#flash .message {
   color: orangered;
 }
-div#trash{
-  float: right;
-  margin: 0px 20px 20px 20px;
-  background: #eee;
-  border: 2px solid #000;
-  padding: 15px;
-  font-family: sans-serif;
-}
diff --git a/quickwiki/templates/base.mako b/quickwiki/templates/base.mako
--- a/quickwiki/templates/base.mako
+++ b/quickwiki/templates/base.mako
@@ -3,14 +3,26 @@
 <html>
   <head>
     <title>QuickWiki</title>
-    ${h.stylesheet_link_tag('/quick.css')}
-    ${h.javascript_include_tag('/javascripts/effects.js', builtins=True)}
+    ${h.stylesheet_link('/quick.css')}
   </head>
+
   <body>
     <div class="content">
+      <h1 class="main">${self.header()}</h1>
+      
+      <% flashes = h.flash.pop_messages() %>
+      % if flashes:
+        % for flash in flashes:
+        <div id="flash">
+          <span class="message">${flash}</span>
+        </div>
+        % endfor
+      % endif
+      
       ${next.body()}\
+      
       <p class="footer">
-      ${footer(request.environ['pylons.routes_dict']['action'])}\
+      ${self.footer(request.environ['pylons.routes_dict']['action'])}\
       </p>
     </div>
   </body>
@@ -18,12 +30,12 @@
 
 ## Don't show links that are redundant for particular pages
 <%def name="footer(action)">\
-  Return to the ${h.link_to('FrontPage', h.url_for(action="index", title="FrontPage"))}
-  % if action == "list":
+  Return to the ${h.link_to('FrontPage', url('home'))}
+  % if action == "index":
     <% return '' %>
   % endif
-  % if action != "edit":
-    | ${h.link_to('Edit '+c.title, h.url_for(title=c.title, action='edit'))}
+  % if action != 'edit':
+    | ${h.link_to('Edit ' + c.title, url('edit_page', title=c.title))}
   % endif
-  | ${h.link_to('Title List', h.url_for(action='list', title=None))}
+  | ${h.link_to('Title List', url('pages'))}
 </%def>
diff --git a/quickwiki/templates/list-titles.mako b/quickwiki/templates/list-titles.mako
deleted file mode 100644
--- a/quickwiki/templates/list-titles.mako
+++ /dev/null
@@ -1,7 +0,0 @@
-% for title in c.titles:
-<li>
-  <span id="${unicode(title)}">${title}</span>
-  &nbsp;[${h.link_to('visit', h.url_for(title=title, action="index"))}]
-  ${h.draggable_element(unicode(title), revert=True)}
-</li>
-% endfor
diff --git a/quickwiki/templates/edit.mako b/quickwiki/templates/pages/edit.mako
rename from quickwiki/templates/edit.mako
rename to quickwiki/templates/pages/edit.mako
--- a/quickwiki/templates/edit.mako
+++ b/quickwiki/templates/pages/edit.mako
@@ -1,8 +1,8 @@
-<%inherit file="base.mako"/>
+<%inherit file="/base.mako"/>\
 
-<h1 class="main">Editing ${c.title}</h1>
+<%def name="header()">Editing ${c.title}</%def>
 
-${h.start_form(h.url_for(action='save', title=c.title), method="post")}
-  ${h.text_area(name='content', rows=7, cols=40, content=c.content)} <br />
-  ${h.submit(value="Save changes", name='commit')}
+${h.secure_form(url('save_page', title=c.title))}
+  ${h.textarea(name='content', rows=7, cols=40, content=c.content)} <br />
+  ${h.submit(value='Save changes', name='commit')}
 ${h.end_form()}
diff --git a/quickwiki/templates/list.mako b/quickwiki/templates/pages/index.mako
rename from quickwiki/templates/list.mako
rename to quickwiki/templates/pages/index.mako
--- a/quickwiki/templates/list.mako
+++ b/quickwiki/templates/pages/index.mako
@@ -1,11 +1,11 @@
-<%inherit file="base.mako"/>
+<%inherit file="/base.mako"/>\
 
-<h1 class="main">Title List</h1>
-<div id="trash">
-  Delete a page by dragging its title here
-</div>
-${h.drop_receiving_element("trash", update="titles", url=h.url_for(action="delete"))}
+<%def name="header()">Title List</%def>
 
 <ul id="titles">
-  <%include file="list-titles.mako"/>
+  % for title in c.titles:
+  <li>
+    ${title} [${h.link_to('visit', url('show_page', title=title))} - ${h.link_to('delete', url('delete_page', title=title))}]
+  </li>
+  % endfor
 </ul>
diff --git a/quickwiki/templates/new_page.mako b/quickwiki/templates/pages/new.mako
rename from quickwiki/templates/new_page.mako
rename to quickwiki/templates/pages/new.mako
--- a/quickwiki/templates/new_page.mako
+++ b/quickwiki/templates/pages/new.mako
@@ -1,6 +1,7 @@
-<%inherit file="base.mako"/>  
+<%inherit file="/base.mako"/>\
 
-<h1 class="main">${c.title}</h1>
+<%def name="header()">${c.title}</%def>
+
 <p>This page doesn't exist yet.
-  <a href="${h.url_for(action='edit', title=c.title)}">Create the page</a>.
+  <a href="${url('edit_page', title=c.title)}">Create the page</a>.
 </p>
diff --git a/quickwiki/templates/page.mako b/quickwiki/templates/pages/show.mako
rename from quickwiki/templates/page.mako
rename to quickwiki/templates/pages/show.mako
--- a/quickwiki/templates/page.mako
+++ b/quickwiki/templates/pages/show.mako
@@ -1,7 +1,5 @@
-<%inherit file="base.mako"/>
+<%inherit file="/base.mako"/>\
 
-<h1 class="main">${c.title}</h1>
-% if c.message:
-<p><div id="message">${c.message}</div></p>
-% endif
-${c.content}
+<%def name="header()">${c.title}</%def>
+
+${h.literal(c.content)}
diff --git a/quickwiki/tests/__init__.py b/quickwiki/tests/__init__.py
--- a/quickwiki/tests/__init__.py
+++ b/quickwiki/tests/__init__.py
@@ -1,40 +1,36 @@
 """Pylons application test package
 
-When the test runner finds and executes tests within this directory,
-this file will be loaded to setup the test environment.
+This package assumes the Pylons environment is already loaded, such as
+when this script is imported from the `nosetests --with-pylons=test.ini`
+command.
 
-It registers the root directory of the project in sys.path and
-pkg_resources, in case the project hasn't been installed with
-setuptools. It also initializes the application via websetup (paster
-setup-app) with the project's test.ini configuration file.
+This module initializes the application via ``websetup`` (`paster
+setup-app`) and provides the base testing objects.
 """
-import os
-import sys
 from unittest import TestCase
 
-import pkg_resources
-import paste.fixture
-import paste.script.appinstall
 from paste.deploy import loadapp
-from routes import url_for
+from paste.script.appinstall import SetupCommand
+from pylons import config, url
+from routes.util import URLGenerator
+from webtest import TestApp
 
-__all__ = ['url_for', 'TestController']
+import pylons.test
 
-here_dir = os.path.dirname(os.path.abspath(__file__))
-conf_dir = os.path.dirname(os.path.dirname(here_dir))
+__all__ = ['environ', 'url', 'TestController']
 
-sys.path.insert(0, conf_dir)
-pkg_resources.working_set.add_entry(conf_dir)
-pkg_resources.require('Paste')
-pkg_resources.require('PasteScript')
+# Invoke websetup with the current config file
+SetupCommand('setup-app').run([config['__file__']])
 
-test_file = os.path.join(conf_dir, 'test.ini')
-cmd = paste.script.appinstall.SetupCommand('setup-app')
-cmd.run([test_file])
+environ = {}
 
 class TestController(TestCase):
 
     def __init__(self, *args, **kwargs):
-        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
-        self.app = paste.fixture.TestApp(wsgiapp)
+        if pylons.test.pylonsapp:
+            wsgiapp = pylons.test.pylonsapp
+        else:
+            wsgiapp = loadapp('config:%s' % config['__file__'])
+        self.app = TestApp(wsgiapp)
+        url._push_object(URLGenerator(config['routes.map'], environ))
         TestCase.__init__(self, *args, **kwargs)
diff --git a/quickwiki/tests/functional/test_page.py b/quickwiki/tests/functional/test_pages.py
rename from quickwiki/tests/functional/test_page.py
rename to quickwiki/tests/functional/test_pages.py
--- a/quickwiki/tests/functional/test_page.py
+++ b/quickwiki/tests/functional/test_pages.py
@@ -1,6 +1,8 @@
 from quickwiki.tests import *
 
-class TestPageController(TestController):
+class TestPagesController(TestController):
+
     def test_index(self):
-        response = self.app.get(url_for(controller='page'))
-        # Test response...
+        response = self.app.get(url(controller='pages', action='index'))
+        self.assert_('Title List' in response)
+        self.assert_('FrontPage' in response)
diff --git a/quickwiki/websetup.py b/quickwiki/websetup.py
--- a/quickwiki/websetup.py
+++ b/quickwiki/websetup.py
@@ -1,31 +1,28 @@
 """Setup the QuickWiki application"""
 import logging
 
-from paste.deploy import appconfig
-from pylons import config
-
 from quickwiki.config.environment import load_environment
 
 log = logging.getLogger(__name__)
 
-def setup_config(command, filename, section, vars):
+def setup_app(command, conf, vars):
     """Place any commands to setup quickwiki here"""
-    conf = appconfig('config:' + filename)
     load_environment(conf.global_conf, conf.local_conf)
+
+    # Load the models
+    from quickwiki.model import meta
+    meta.metadata.bind = meta.engine
+
+    # Create the tables if they aren't there already
+    log.info("Creating tables...")
+    meta.metadata.create_all(checkfirst=True)
+    log.info("Successfully set up.")
     
-    # Populate the DB on 'paster setup-app'
     import quickwiki.model as model
-
-    log.info("Setting up database connectivity...")
-    engine = config['pylons.g'].sa_engine
-    log.info("Creating tables...")
-    model.metadata.create_all(bind=engine)
-    log.info("Successfully set up.")
-
     log.info("Adding front page data...")
     page = model.Page()
-    page.title = 'FrontPage'
-    page.content = 'Welcome to the QuickWiki front page.'
-    model.Session.save(page)
-    model.Session.commit()
+    page.title = u'FrontPage'
+    page.content = u'Welcome to the QuickWiki front page.'
+    meta.Session.add(page)
+    meta.Session.commit()
     log.info("Successfully set up.")
diff --git a/setup.cfg b/setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -5,36 +5,8 @@
 [easy_install]
 find_links = http://www.pylonshq.com/download/
 
-[pudge]
-theme = pythonpaste.org
-
-# Add extra doc files here with spaces between them
-docs = docs/index.txt
-
-# Doc Settings
-doc_base = docs/
-dest = docs/html
-
-# Add extra modules here separated with commas
-modules = quickwiki
-title = Quickwiki
-organization = Pylons
-
-# Highlight code-block sections with Pygments
-highlighter = pygments
-
-# Optionally add extra links
-#organization_url = http://pylonshq.com/
-#trac_url = http://pylonshq.com/project
-settings = no_about=true
-
-# Optionally add extra settings
-#           link1=/community/ Community
-#           link2=/download/ Download
-
-[publish]
-doc-dir=docs/html
-make-dirs=1
+[nosetests]
+with-pylons = test.ini
 
 # Babel configuration
 [compile_catalog]
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,12 +7,17 @@
 
 setup(
     name='QuickWiki',
-    version="0.1.5",
-    description="QuickWiki - Pylons 0.9.6 Tutorial application",
-    #author="",
-    #author_email="",
-    url="http://wiki.pylonshq.com/display/pylonsdocs/QuickWiki+Tutorial",
-    install_requires=["Pylons>=0.9.6", "docutils==0.4", "SQLAlchemy>=0.4.1"],
+    version='0.1.6',
+    description='QuickWiki - Pylons 0.9.7 Tutorial application',
+    #author='',
+    #author_email='',
+    url='http://docs.pylonshq.com/tutorials/quickwiki_tutorial.html',
+    install_requires=[
+        "Pylons>=0.9.7",
+        "SQLAlchemy==0.5.0rc4",
+        "docutils==0.4"
+    ],
+    setup_requires=["PasteScript>=1.6.3"],
     packages=find_packages(exclude=['ez_setup']),
     include_package_data=True,
     test_suite='nose.collector',
@@ -21,6 +26,8 @@
     #        ('**.py', 'python', None),
     #        ('templates/**.mako', 'mako', None),
     #        ('public/**', 'ignore', None)]},
+    zip_safe=False,
+    paster_plugins=['PasteScript', 'Pylons'],
     entry_points="""
     [paste.app_factory]
     main = quickwiki.config.middleware:make_app
diff --git a/test.ini b/test.ini
--- a/test.ini
+++ b/test.ini
@@ -19,3 +19,4 @@
 use = config:development.ini
 
 # Add additional test specific configuration options as necessary.
+sqlalchemy.url = sqlite:///:memory:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.