/usr/share/doc/python-myghty/html/documentation.html is in python-myghty 1.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 | <html>
<head>
<title>
Myghty Documentation
</title>
<link href="style.css" rel="stylesheet" type="text/css"></link>
<link href="syntaxhighlight.css" rel="stylesheet" type="text/css"></link>
</head>
<body>
<link href="docs.css" rel="stylesheet" type="text/css"></link>
<div style="position:absolute;left:0px;top:0px;"><a name="top"></a> </div>
<div class="doccontainer">
<div class="docheader">
<div class="docheadertext" >Myghty Documentation</div>
<div class="">Version: 1.1 Last Updated: 09/10/06 19:32:29</div>
</div>
<div class="maintoc">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<a name="table_of_contents"></a>
<span class="docheadertext">Table of Contents</span>
<a href="#full_index">(view full table)</a>
<br/><br/>
<div style="margin-left:50px;">
<b>Introduction</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#whatdoesitdo">What does Myghty Do?</a>
</div>
</div>
<b>Setting Up</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#installation">Installation</a>
</div>
<div class="toclink">
<A style="" href="#configuration">Configuration</a>
</div>
<div class="toclink">
<A style="" href="#configuration_programmatic">Programmatic Configuration</a>
</div>
</div>
<b>The Myghty Environment</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#embedding">Embedding Python in HTML</a>
</div>
<div class="toclink">
<A style="" href="#scopedpython">Scoped <%python> Blocks</a>
</div>
<div class="toclink">
<A style="" href="#globals">Standard Global Variables</a>
</div>
<div class="toclink">
<A style="" href="#components">Components</a>
</div>
<div class="toclink">
<A style="" href="#modulecomponents">Module Components</a>
</div>
<div class="toclink">
<A style="" href="#request">The Request</a>
</div>
<div class="toclink">
<A style="" href="#otherblocks">Other Blocks</a>
</div>
<div class="toclink">
<A style="" href="#inheritance">Inheritance</a>
</div>
<div class="toclink">
<A style="" href="#specialtempl">Special Templates</a>
</div>
</div>
<b>Additional Features</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#filtering">Filtering and Flushing (and Escaping)</a>
</div>
<div class="toclink">
<A style="" href="#session">Session</a>
</div>
<div class="toclink">
<A style="" href="#caching">Data Caching</a>
</div>
<div class="toclink">
<A style="" href="#resolver">Advanced Resolver Configuration</a>
</div>
<div class="toclink">
<A style="" href="#unicode">Unicode Support</a>
</div>
</div>
<b>Appendix</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#parameters">Index of Configuration Parameters</a>
</div>
<div class="toclink">
<A style="" href="#technical">Myghty Guts (tech description)</a>
</div>
<div class="toclink">
<A style="" href="#docstrings">Modules and Classes</a>
</div>
</div>
</div>
</div>
<div class="maintoc">
<a name="full_index"></a>
<span class="docheadertext">Table of Contents: Full</span>
<a href="#table_of_contents">(view brief table)</a>
<br/><br/>
<div style="margin-left:50px;">
<b>Introduction</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#whatdoesitdo">What does Myghty Do?</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_psp">High Performance Python Server Pages (PSP)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_components">Componentized Development</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_modulecomponents">Module Components</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_inheritance">Page Inheritance</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_performance">Performance</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#whatdoesitdo_other">Other Features</a>
</div>
</div>
</div>
</div>
<b>Setting Up</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#installation">Installation</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_requirements">Requirements</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_quick">Quick Start - Running the Demo Server</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_install">Installing the Library</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_docgen">Generating the Documentation</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_paste">Running Paste Templates</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#installation_componentgen">Running Filesystem Components</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#configuration">Configuration</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_standalone">Standalone Handler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_cgi">CGI</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_mod_python">mod_python</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_mod_python_multiple">Advanced mod_python Configuration - Multiple ApacheHandlers</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#configuration_programmatic">Programmatic Configuration</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler">Chaining to HTTPHandler</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_ApacheHandler">ApacheHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_CGIHandler">CGIHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_WSGIHandler">WSGIHandler</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_interpreter">Chaining to Interpreter</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_interpreter_standalone">Configuring a Standalone Application</a>
</div>
</div>
</div>
</div>
</div>
<b>The Myghty Environment</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#embedding">Embedding Python in HTML</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_control">Control Lines</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_comment">Comment Lines</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_substitutions">Substitutions</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_blocks">Python Blocks</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_whitespace">Controlling Whitespace with the Backslash</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#embedding_indentation">Indentation Behavior</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#scopedpython">Scoped <%python> Blocks</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_component">Component Scope</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_global">Global Scope</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_init">Init Scope</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_cleanup">Cleanup Scope</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_request">Request Scope</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_request_value">Using Pass-By-Value</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_request_alternative">Alternative - Request Attributes</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_thread">Thread Scope</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_thread_threadlocal">Alternative to Thread Scope: ThreadLocal()</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#globals">Standard Global Variables</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalm">Your Best Friend: <i>m</i></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalargs">Your Other Best Friend: <i>ARGS</i></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalr">Your Pal: <i>r</i></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globals">Your Fair Weather Friend: <i>s</i></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalcustom">Make your Own Friends</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalcustom_assignment">Assignment to Request-Scoped Globals</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#components">Components</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_example">Component Calling Example</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_pathscheme">Component Path Scheme</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_args">Component Arguments - the <%args> tag</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_args_argscope">Argument Scope: component/request/subrequest/dynamic</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_subcomponent">How to Define a Subcomponent</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_subcomponent_calling">Calling a Subcomponent</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_method">How to Define a Method</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_method_calling">Calling a Method</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_closure">How to Define a Closure</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_flags">Subcomponent Flags</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_callwithcontent">Component Calls with Content</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic">Calling Components Programmatically</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_comp">m.comp(component, **params)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_scomp">m.scomp(component, **params)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_subrequests">Subrequests</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_callself">call_self(buffer, retval)</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_methods">Component Methods</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_members">Component Members</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#modulecomponents">Module Components</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_example">Example Module Component</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor">Flavors of Module Component</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_function">Function</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_callable">Callable Object</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_method">Object Method</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_explicit">Class / Explicit Module Component</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_initialization">Module Component Initialization</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_controller">Using MCs as Controllers</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution">Configuring Module Component Resolution</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_components">module_components</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_root">module_root</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_routesresolver">Routes Resolver</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_preprocessor">Module Component Pre and Post processing</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_templates">Using Module Components within Templates</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_templates_formexample">Example: Form Visitor</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#request">The Request</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#request_methods">Request Methods</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#request_members">Request Members</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#otherblocks">Other Blocks</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#otherblocks_flags"><%flags></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#otherblocks_attr"><%attr></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#otherblocks_text"><%text></a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#otherblocks_doc"><%doc></a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#inheritance">Inheritance</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#inheritance_wrapper">The Wrapper Chain</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#inheritance_example">Example - Basic Wrapping</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#inheritance_basecomp">The Base Component</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#inheritance_method">Method and Attribute Inheritance</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#inheritance_methodexample">Method Inheritance Example</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#specialtempl">Special Templates</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#specialtempl_autohandler">autohandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#specialtempl_dhandler">dhandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#specialtempl_modulecomponents">Using Module Components for autohandler/dhandler</a>
</div>
</div>
</div>
</div>
<b>Additional Features</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#filtering">Filtering and Flushing (and Escaping)</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_autoflush">The Autoflush Option</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_autoflush_subcomponents">Setting Autoflush in Subcomponents</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_autoflush_autohandlers">Non-Buffered with Autohandlers</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering">Filtering</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_filter">The <%filter> Tag</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_escapefilter">Escaping Content in a Filter Section</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_filterflush">Filtering Behavior with Autoflush Enabled</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_trim">Filtering Whitespace - the Trim Flag</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping">Escaping Content</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_substitutions">Escaping Substitutions</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_programmatic">Programmatic Escaping</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_custom">Custom Escape Flags</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_custom">Default Escape Flags</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#session">Session</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#session_usage">Basic Usage</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#session_options">Session Options</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#session_methods">Session Methods</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#session_members">Session Members</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#session_object">Using the Session Object Standalone</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#caching">Data Caching</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#caching_component">Caching a Component's Output</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#caching_interface">Programmatic Interface</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#caching_details">More on Caching</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#caching_options">Cache Options</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#caching_types">Cache Types</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#resolver">Advanced Resolver Configuration</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_intro">Introduction</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_step1">Basic Example</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_realthing">The Real Set of Rules</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_conditionals">Conditionals, Groups and ConditionalGroups</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_context">Resolver Contexts</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_logging">Resolution Logging</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_custom">Custom Rules</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_custom_installing">Installing the Rule</a>
</div>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#unicode">Unicode Support</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#unicode_unicode_writes">What You Can Give to m.write() (and m.apply_escapes())</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#unicode_magic_comment">The Magic Encoding Comment</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#unicode_output_encoding">Controlling the Output Encoding</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#unicode_details">Other Details</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#unicode_disabling">Disabling Unicode Support</a>
</div>
</div>
</div>
</div>
<b>Appendix</b><br/>
<div class="tocsection">
<div class="toclink">
<A style="" href="#parameters">Index of Configuration Parameters</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#technical">Myghty Guts (tech description)</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_goals">Design Goals</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_templates">Approaches to Templating</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_generation">Generating Python Modules</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_request">Handling a Request</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules">Modules</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_request">request</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_interp">interp</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_lexer">lexer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_compiler">compiler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_objgen">objgen</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_component">component</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_resolver">resolver</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_escapes">escapes</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_buffer">buffer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_HTTPHandler">HTTPHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_util">util</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_synchronizer">synchronizer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_cache">cache</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_container">container</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_exception">exception</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_differences">Differences from HTML::Mason</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings">Modules and Classes</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.request">Module myghty.request</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.request_modfunc">Module Functions</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.request_Request">Class Request(object)</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component">Module myghty.component</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_Component">Class Component(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_FileComponent">Class FileComponent(Component)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_HTTPModuleComponent">Class HTTPModuleComponent(ModuleComponent)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_ModuleComponent">Class ModuleComponent(Component)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_SubComponent">Class SubComponent(Component)</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.interp">Module myghty.interp</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.interp_Interpreter">Class Interpreter</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver">Module myghty.resolver</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_AdjustedResolveFile">Class AdjustedResolveFile(ResolveFile)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Conditional">Class Conditional(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ConditionalGroup">Class ConditionalGroup(Conditional)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Group">Class Group(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_NotFound">Class NotFound(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_PathTranslate">Class PathTranslate(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveDhandler">Class ResolveDhandler(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveFile">Class ResolveFile(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveModule">Class ResolveModule(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolvePathModule">Class ResolvePathModule(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveUpwards">Class ResolveUpwards(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Resolver">Class Resolver(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolverRule">Class ResolverRule(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_URICache">Class URICache(ResolverRule)</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource">Module myghty.csource</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ComponentSource">Class ComponentSource(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_FileComponentSource">Class FileComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_MemoryComponentSource">Class MemoryComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ModuleComponentSource">Class ModuleComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ModuleComponentSourceSingleton">Class ModuleComponentSourceSingleton(type)</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session">Module myghty.session</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_MyghtySessionArgs">Class MyghtySessionArgs</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_Session">Class Session</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_SignedCookie">Class SignedCookie(BaseCookie)</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="onepagecontent">
<div class="section">
<A name="whatdoesitdo"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Next: <a href="#installation">Installation</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">What does Myghty Do?</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#whatdoesitdo_psp">High Performance Python Server Pages (PSP)</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#whatdoesitdo_components">Componentized Development</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#whatdoesitdo_modulecomponents">Module Components</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#whatdoesitdo_inheritance">Page Inheritance</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#whatdoesitdo_performance">Performance</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#whatdoesitdo_other">Other Features</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Heres a rundown of what Myghty is about, touching upon the basic features one would expect in a template system, as well as the unique features Myghty provides.
</p>
</div>
<A name="whatdoesitdo_psp"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">High Performance Python Server Pages (PSP)</span>
<div class="sectiontext">
<p>Myghty's primary feature is it's <b>Python Server Page (PSP)</b> system. Individual templates are generated into pure Python modules which become the method of serving the content. Myghty creates real Python modules from templates, which are regular .py files with corresponding .pyc bytecode files. These modules can also be generated in memory only, if desired.</p>
<p>Myghty templates allow full Python syntax to be embedded amongst HTML or other markup, and keeps intact the <b>full syntax and indentation scheme</b> of Python, even within very markup-interactive sections of code. Myghty also lets you organize embedded Python code in ways that minimize its intrusion upon markup. Python embedded within markup is clearly denoted via <%python> tags or the more interactive "%" syntax:</p>
<div class="code">
<pre><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">somefunc</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_keyword">return </span><span class="python_name">True</span><span class="python_operator">
</span> <span class="blocktag"></%python></span><span class="text">
% if somefunc():
<p>
hello!
</p>
% # end for</span></pre></div>
<p>Read more about Myghty syntax in <a href="#embedding" >Embedding Python in HTML</a>.</p>
<p>
Python sections can optionally have scope attributes specified, with values such as "global", "request", "init" and "cleanup", which cause the contained python code to execute at specific points in the template's execution, regardless of where they are placed in the template. This allows flexible organization of template code and a very distinct separation of Python and markup. Read more about Myghty code scope in <a href="#scopedpython" >Scoped <%python> Blocks</a>.</p>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<A name="whatdoesitdo_components"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Componentized Development</span>
<div class="sectiontext">
<p>Myghty allows you to organize Python code and markup into smaller sub-units of a page called <b>Components</b>. Consider a page like this:</p>
<pre>
+--------------------+
| | toolbar |
| +---------------|
| header |
|--------------------|
| | |
| left | |
| nav | content |
| | |
| | |
|--------------------|
| footer |
+--------------------+
</pre>
<p>Each subsection of this page is a likely candidate to be its own <b>component</b>. The overall template is referred to as the <b>top-level component</b>, and contains any number of <b>subcomponents</b>, which are effectively semi-autonomous units of code within a larger template file. They have their own namespaces, passed-in argument lists, buffering and caching attributes, etc. Components normally send their output to the current output stream, but can also be called as Python functions with return values, or their output content can be grabbed into a string as the return value.</p>
<p>All components are capable of calling any other component within the same template, and also of calling another template to be executed inline, or even the subcomponents contained within other templates, which are known as <b>methods</b>. With these functions, the page above can be organized into any variety of HTML/python code-snippets either within a single template file or across any combination of template and/or method library files:</p>
<pre>
components.myt
+-----------------+
| | page.myt
| | header.myt +---------------+
| +-----------+ | +---------------+ | ********** |
| | toolbar |--------------->***** |------> ********** |
| +-----------+ | | header | | |
| | +---------------+ | ** |
| +------+ | | ** page |
| | | | | ** content |
| | left | ------------------------------->** |
| | nav | | | ** |
| | | | | |
| +------+ | | +-----------+ |
| | | | footer | |
+-----------------+ | +-----------+ |
+---------------+
</pre>
<p>Components are called via the <& &> tag construct, and also support "open-tag/close-tag" behavior via the <&| &></&> syntax, known as a <b>component call with content</b>. The content within the tags is enclosed into its own Python function that is callable by the component code, allowing custom tags with full control of execution to be created.
</p>
<p>Read more about Myghty components in <a href="#components" >Components</a>.</p>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<A name="whatdoesitdo_modulecomponents"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module Components</span>
<div class="sectiontext">
<p>Myghty introduces a convenient environment-agnostic way to mix regular Python modules with template code known as Module Components. The same component model that applies to templates can be applied to regular Python objects and functions, either by explicitly subclassing the ModuleComponent class in a manner similar to a Servlet, or by configuring Myghty to implicitly resolve any regular Python function, callable object, or plain object instance into a FunctionComponent (version 0.98).</p>
<p>Module Components serve primarily as the "controller" stage in a request, the initial entry point for a request that handles data loading and state changes, and then passes control onto a template for display. As they are also fully capable component objects, they can also just as easily be embedded within templates, either by themselves or wrapped around further sub-content, to allow the creation of module-based tag libraries.</p>
<p>A big advantage to using Module Components for controller code is that the application remains completely portable to any environment, including mod_python, any WSGI environment, or non-web oriented environments.</p>
<p>Read more about Myghty Module Components in <a href="#modulecomponents" >Module Components</a>.</p>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<A name="whatdoesitdo_inheritance"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Page Inheritance</span>
<div class="sectiontext">
<p>Any top level component can also be <b>inherited</b> by another top level component. This means the execution of pages can be implicitly or explicitly "wrapped" by an enclosing template, which can control the execution and content embedding of its "subtemplate" at any point in its execution. In the diagram below, a content-based HTML file is enclosed by a file providing a standardized layout, which is enclosed by another file that provides session authentication code and management:
</p>
<pre>
/lib/authenticate.myt
+------------------+
|% authenticate() |
|------------------- /autohandler
| | +-----------------+
| | header | /foo/content.myt
| |-----------------| +--------+
| m.call_next() ---> | | |
| | m.call_next() ---> |content |
| | | |
| | |-----------------| +--------+
|------------------| | footer |
|% cleanup() | +-----------------+
+------------------+
</pre>
<p>The methods of a parent template are also inherited by the child and can also be overridden, allowing a sub-template to change the behavior of its parent. Layout and behavior of individual groups of templates, directories, or entire sites can be managed through a concise and centralized group of inheritable templates.
</p>
<p>Read more about Inheritance in <a href="#inheritance" >Inheritance</a>.</p>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<A name="whatdoesitdo_performance"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Performance</span>
<div class="sectiontext">
<p>Myghty is written with fast performance and highly concurrent service in mind. A flexible cache API, supporting in-memory, file, DBM and Memcached backends allows quick re-delivery of complicated pages. Buffering can be completely disabled, for an entire site or just individual pages, to send template output to directly to the client. Expensive cache and compilation operations are process- and thread-synchronized to prevent data corruption and redundant computation. A configurable least-recently-used cache holds only the most heavily used components in memory, deferring less used ones to be loaded again from .pyc files. Filesystem checks can be disabled as well, allowing complete in-memory operation. Large chunks of plain text are distilled into large, multi-line write() statements to minimize method call overhead for large and mostly static pages.</p>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<A name="whatdoesitdo_other"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Other Features</span>
<div class="sectiontext">
<ul>
<li> Session object support - can write session data into memory, plain or DBM files, or Memcached.
<li> Direct connectors for mod_python, CGI, WSGI, Python Paste, SimpleHTTPServer. As the Interpreter object is a lightweight object with no external dependencies whatsoever, any Python application or application server can invoke any series of Myghty components with just one line of code.
<li> A super-configurable ruleset driven URI resolution architecture allowing many options for resolving URI's both externally and within templates. Allows any combination of resolution directly to templates, Module Components, or any plain Python function or object instance. Special rules exist to route non-existent URI's to specific components, to cache the results of URI resolution for higher performance, and to execute conditionally based on contextual information.
<li>Cache API and implementation, can cache component output and any other data structure in memory, in plain files, DBM files, or Memcached. Includes a "busy lock" feature that allows a slow re-generation method to execute while the old data continues to be returned to other threads and processes. New cache implementations can be added fairly easily.
<li> Flexible global namespaces allow components to have any number of custom "global" variables.
<li> Special code blocks allow the construction of code that is local to the current request, or local to the current thread. A ThreadLocal object is supplied as well for safe management of thread-sensitive resources such as databases.
<li> Fine grained control of buffering - the buffering of textual output as it is delivered to the client can controlled at the application, page, or component level.
<li> Custom filtering functions can be defined for the output any component, within the source of the component via the <%filter> tag.
<li> Full featured error handling and reporting. errors can be logged to the Apache logs or standard error, caught by application code, and/or reported to the browser screen. stack traces are delivered showing original template line numbers.
</ul>
</div>
<a href="#whatdoesitdo" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="installation"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#whatdoesitdo">What does Myghty Do?</a>
|
Next: <a href="#configuration">Configuration</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Installation</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#installation_requirements">Requirements</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#installation_quick">Quick Start - Running the Demo Server</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#installation_install">Installing the Library</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#installation_docgen">Generating the Documentation</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#installation_paste">Running Paste Templates</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#installation_componentgen">Running Filesystem Components</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
</div>
<A name="installation_requirements"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Requirements</span>
<div class="sectiontext">
<ul>
<li>Python 2.3.3 or greater. There is an issue with weakrefs (Python bug id <a href="http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=839548">839548</a>) prior to that version which impacts stability.
<li>For production webserver usage, a server environment that supports one of: CGI, WSGI, or mod_python.
<li>For mod_python usage, Apache 1.3/mod_python 2.7 (or greater) or Apache 2.0/mod_python 3.1 (or greater).
<li>Tested platforms: Linux (RedHat 6.2, RedHat 9), Mac OSX, Solaris, Windows 2000. Prefork and worker MPMs tested on Apache 2.0.
<li>Familiarity with the webserver being used and whatever plug-in architecture being used.
</ul>
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<A name="installation_quick"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Quick Start - Running the Demo Server</span>
<div class="sectiontext">
<p>Myghty includes an out-of-the-box instant-gratification examples/documentation server you can run directly from the distribution files, which listens on port 8000 by default. Extract the distribution from its .tar.gz file. Then run the server as follows:</p>
<div class="code">
<pre>cd /path/to/Myghty-X.XX/
python ./tools/run_docs.py</pre></div>
<p>
Then point a webbrowser to the location <span class="codeline"><a href="http://localhost:8000/">http://localhost:8000/</a>.</span> An alternative port can be specified on the command line, e.g. <span class="codeline">python ./tools/run_docs.py 8100</span>.
</p>
<p>The demo server is a handy tool to browse through a release without having to perform an install. The underlying HTTP server implementation can also be handy for development and prototyping.</p>
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<A name="installation_install"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Installing the Library</span>
<div class="sectiontext">
<p>Myghty now installs with <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>, which is the next generation of the standard Python <span class="codeline">distutils</span> module. Its basic usage is the same as that of distutils. Switch to the user account under which Python is installed, and run:
<div class="code">
<pre>cd /path/to/Myghty-X.XX/
python setup.py install</pre></div>
As some systems may have multiple Python interpreters installed, be sure to use the Python executeable that corresponds to the Python being used by the webserver, such as the mod_python configuration, to insure the files go into the correct library path. setup.py will precompile the Myghty .py files and install them in the library path for the Python executeable you just ran. </p>
<p>This installer also installs Myghty in a version-specific location, such as "site-packages/Myghty-0.99-py2.3.egg/". If you have installed a version of Myghty prior to 0.99, the <span class="codeline">distutils</span>-based installation, which lives in "site-packages/myghty", will produce a conflict message when running setup.py. After installation, you should delete the old install, either manually or via the command <span class="codeline">python ez_setup.py -D myghty</span>.
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<A name="installation_docgen"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Generating the Documentation</span>
<div class="sectiontext">
<p>
This documentation can also be generated into flat html files that are browseable directly from the filesystem. Myghty can create these files by running the <span class="codeline">genhtml.py</span> utility:</p>
<div class="code">
<pre>cd /path/to/Myghty-X.XX/doc
python genhtml.py</pre></div>
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<A name="installation_paste"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Running Paste Templates</span>
<div class="sectiontext">
<p>Myghty now includes a few <a href="http://www.pythonpaste.org">Python Paste</a> templates, which are pre-built Myghty applications that can install themselves into a runnable application. Python 2.4 is required to run Python Paste. </p>
<p>Myghty's standard install procedure will automatically download and install all Python Paste components, which are also available at <a href="http://pythonpaste.org/download">http://pythonpaste.org/download</a>. Also required is WSGIUtils, which must be installed from a particular .egg file format, via:</p>
<div class="code">
<pre>python ez_setup.py http://pylons.groovie.org/files/WSGIUtils-0.6-py2.4.egg</pre></div>
<p>When Python Paste is installed, it will install the script "paster" into the standard Python scripts location. Insure that this location is in your path. Then to set up a Paste Template, just do:</p>
<div class="code">
<pre>cd /target/directory
paster create --template=myghty_simple myproject
cd myproject
paster serve server.conf</pre></div>
<p>The <span class="codeline">myghty_simple</span> template is a very small four-template configuration, which will by default listen on port 8080. Also included is <span class="codeline">myghty_modulecomponent</span>, which shows off a more controller-oriented configuration, and <span class="codeline">myghty_routes</span>, which builds a new Rails-like "Routes" configuration. </p>
<p>When a new Paste Template project is created, the file <span class="codeline"><projectname>/server.conf</span> illustrates the general Paste options, such as the server listening port. Myghty-specific configuration information is in <span class="codeline"><projectname>/<projectname>/webconfig.py</span>.
</p>
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<A name="installation_componentgen"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Running Filesystem Components</span>
<div class="sectiontext">
<p>There is also a generic tool for running any Myghty template either to standard output or to a file. The command is as follows:</p>
<div class="code">
<pre>python tools/gen.py --help
usage: gen.py [options] files...
options:
-h, --help show this help message and exit
--croot=COMPONENT_ROOT
set component root (default: ./)
--dest=DESTINATION set destination directory (default: ./)
--stdout send output to stdout
--datadir=DATADIR set data directory (default: dont use data directory)
--ext=EXTENSION file extension for output files (default: .html)
--source generate the source component to stdout</pre></div>
</div>
<a href="#installation" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="configuration"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#installation">Installation</a>
|
Next: <a href="#configuration_programmatic">Programmatic Configuration</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Configuration</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#configuration_standalone">Standalone Handler</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#configuration_cgi">CGI</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#configuration_mod_python">mod_python</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_mod_python_multiple">Advanced mod_python Configuration - Multiple ApacheHandlers</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Below are configuration instructions for the three most basic types of configuration: the standalone handler, a CGI handler, and running under mod_python. For further information on configuration, see:
<ul>
<li><a href="http://www.myghty.org/trac/wiki/How-to%27s_Configuration">How-to's_Configuration</a> - User-contributed configuration information at www.myghty.org, including:
<ul>
<li><a href="http://www.myghty.org/trac/wiki/How_to_Configure_lighttpd_%2B_mod_fastcgi_%2B_Myghty">How to Configure lighttpd + mod fastcgi + Myghty</a> - A configuration that one user acheives six times faster performance than an equivalent Apache configuration.
</ul>
</li>
<li><a href="#parameters" >Index of Configuration Parameters</a> - full index of configuration parameters</li>
<li><a href="#configuration_programmatic" >Programmatic Configuration</a> - writing Python modules that interface to Myghty in various ways</li>
<li><a href="#resolver" >Advanced Resolver Configuration</a> - developing custom rulesets to match URIs to components</li>
<li><a href="#caching_options" >Cache Options</a> - configuring component-caching support</li>
<li><a href="#session_options" >Session Options</a> - configuring session-storage support</li>
</ul>
</p>
</div>
<A name="configuration_standalone"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Standalone Handler</span>
<div class="sectiontext">
<p>The standalone handler is a web server built off of Python's BaseHTTPServer class, and is great for local workstation development and testing. Here is a quick example to simply serve pages from the current directory - place the following code into a file <span class="codeline">run_server.py</span>:</p>
<div class="code">
<pre><span class="python_comment">#!/usr/local/bin/python</span>
<span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">HTTPServerHandler </span><span class="python_keyword">as </span><span class="python_name">HTTPServerHandler</span><span class="python_operator">
</span>
<span class="python_comment"># create the server.</span>
<span class="python_name">httpd </span><span class="python_operator">= </span><span class="python_name">HTTPServerHandler</span><span class="python_operator">.</span><span class="python_name">HTTPServer</span><span class="python_enclosure">(</span>
<span class="python_comment"># port number to listen on.</span>
<span class="python_name">port </span><span class="python_operator">= </span><span class="python_number">8080</span><span class="python_operator">,</span>
<span class="python_comment"># HSHandler list. indicates paths where the file should be interpreted</span>
<span class="python_comment"># as a Myghty component request.</span>
<span class="python_comment"># Format is a list of dictionaries, each maps a regular expression matching a URI</span>
<span class="python_comment"># to an instance of HTTPServerHandler.HSHandler, containing the arguments for</span>
<span class="python_comment"># a Myghty interprter. for HTTP requests of type "text/*", this list is matched</span>
<span class="python_comment"># first against the incoming request URI. </span>
<span class="python_name">handlers </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_enclosure">{</span><span class="python_literal">'.*\.myt' </span><span class="python_operator">: </span><span class="python_name">HTTPServerHandler</span><span class="python_operator">.</span><span class="python_name">HSHandler</span><span class="python_enclosure">(</span><span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'./cache'</span><span class="python_operator">, </span><span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'./'</span><span class="python_enclosure">)}</span><span class="python_operator">,</span>
<span class="python_enclosure">]</span><span class="python_operator">,</span>
<span class="python_comment"># document root list. indicates paths where the file should be served</span>
<span class="python_comment"># like a normal file, with the appropriate MIME type set as the content-type.</span>
<span class="python_comment"># These are served for all non "text/*" HTTP requests, and all</span>
<span class="python_comment"># incoming URIs that do not match the list of handlers above.</span>
<span class="python_name">docroot </span><span class="python_operator">= </span><span class="python_enclosure">[{</span><span class="python_literal">'.*' </span><span class="python_operator">: </span><span class="python_literal">'./'</span><span class="python_enclosure">}]</span><span class="python_operator">,</span>
<span class="python_enclosure">) </span><span class="python_operator">
</span>
<span class="python_comment"># run the server</span>
<span class="python_name">httpd</span><span class="python_operator">.</span><span class="python_name">serve_forever</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
<p>Then, in that same directory, place another file, called <span class="codeline">index.myt</span>:</p>
<div class="code">
<pre><span class="text"><html>
<head><title>Test Page</title></head>
<body>
Welcome to Myghty !
</body>
</html></span></pre></div>
<p>To run the server, type:</p>
<div class="code">
<pre>python ./run_server.py</pre></div>
<p>and point a web browser to <span class="codeline">http://localhost:8080/index.myt</span>. The data directory <span class="codeline">./cache</span> will be automatically created to store data files.</p>
<p>Other examples of the Standalone handler are available in <span class="codeline">examples/shoppingcart/run_cart.py</span> for a straightforward example, or <span class="codeline">tools/run_docs.py</span> for an advanced example that also makes use of custom resolution strategies.</p>
</div>
<a href="#configuration" class="toclink">back to section top</a>
</div>
<A name="configuration_cgi"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">CGI</span>
<div class="sectiontext">
<p>Serving Myghty template files directly via CGI can be achieved with the <span class="codeline">myghty.cgi</span> utility located in the <span class="codeline">/tools</span> directory. This program is a simple interface to the <span class="codeline">CGIHandler</span>, which converts the "path-info" of the requested URI into a Myghty component call. The script's configuration information is present within the top half of the script itself, to allow the most straightforward configuration, although it could certainly be modified to load configuration information from any other source such as other Python modules or configuration files.</p>
<p>It requires configuration of the component root, data directory, and optionally additional Python libraries to run. Other configuration parameters can be added to the <span class="codeline">handle()</span> call as well. The cgi handler will handle requests of the form:<br/><br/>
<span class="codeline">http://<domain>/<cgi-bin directory>/myghty.cgi/<uri of template></span>.
</p>
<p>The script is below. Modify the appropriate lines and copy the myghty.cgi program into your webserver's cgi-bin directory for a basic cgi-based template handler. For usage within custom CGI scripts, see the next section detailing programmatic methods of calling Myghty.</p>
<div class="code">
<pre><span class="python_comment">#!/usr/local/bin/python</span>
<span class="python_comment"># myghty cgi runner. place in cgi-bin directory and address Myghty templates</span>
<span class="python_comment"># with URLs in the form:</span>
<span class="python_comment"># http://mysite.com/cgi-bin/myghty.cgi/path/to/template.myt</span>
<span class="python_comment"># component root. this is where the Myghty templates are.</span>
<span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'/path/to/croot'</span><span class="python_operator">
</span>
<span class="python_comment"># data directory. this is where Myghty puts its object files.</span>
<span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'/path/to/datadir'</span><span class="python_operator">
</span>
<span class="python_comment"># libraries. Put paths to additional custom Python libraries here.</span>
<span class="python_name">lib </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'/path/to/custom/libraries'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_keyword">import </span><span class="python_name">sys</span><span class="python_operator">
</span><span class="python_enclosure">[</span><span class="python_name">sys</span><span class="python_operator">.</span><span class="python_name">path</span><span class="python_operator">.</span><span class="python_name">append</span><span class="python_enclosure">(</span><span class="python_name">path</span><span class="python_enclosure">) </span><span class="python_keyword">for </span><span class="python_name">path </span><span class="python_keyword">in </span><span class="python_name">lib</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">CGIHandler </span><span class="python_keyword">as </span><span class="python_name">handler</span><span class="python_operator">
</span>
<span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_name">component_root</span><span class="python_operator">, </span><span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_name">data_dir</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
</div>
<a href="#configuration" class="toclink">back to section top</a>
</div>
<A name="configuration_mod_python"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">mod_python</span>
<div class="sectiontext">
<p>This section assumes familiarity with basic Apache configuration. Myghty includes a handler known as <span class="codeline">myghty.http.ApacheHandler</span> which can interpret requests from the mod_python request object. This handler can be configured directly within the httpd.conf file of Apache, using regular Apache configuration file directives to configure its options. Alternatively, the ApacheHandler can be used within an external Python module that defines its own mod_python handler, which allows most of the configuration of the handler to be stated within a Python file instead of the httpd.conf file. The first method, described in this section, is expedient for a straightforward Myghty template service, or a simple view-controller setup. While the full range of configurational options can be present directly in http.conf stated as Apache configuration directives, including Python imports, functions, and datastructures, the syntax of embedding Python into conf directives can quickly become burdensome when configuring an application with a complex resolution stream. Therefore it is recommended that Apache users also become familiar with programmatic configuration, described in the section <a href="#configuration_programmatic_httphandler_ApacheHandler" >ApacheHandler</a>.</p>
<p>Myghty configuration parameters are written in the Apache httpd.conf file as "Myghty" plus the parameter name in InitialCaps. The full range of configuration parameters in <b>None</b> may be used. The values (right-hand side of the configuration directive) are Python evaluable expressions. In the simplest case, this is just a string, which is mostly easily identified as <span class="codeline">r"<string>"</span> so that Apache does not strip the quotes out. Any Python structure can be used as the value, such as a list, dictionary, lambda, etc., as long as the proper Apache conf escaping is used.</p>
<p>Below is a straightforward example that routes all Apache requests for files with the extension ".myt" to the Myghty ApacheHandler:</p>
<div class="code">
<pre># associate .myt files with mod_python
# mod_python 3.1 uses 'mod_python'
AddHandler mod_python .myt
# or for mod_python 2.7 use 'python-program'
# AddHandler python-program .myt
# set the handler called by mod_python to be the Myghty ApacheHandler
PythonHandler myghty.ApacheHandler::handle
# set python library paths - this line is used to indicate
# additional user-defined library paths. this path is not required for the
# Myghty templates themselves.
PythonPath "sys.path+[r'/path/to/my/libraries']"
# set component root.
# for this example, an incoming URL of http://mysite.com/files/myfile.myt
# will be resolved as: /path/to/htdocs/files/myfile.myt
PythonOption MyghtyComponentRoot r"/path/to/htdocs"
# data directory where myghty will write its object files,
# as well as session, cache, and lock files
PythonOption MyghtyDataDir r"/path/to/writeable/data/directory/"
# other options - simply write as 'Myghty' with the param name in
# InitialCaps format, values should be legal python expressions
# watch out for using quotes "" as apache.conf removes them -
# use r"value" or '"value"' instead
PythonOption Myghty<paramname> <paramvalue></pre></div>
<p>When this is done, requests to Apache which refer to pages with the extension .myt will be routed to the ApacheHandler, which will resolve the filename into a component which is then executed.</p>
<p>An additional format for the "MyghtyComponentRoot" parameter, a list of multiple paths, can be specified as a list of dictionaries. An example:
<div class="code">
<pre># Multiple Roots, each has a key to identify it,
# and their ordering determines their precedence
PythonOption MyghtyComponentRoot \
"[ \
{'components':'/optional/path/to/components'}, \
{'main':'/path/to/htdocs/htdocs'} \
]"</pre></div>
<p>
Keep in mind that the MyghtyComponentRoot parameter (normally called component_root) defines filesystem paths that have no relationship to Apache DocumentRoots. From the perspective of Apache, there is only a single mod_python handler being invoked, and it has no awareness of the component_root. This means that any incoming URL which matches the Myghty handler will be matched to a root in the component_root and served as a Myghty template, effectively allowing "access" to files that are not directly access-controlled by Apache. To restrict direct access to Myghty component files which are meant for internal use, an alternate file extension, such as ".myc" can be used, so that while a Myghty component can internally find those files within the component_root, the Apache server has no knowledge of the .myc extension and they are not served. This also requires that the .myc files are kept in a directory or directories separate from any configured Apache DocuementRoots.</p>
<p>
Myghty also has the ability to handle directory requests and requests for nonexistent files via various mechanisms, including <a href="#specialtempl_dhandler" >dhandler</a> and <a href="#modulecomponents" >Module Components</a>. However, the example above is configured to only respond to URLs with the specific file extension of ".myt". To handle directory requests without a filename being present, or requests for many different file extensions at once, replace the usage of <span class="codeline">AddHandler</span> with the Apache <span class="codeline">SetHandler</span> directive combined with the <FilesMatch>, <LocationMatch>, or <DirectoryMatch> Apache directives. These directives are described in the Apache documentation. For example:
</p>
<div class="code">
<pre><LocationMatch '/store/.*'>
SetHandler mod_python
PythonHandler myghty.ApacheHandler::handle
PythonPath "sys.path+[r'/path/to/my/libraries']"
# module component directive. matches regular expressions to Python classes and functions.
PythonOption MyghtyModuleComponents "[ \
{'/store/product/.*':store:ProductHandler},\
{'/store/checkout/.*':store:CheckoutHandler},\
]"
PythonOption MyghtyComponentRoot r"/path/to/htdocs"
PythonOption MyghtyDataDir r"/path/to/writeable/data/directory/"
</LocationMatch></pre></div>
<p>The above MyghtyModuleComponents, the apache version of <a href="#parameters_module_components" >module_components</a>, is just one way to serve module components; there is also <a href="#parameters_module_root" >module_root</a>, as well as the Routes resolver.</p>
<p>When serving all files within a directory, one should take care that Myghty is not be used to handle binary files, such as images. Also, it might be inappropriate to serve other kinds of text files such as stylesheets (.css files) and javascript files (.js files), even though one could use Myghty templating to serve these. To get around these issues, when straight file-extension matching is not enough, the Myghty and non-Myghty files can be placed in different directories and Apache correspondingly configured to enable Python handling in the Myghty directory only.
</p>
</div>
<A name="configuration_mod_python_multiple"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Advanced mod_python Configuration - Multiple ApacheHandlers</span>
<div class="sectiontext">
<p>Several Interpreters can be configured with their own set of configuration parameters and executed all within the same Python interpreter instance, through the use of the <a href="#parameters_interpreter_name" >interpreter_name</a> configuration parameter.
In the example below, a site configures three main dynamic areas: a documentation section, a catalog section, and the default section for all requests that do not correspond to the previous two. It uses three ApacheHandlers each with different component_root configuration parameters, but they share a common data_dir. The handlers are each configured inside a <LocationMatch> directive where they are given a unique name that identifies them upon each request.</p>
<div class="code">
<pre># Apache resolves the LocationMatch directives in the order they
# appear so the most general directive is last.
# note that every path within each "component root" parameter has a unique name, since
# all the Myghty interpreters happen to be using the same data directory.
# also, the PythonPath is set for each SetHandler. while this should work as a single
# configuration for all three sections, in testing it seems to work sporadically, so its
# set explicitly for each one.
# set Myghty data dir, will be used by all sub-directives
PythonOption MyghtyDataDir r"/web/myapp/cache/"
# '/docs/', serves product documentation
<LocationMatch "/docs/.*\.myt">
# set myghty handler
SetHandler mod_python
PythonHandler myghty.ApacheHandler::handle
PythonPath "['/foo/bar/lib', '/usr/local/myapp/lib'] + sys.path"
# set interpreter name
PythonOption MyghtyInterpreterName r"document_interp"
# set component root
PythonOption MyghtyComponentRoot "[\
{'docs_components' : r'/web/myapp/components'},\
{'docs_htdocs' : r'/web/myapp/documents'},\
]"
# add a translation rule to trim off the /docs/
# when resolving the component
PythonOption MyghtyPathTranslate "[\
(r'/docs/(.*)' : r'\1'),\
]"
</LocationMatch>
# '/catalog/', serves a browseable catalog via a module component
# users can also log in to this area
<LocationMatch "/catalog/.*">
# set myghty handler
SetHandler mod_python
PythonHandler myghty.ApacheHandler::handle
PythonPath "['/foo/bar/lib', '/usr/local/myapp/lib'] + sys.path"
# set interpreter name
PythonOption MyghtyInterpreterName r"catalog_interp"
# set component root
PythonOption MyghtyComponentRoot "[\
{'catalog_components' : r'/web/myapp/catalog/comp'},\
]"
# configure some module components
PythonOption MyghtyModuleComponents "[\
{r'/catalog/login' : 'myapp.components:Login'},\
{r'/catalog/.*' : 'myapp.components:Catalog'},\
]"
</LocationMatch>
# default: all other site docs
<LocationMatch ".*\.myt">
# set myghty handler
SetHandler mod_python
PythonHandler myghty.ApacheHandler::handle
PythonPath "['/foo/bar/lib', '/usr/local/myapp/lib'] + sys.path"
PythonOption MyghtyInterpreterName r"default_interp"
# set component root
PythonOption MyghtyComponentRoot "[\
{'default' : r'/web/myapp/htdocs'},\
]"
</LocationMatch></pre></div>
<p>Configuring component roots and path translation based on the incoming URI can also be accomplished within the scope of a single Interpreter by defining a custom set of resolver rules. This technique is described in <a href="#resolver" >Advanced Resolver Configuration</a>.</p>
</div>
<a href="#configuration" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="configuration_programmatic"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#configuration">Configuration</a>
|
Next: <a href="#embedding">Embedding Python in HTML</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Programmatic Configuration</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#configuration_programmatic_httphandler">Chaining to HTTPHandler</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_ApacheHandler">ApacheHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_CGIHandler">CGIHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_httphandler_WSGIHandler">WSGIHandler</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#configuration_programmatic_interpreter">Chaining to Interpreter</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#configuration_programmatic_interpreter_standalone">Configuring a Standalone Application</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>This section illustrates how to link the Myghty interpreter to a Python application. If you already have a basic configuration running and want to jump into programming templates, skip ahead to <a href="#embedding" >Embedding Python in HTML</a>.</p>
<p>The central request-handling unit within Myghty is called the <b>Interpreter</b>. When an application is set up to handle a request and pass control onto the Interpreter, it is referred to as an <b>external controller</b>. In the model-view-controller paradigm, the application is the controller, the template called by the Interpreter is the view, and whatever data is passed from the controller to the template is the model.</p>
<p>Currently, all Myghty installations, except for mod_python, require at least a rudimentary external controller, which serves as the place for configuration directives to be set up and specified to the Myghty environment. Since a lot of configuration directives reference datastructures or functions themselves, a Python module is the most natural place for this to happen.</p>
<p>A more elaborate external controller may be the point at which an application passes control from its application code and business logic onto a view layer, served by a Myghty Interpreter and corresponding template files. This may be appropriate for an application that is already handling the details of its HTTP environment, if any, or any application that just needs basic template support.</p>
<p>In contrast to the "external controller" concept is the <b>internal controller</b>, which is Python code that executes after the Interpreter begins handling the request, forwarding data onto template-driven components at the end of its request cycle. Myghty provides a construct for this kind of controller described in <a href="#modulecomponents" >Module Components</a>. It is recommended that an application that aims to be designed in a full MVC (model-view-controller) style, particularly one that runs in an HTTP environment, place its controller code into Module Components, and only application configuration code and externally-dependent code into a single external controller module. That way the majority of an application's controller code is written in an environment-neutral fashion, and also has the full benefits of the Myghty resolution and request environment available to it.</p>
<p>The two general categories of external controller are:</p>
<ul>
<li><a href="#configuration_programmatic_httphandler" >Chaining to HTTPHandler</a></li>
<li><a href="#configuration_programmatic_interpreter" >Chaining to Interpreter</a></li>
</ul>
</div>
<A name="configuration_programmatic_httphandler"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Chaining to HTTPHandler</span>
<div class="sectiontext">
<p>For applications running in an HTTP environment, chaining to HTTPHandler is the usual method. An HTTPHandler object has awareness of HTTP requests for any of four different environments, which are WSGI, CGI, mod_python, and the standalone handler. It can construct the appropriate HTTP-aware environment to be delivered to the Interpreter and ultimately onto templates, which then receive an implementation-neutral interface to that environment via the <i>r</i> global object.</p>
<p>All HTTP-based Myghty configurations utilize a subclass of <span class="codeline">myghty.http.HTTPHandler.HTTPHandler</span> to serve requests. Each HTTP environment has its own module: <span class="codeline">myghty.http.ApacheHandler</span>, <span class="codeline">myghty.http.CGIHandler</span>, <span class="codeline">myghty.http.HTTPServerHandler</span> and <span class="codeline">myghty.http.WSGIHandler</span>, containing the classes <span class="codeline">ApacheHandler</span>, <span class="codeline">CGIHandler</span>, <span class="codeline">HSHandler</span>, and <span class="codeline">WSGIHandler</span>, respectively.</p>
<p>As of version 0.98, the recommended way to chain to an HTTPHandler is to first get an instance to a handler via the function <span class="codeline">get_handler()</span>, and then execute a request on that handler via the method <span class="codeline">handle()</span>. In previous versions, a single function <span class="codeline">handle()</span> is used which combines the argument sets of both functions; this function is still available.</p>
<p>The get_handler function retrieves a handler from a registry based on the given <b>interpreter_name</b>, which defaults to 'main' or in the case of Apache uses the http.conf variable "MyghtyInterpreterName". Application-scoped configuration variables are sent to this method which are used to create the initial HTTPHandler object. Once created, subsequent calls with the same interpreter_name will return the same HTTPHandler instance.
</p>
<p>HTTPHandler then supplies the method <span class="codeline">handle()</span> to handle requests, which accepts configurational parameters on a per request basis. Common per-request parameters include the component path or object to serve, the request arguments, and out_buffer to capture component output.</p>
<p>Each handler module has a slightly different calling signature, illustrated below. </p>
</div>
<A name="configuration_programmatic_httphandler_ApacheHandler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">ApacheHandler</span>
<div class="sectiontext">
<p>The ApacheHandler handles mod_python requests. It retrieves configuration via directives found in the host's httpd.conf file in the manner detailed in <a href="#configuration_mod_python" >mod_python</a>, and by default serves the component referenced by the <span class="codeline">request.uri</span> data member. Configuration parameters sent programmatically override those found in the Apache configuration.</p>
<p>In the example below, a file "myghty_handler.py" is created, which contains a very simple mod_python handler that "chains" to the myghty ApacheHandler.</p>
<div class="code">
<div class="codetitle">myghty_handler.py</div>
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">ApacheHandler </span><span class="python_keyword">as </span><span class="python_name">ApacheHandler</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">ApacheHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>A configuration for the above file is similar to a straight Apache configuration. Since the ApacheHandler created in the myghty_handler.py file contains no configuration at all, all of its options will come from the httpd.conf directives:</p>
<div class="code">
<pre>AddHandler mod_python .myt
PythonHandler myghty_handler::handle
PythonPath "sys.path+[r'/path/to/my/libraries']"
PythonOption MyghtyComponentRoot r"/path/to/htdocs"
PythonOption MyghtyDataDir r"/path/to/writeable/data/directory/"</pre></div>
<p>When we take the above handler file and add configuration directives programmatically, they will override those named in the httpd.conf file:</p>
<div class="code">
<div class="codetitle">myghty_handler.py</div>
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">ApacheHandler </span><span class="python_keyword">as </span><span class="python_name">ApacheHandler</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">ApacheHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_operator">,</span>
<span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/usr/local/web/data'</span><span class="python_operator">,</span>
<span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_enclosure">[</span>
<span class="python_enclosure">{</span><span class="python_literal">'components'</span><span class="python_operator">:</span><span class="python_literal">'/usr/local/web/components'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">{</span><span class="python_literal">'templates'</span><span class="python_operator">:</span><span class="python_literal">'/usr/local/web/templates'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">])</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<P>Another example, overriding the application's data directory, and also the request's component path and request arguments:</p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">ApacheHandler </span><span class="python_keyword">as </span><span class="python_name">ApacheHandler</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">ApacheHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
<span class="python_name">request</span><span class="python_operator">, </span><span class="python_name">interpreter_name </span><span class="python_operator">= </span><span class="python_literal">'mainhandler'</span><span class="python_operator">, </span><span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'/data'</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_operator">, </span>
<span class="python_name">component </span><span class="python_operator">= </span><span class="python_literal">'mypage.myt'</span><span class="python_operator">, </span><span class="python_name">request_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'foo' </span><span class="python_operator">: </span><span class="python_literal">'bar'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>The above example also specifies the <a href="#parameters_interpreter_name" >interpreter_name</a> configuration parameter which identifies which ApacheHandler is returned by <span class="codeline">get_handler</span>. If this parameter is not specified, it defaults to "main".</p>
</div>
<a href="#configuration_programmatic" class="toclink">back to section top</a>
</div>
<A name="configuration_programmatic_httphandler_CGIHandler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">CGIHandler</span>
<div class="sectiontext">
<p>The CGI handler retreives its environment information via the <span class="codeline">cgi.FieldStorage()</span> method as well as <span class="codeline">os.environ</span>. Configuration parameters sent programmatically override those found in the CGI environment. By default, CGIHandler serves the component indicated by the environment variable PATH_INFO.
</p>
<div class="code">
<div class="codetitle">CGI application chaining to CGIHandler.handle() function</div>
<pre><span class="python_comment">#!/usr/local/bin/python</span>
<span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">CGIHandler </span><span class="python_keyword">as </span><span class="python_name">CGIHandler</span><span class="python_operator">
</span>
<span class="python_comment"># serve the component based on PATH_INFO</span>
<span class="python_name">CGIHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
<span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_literal">'/path/to/htdocs'</span><span class="python_operator">,</span>
<span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/datadirectory'</span>
<span class="python_enclosure">)</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
</div>
<a href="#configuration_programmatic" class="toclink">back to section top</a>
</div>
<A name="configuration_programmatic_httphandler_WSGIHandler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">WSGIHandler</span>
<div class="sectiontext">
<p>WSGIHandler works similarly to CGIHandler. Its <i>r</i> object maintains a reference to both the <span class="codeline">environ</span> and <span class="codeline">start_response</span> members. These members are used to extract the core data members of the <i>r</i> object, such as <span class="codeline">headers_in</span>, <span class="codeline">method</span>, etc. </p>
<p>When running under WSGI, the <span class="codeline">environ</span> and <span class="codeline">start_response</span> variables are available via:
<div class="code">
<pre><span class="python_comment"># WSGI environment variables</span>
<span class="python_name">r</span><span class="python_operator">.</span><span class="python_name">environ</span><span class="python_operator">
</span><span class="python_name">r</span><span class="python_operator">.</span><span class="python_name">start_response</span><span class="python_operator"></span></pre></div>
</p>
<div class="code">
<div class="codetitle">WSGI application chaining to WSGIHandler.handle() method</div>
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler </span><span class="python_keyword">as </span><span class="python_name">WSGIHandler</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">application</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">return </span><span class="python_name">WSGIHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
<span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_literal">'/path/to/htdocs'</span><span class="python_operator">, </span>
<span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/datadirectory'</span><span class="python_enclosure">)</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>Also supported with WSGI is the standard <span class="codeline">application(environ, start_response)</span> function, which takes in all application and request-scoped configuration parameters via the <span class="codeline">environ</span> argument:</p>
<div class="code">
<div class="codetitle">WSGI application via application()</div>
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler </span><span class="python_keyword">as </span><span class="python_name">WSGIHandler</span><span class="python_operator">
</span>
<span class="python_name">params </span><span class="python_operator">= </span><span class="python_name">dict</span><span class="python_enclosure">(</span>
<span class="python_name">interpreter_name</span><span class="python_operator">=</span><span class="python_literal">'main_wsgi'</span><span class="python_operator">,</span>
<span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_literal">'/path/to/htdocs'</span><span class="python_operator">, </span>
<span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/datadirectory'</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">application</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">environ</span><span class="python_enclosure">[</span><span class="python_literal">'myghty.application'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_name">params</span><span class="python_operator">
</span><span class="python_name">environ</span><span class="python_enclosure">[</span><span class="python_literal">'myghty.request'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'component' </span><span class="python_operator">: </span><span class="python_literal">'mycomponent.myt'</span><span class="python_enclosure">}</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">WSGIHandler</span><span class="python_operator">.</span><span class="python_name">application</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
</div>
<a href="#configuration_programmatic" class="toclink">back to section top</a>
</div>
</div>
<A name="configuration_programmatic_interpreter"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Chaining to Interpreter</span>
<div class="sectiontext">
<p>The Myghty Interpreter object is the underlying engine that creates Myghty requests and executes them, supplying the necessary services each request needs. The Interpreter can be programmatically instantiated with a full set of configuration parameters and used directly.</p>
<p>While the advantage of using an HTTPHandler in an application is that Myghty components are aware of HTTP-specific information, such as the mod_python request object, HTTP headers, the httpd.conf configuration, etc., an application can also bypass all this by chaining directly to the Interpreter, if templates do not need HTTP awareness and the configuration can be programatically specified.</p>
<div class="code">
<div class="codetitle">mod_python handler chaining to Interpreter</div>
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">interp </span><span class="python_keyword">as </span><span class="python_name">interp</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span>
<span class="python_comment"># set up a singleton instance of Interpreter</span>
<span class="python_name">interpreter </span><span class="python_operator">= </span><span class="python_name">interp</span><span class="python_operator">.</span><span class="python_name">Interpreter</span><span class="python_enclosure">(</span>
<span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'./cache'</span><span class="python_operator">,</span>
<span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'./doc/components'</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># set up some data to send to the template</span>
<span class="python_operator"> </span><span class="python_name">data </span><span class="python_operator">= </span><span class="python_enclosure">{</span>
<span class="python_literal">'foo'</span><span class="python_operator">: </span><span class="python_literal">'bar'</span><span class="python_operator">,</span>
<span class="python_literal">'info' </span><span class="python_operator">: </span><span class="python_name">get_info</span><span class="python_enclosure">()</span>
<span class="python_enclosure">}</span><span class="python_operator">
</span>
<span class="python_comment"># call a template</span>
<span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">(</span><span class="python_literal">'mytemplate.myt'</span><span class="python_operator">, </span><span class="python_name">request_args </span><span class="python_operator">= </span><span class="python_name">data</span><span class="python_operator">, </span><span class="python_name">out_buffer </span><span class="python_operator">= </span><span class="python_name">request</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>In the above approach, Myghty components are unaware of the HTTP environment, meaning there is no <i>r</i> global variable, and also can't make HTTP return calls or location redirects. A greater amount of responsibility is placed within the controller.</p>
</div>
<A name="configuration_programmatic_interpreter_standalone"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Configuring a Standalone Application</span>
<div class="sectiontext">
<p>Chaining to the Interpreter directly also allows Myghty to run outside of a web context completely, within any Python application. It doesnt really need much configuration to run in "barebones" mode; the two most common features are the component root, which specifies one or more roots to search for input files, and the optional data directory, where it will store compiled python modules. Without the data directory, the compiled python modules are created in memory only.</p>
<p>A standlone application to run Myghty templates looks like this:</p>
<div class="code">
<pre><span class="python_comment">#!/usr/local/bin/python</span>
<span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">interp </span><span class="python_keyword">as </span><span class="python_name">interp</span><span class="python_operator">
</span><span class="python_keyword">import </span><span class="python_name">sys</span><span class="python_operator">
</span>
<span class="python_name">interpreter </span><span class="python_operator">= </span><span class="python_name">interp</span><span class="python_operator">.</span><span class="python_name">Interpreter</span><span class="python_enclosure">(</span>
<span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'./cache'</span><span class="python_operator">,</span>
<span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'./doc/components'</span><span class="python_operator">,</span>
<span class="python_name">out_buffer </span><span class="python_operator">= </span><span class="python_name">sys</span><span class="python_operator">.</span><span class="python_name">stdout</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># component name is relative to component_root</span>
<span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">(</span><span class="python_literal">'/index.myt'</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>The <span class="codeline">execute</span> method of Intepreter takes optional parameters and sends them off to a newly created <span class="codeline">Request</span> object. You can specify any of the constructor arguments used by <span class="codeline">Request</span> or its embedded helper object <span class="codeline">RequestImpl</span> in the <span class="codeline">execute</span> call of Interpreter, which will override the values given in the constructor to Interpreter. The below example sends a buffer to each request with which to capture output, via the <a href="#parameters_out_buffer" >out_buffer</a> parameter:</p>
<div class="code">
<pre><span class="python_name">file </span><span class="python_operator">= </span><span class="python_name">open</span><span class="python_enclosure">(</span><span class="python_literal">'index.html'</span><span class="python_operator">, </span><span class="python_literal">'w'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">(</span><span class="python_literal">'/index.myt'</span><span class="python_operator">, </span><span class="python_name">out_buffer </span><span class="python_operator">= </span><span class="python_name">file</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">file</span><span class="python_operator">.</span><span class="python_name">close</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
</div>
<a href="#configuration_programmatic" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="embedding"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#configuration_programmatic">Programmatic Configuration</a>
|
Next: <a href="#scopedpython">Scoped <%python> Blocks</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Embedding Python in HTML</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#embedding_control">Control Lines</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#embedding_comment">Comment Lines</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#embedding_substitutions">Substitutions</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#embedding_blocks">Python Blocks</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#embedding_whitespace">Controlling Whitespace with the Backslash</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#embedding_indentation">Indentation Behavior</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>A Myghty file usually is laid out as an HTML file, or other text file, containing specialized tags that are recognized by the Myghty page compiler. When compiled, the file is converted into a python module which is then executed as regular python code. A Myghty template in its compiled form is typically referred to as a <i>component</i>. A <i>component</i> can also contain one or more <i>subcomponents</i> and/or <i>methods</i>, which are described further in the section <a href="#components" >Components</a>. Basically when we say "component" we are talking about a self contained unit of Myghty templating code. The term "top level component" refers to the outermost component within a request, which is the page itself being executed. The term "file based component" refers to a component corresponding to the file that it appears in.
</p>
</div>
<A name="embedding_control"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Control Lines</span>
<div class="sectiontext">
<p>Control lines look like this:</p>
<div class="code">
<pre><span class="text">
% for x in range(0, 10):
hello!<br/>
% # end for</span></pre></div>
<p>The percent sign must be the very first character on the line, and the rest of the text is interpreted directly as Python code. The whitespace of the line, as well as the presence of a colon at the end of the line, is significant in determining the indentation of subsequent, non-control lines. As in the example above, the "for" statement followed by a colon, sets the indentation to be one level deeper, which causes the html text "hello!" to be iterated within the block created by the Python statement. The block is then closed by placing another control line, containing only whitespace plus an optional comment.</p>
<p>A more involved example:</p>
<div class="code">
<pre><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">mood </span><span class="python_keyword">in </span><span class="python_enclosure">[</span><span class="python_literal">'happy'</span><span class="python_operator">, </span><span class="python_literal">'happy'</span><span class="python_operator">, </span><span class="python_literal">'sad'</span><span class="python_operator">, </span><span class="python_literal">'sad'</span><span class="python_operator">, </span><span class="python_literal">'happy'</span><span class="python_enclosure">]</span><span class="python_operator">:</span>
<span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">mood </span><span class="python_operator">== </span><span class="python_literal">'happy'</span><span class="python_operator">:</span>
<span class="text">
<img src="happyface.gif"/> Hey There !
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">else</span><span class="python_operator">:</span>
<span class="text">
<img src="sadface.gif"/> Buzz Off !
</span><span class="controlline">%</span> <span class="python_comment">#if statement</span><span class="python_operator"></span>
<span class="controlline">%</span> <span class="python_comment">#for loop</span><span class="python_operator"></span></pre></div>
<p>Note that the whitespace is not significant in plain HTML or text lines. When this template is converted to Python code, the plain text will be embedded in <span class="codeline">write</span> statements that are indented properly within the block. Block-closing statements like "else:" and "except:" are also properly interpreted.</p>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<A name="embedding_comment"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Comment Lines</span>
<div class="sectiontext">
<p>
Note that a blank control line, i.e. starting with '%', is significant in affecting the whitespace indentation level, whether or not it contains a comment character '#' followed by a comment. To do line-based comments without affecting whitespace, use '#' as the very first character on a line:
</p>
<div class="code">
<pre><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">x </span><span class="python_keyword">in </span><span class="python_enclosure">(</span><span class="python_number">1</span><span class="python_operator">,</span><span class="python_number">2</span><span class="python_operator">,</span><span class="python_number">3</span><span class="python_enclosure">)</span><span class="python_operator">:</span>
<span class="text"> <b>hi </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">x</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></b>
</span><span class="doctag"># a comment
</span><span class="text">
</span><span class="controlline">%</span> <span class="python_comment"># a block-closing control line</span><span class="python_operator"></span></pre></div>
<p>Comments can also be done with the <%doc> tag described in <a href="#otherblocks_doc" ><%doc></a>. </p>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<A name="embedding_substitutions"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Substitutions</span>
<div class="sectiontext">
<P>A substitution is an embedded python expression, whos evaluated value will be sent to the output stream of the component via a <span class="codeline">m.write()</span> statement:</p>
<div class="code">
<pre><span class="text">Three plus five is: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_number">3 </span><span class="python_operator">+ </span><span class="python_number">5</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>produces:</p>
<div class="code">
<pre><span class="text">Three plus five is: 8</span></pre></div>
<p>Substitutions can also span multiple lines which is handy in conjunction with triple-quoted blocks.</p>
<p>The text of substitutions can also be HTML or URL escaped via the use of flags. For a description of escape flags, see the section <a href="#filtering_escaping" >Escaping Content</a>.
</p>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<A name="embedding_blocks"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Python Blocks</span>
<div class="sectiontext">
<p>A python block is a block of pure python code:</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">usermanager</span><span class="python_operator">.</span><span class="python_name">get_user</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"username is %s" </span><span class="python_operator">% </span><span class="python_name">user</span><span class="python_operator">.</span><span class="python_name">get_name</span><span class="python_enclosure">())</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>Code within a %python block is inserted directly into the component's generated Python code, with its whitespace <b>normalized</b> to that of the most recent control line. The %python tags, as well as the code within the tags, can be at any indentation level in relation to the rest of the document, including other %python blocks; it is only necessary that the indentation of the code within the block is internally consistent with itself. See the next section for an example.</p>
<p>
There are also variations upon the %python block, where the contained Python code is executed within a specific context of a component's execution, such as initialization, cleanup, or global. These special variations are explained in <a href="#scopedpython" >Scoped <%python> Blocks</a>.
</p>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<A name="embedding_whitespace"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Controlling Whitespace with the Backslash</span>
<div class="sectiontext">
<p>To allow for finer control of the whitespace inherently generated by multiline HTML or Python control structures, the backslash character "\" can be used at the end of any line to suppress newline generation:
<div class="code">
<pre><span class="text"><span class="light"></span><span class="python_operator">\
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">x </span><span class="python_keyword">in </span><span class="python_enclosure">(</span><span class="python_number">1</span><span class="python_operator">,</span><span class="python_number">2</span><span class="python_operator">,</span><span class="python_number">3</span><span class="python_enclosure">)</span><span class="python_operator">:</span>
<span class="text"> [</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">x</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">]</span><span class="python_operator">\
</span><span class="controlline">%</span><span class="python_operator"></span>
<span class="text"></span></span></pre></div>
Which will produce:
<div class="code">
<pre><span class="text"><span class="light">[1][2][3]</span></span></pre></div>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<A name="embedding_indentation"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Indentation Behavior</span>
<div class="sectiontext">
<p>The interaction of control lines, plain text, and python blocks is regulated by the Myghty engine to create an overall indentation scheme that is functional but also allows HTML and python blocks to be laid out with a high degree of freedom. The following example illustrates the indentation behavior:</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">forecasts </span><span class="python_operator">= </span><span class="python_enclosure">{</span>
<span class="python_literal">'monday'</span><span class="python_operator">:</span><span class="python_literal">'stormy'</span><span class="python_operator">,</span>
<span class="python_literal">'tuesday'</span><span class="python_operator">:</span><span class="python_literal">'sunny'</span><span class="python_operator">,</span>
<span class="python_literal">'wednesday'</span><span class="python_operator">:</span><span class="python_literal">'sunny'</span><span class="python_operator">, </span>
<span class="python_literal">'thursday'</span><span class="python_operator">:</span><span class="python_literal">'humid'</span><span class="python_operator">,</span>
<span class="python_literal">'friday'</span><span class="python_operator">:</span><span class="python_literal">'tornado'</span>
<span class="python_enclosure">}</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="blocktag"></%python></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">day </span><span class="python_keyword">in </span><span class="python_enclosure">[</span><span class="python_literal">'monday'</span><span class="python_operator">, </span><span class="python_literal">'tuesday'</span><span class="python_operator">, </span><span class="python_literal">'wednesday'</span><span class="python_operator">, </span><span class="python_literal">'thursday'</span><span class="python_operator">, </span><span class="python_literal">'friday'</span><span class="python_enclosure">]</span><span class="python_operator">:</span>
<span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">weather </span><span class="python_operator">= </span><span class="python_name">forecasts</span><span class="python_enclosure">[</span><span class="python_name">day</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">weather </span><span class="python_operator">== </span><span class="python_literal">'tornado'</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"run for the hills !"</span><span class="python_operator">
</span><span class="python_keyword">elif </span><span class="python_name">weather </span><span class="python_operator">== </span><span class="python_literal">'stormy'</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"bring an umbrella"</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"enjoy the day...."</span><span class="python_operator">
</span> <span class="blocktag"></%python></span><span class="text">
Weather for </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">day</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">forecasts</span><span class="python_enclosure">[</span><span class="python_name">day</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
Advice: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">advice</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</span><span class="controlline">%</span> <span class="python_comment"># end for</span><span class="python_operator"></span></pre></div>
<p>The above block, when compiled, translates into the following Python code, that is then executed to produce the final output:</p>
<div class="code">
<pre><span class="python_comment"># BEGIN BLOCK body</span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
'''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_comment"># test.myt Line 1</span>
<span class="python_name">forecasts </span><span class="python_operator">= </span><span class="python_enclosure">{</span>
<span class="python_literal">'monday'</span><span class="python_operator">:</span><span class="python_literal">'stormy'</span><span class="python_operator">,</span>
<span class="python_literal">'tuesday'</span><span class="python_operator">:</span><span class="python_literal">'sunny'</span><span class="python_operator">,</span>
<span class="python_literal">'wednesday'</span><span class="python_operator">:</span><span class="python_literal">'sunny'</span><span class="python_operator">, </span>
<span class="python_literal">'thursday'</span><span class="python_operator">:</span><span class="python_literal">'humid'</span><span class="python_operator">,</span>
<span class="python_literal">'friday'</span><span class="python_operator">:</span><span class="python_literal">'tornado'</span>
<span class="python_enclosure">}</span><span class="python_operator">
</span>
<span class="python_comment"># test.myt Line 11</span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
'''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">for </span><span class="python_name">day </span><span class="python_keyword">in </span><span class="python_enclosure">[</span><span class="python_literal">'monday'</span><span class="python_operator">, </span><span class="python_literal">'tuesday'</span><span class="python_operator">, </span><span class="python_literal">'wednesday'</span><span class="python_operator">, </span><span class="python_literal">'thursday'</span><span class="python_operator">, </span><span class="python_literal">'friday'</span><span class="python_enclosure">]</span><span class="python_operator">:
</span><span class="python_comment"># test.myt Line 13</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
'''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_comment"># test.myt Line 14</span>
<span class="python_name">weather </span><span class="python_operator">= </span><span class="python_name">forecasts</span><span class="python_enclosure">[</span><span class="python_name">day</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">weather </span><span class="python_operator">== </span><span class="python_literal">'tornado'</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"run for the hills !"</span><span class="python_operator">
</span><span class="python_keyword">elif </span><span class="python_name">weather </span><span class="python_operator">== </span><span class="python_literal">'stormy'</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"bring an umbrella"</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_name">advice </span><span class="python_operator">= </span><span class="python_literal">"enjoy the day...."</span><span class="python_operator">
</span>
<span class="python_comment"># test.myt Line 24</span>
<span class="python_operator"></span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
Weather for '''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">( </span><span class="python_name">day </span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">''': '''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">( </span><span class="python_name">forecasts</span><span class="python_enclosure">[</span><span class="python_name">day</span><span class="python_enclosure">] )</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
Advice: '''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_comment"># test.myt Line 26</span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">( </span><span class="python_name">advice </span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">'''
'''</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_comment"># test.myt Line 28</span>
<span class="python_comment"># end for</span>
<span class="python_comment"># END BLOCK body</span><span class="python_operator"></span></pre></div>
</div>
<a href="#embedding" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="scopedpython"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#embedding">Embedding Python in HTML</a>
|
Next: <a href="#globals">Standard Global Variables</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Scoped <%python> Blocks</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#scopedpython_component">Component Scope</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#scopedpython_global">Global Scope</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#scopedpython_init">Init Scope</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#scopedpython_cleanup">Cleanup Scope</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#scopedpython_request">Request Scope</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_request_value">Using Pass-By-Value</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_request_alternative">Alternative - Request Attributes</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#scopedpython_thread">Thread Scope</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#scopedpython_thread_threadlocal">Alternative to Thread Scope: ThreadLocal()</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>The <%python> tag is also capable of specifying Python code that occurs within a specific scope of a template's execution, using the <span class="codeline">scope</span> attribute. Scopes are provided that specify Python code as always the first thing executed within a component, always the last thing executed, or executes once per request, once per application thread, or once per application process.</p>
<p>Originally, these scopes had their own specific tag names, which are still available. These names include all those that are familiar to HTML::Mason users, as well as some new names. All synonyms are noted in each section. </p>
</div>
<A name="scopedpython_component"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="component"></p>
<p><b>Also called:</b> <%python></p>
<p>A component-scoped block is a regular block of Python that executes within the body of a template, as illustrated in the previous section <a href="#embedding_blocks" >Python Blocks</a> . Many component-scoped blocks may exist in a template and they will all be executed in the place that they occur. Component scope has two variants, init and cleanup scope, which while still being component scope, execute at specific times in a component's execution regardless of their position in a template. They are described later in this section.</p>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
<A name="scopedpython_global"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Global Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="global"></p>
<p><b>Also called:</b> <%global>, <%once> </p>
<p>A global-scoped block refers to a section of Python code that is executed exactly once for a component, within the scope of its process. In reality, this usually means code that is executed each time the module is newly loaded or reloaded in the current Python process, as it is called as part of the module import process. Variables that are declared in a global-scoped block are compiled as global variables at the top of the generated module, and thus can be seen from within the bodies of all components defined within the module. Assignment to these variables follows the Python scoping rules, meaning that they will magically be copied into local variables once assigned to unless they are pre-declared in the local block with the Python keyword <span class="codeline">global</span>.</p>
<p>Global-scoped Python executes only once when a component module is first loaded, as part of its import. As such, it is called slightly outside of the normal request call-chain and does not have the usual access to the the built-in request-scoped variables <i>m</i>, <i>r</i>, ARGS, etc. However, you can access the Request that is corresponding to this very first execution via the static call <span class="codeline">request.instance()</span>, which will give you the current request instance that is servicing the global-scoped block. </p>
<div class="code">
<pre><span class="text">
</span><span class="blocktag"><%python scope="global"></span>
<span class="python_comment"># declare global variables, accessible</span>
<span class="python_comment"># across this component's generated module</span>
<span class="python_operator"> </span><span class="python_name">message1 </span><span class="python_operator">= </span><span class="python_literal">"this is message one."</span><span class="python_operator">
</span><span class="python_name">message2 </span><span class="python_operator">= </span><span class="python_literal">"this is message two."</span><span class="python_operator">
</span><span class="python_name">message3 </span><span class="python_operator">= </span><span class="python_literal">"doh, im message three."</span><span class="python_operator">
</span> <span class="blocktag"></%python></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_comment"># reference the global variables</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"message one: " </span><span class="python_operator">+ </span><span class="python_name">message1</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"message two: " </span><span class="python_operator">+ </span><span class="python_name">message2</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># we want to assign to message3,</span>
<span class="python_comment"># so declare "global" first</span>
<span class="python_keyword">global </span><span class="python_name">message3</span><span class="python_operator">
</span>
<span class="python_name">message3 </span><span class="python_operator">= </span><span class="python_literal">"this is message three."</span><span class="python_operator">
</span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"message three: " </span><span class="python_operator">+ </span><span class="python_name">message3</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span> <span class="blocktag"></%python></span></pre></div>
<p>Use a global-scoped Python block to declare constants and resources which are shareable amongst all components within a template file. Note that for a threaded environment, global-scoped section applies to all threads within a process. This may not be appropriate for certain kinds of non-threadsafe resources, such as database handles, certain dbm modules, etc. For thread-local global variable declaration, see the section <a href="#scopedpython_thread" >Thread Scope</a>, or use the Myghty <span class="codeline">ThreadLocal()</span> object described in <a href="#scopedpython_thread_threadlocal" >Alternative to Thread Scope: ThreadLocal()</a>. Similarly, request-scoped operation is provided as well, described in the section <a href="#scopedpython_request" >Request Scope</a>.</p>
<p>A global-scoped block can only be placed in a top-level component, i.e. cannot be used within %def or %method.</p>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
<A name="scopedpython_init"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Init Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="init">
<p><b>Also called:</b> <%init></p>
<p>Init-scoped Python is python code that is executed once per component execution, before any other local python code or text is processed. It really is just a variant of component scope, since it is still technically within component scope, just executed before any other component-scoped code executes. One handy thing about init scope is that you can stick it at the <i>bottom</i> of a big HTML file, or in any other weird place, and it will still execute before all the other local code. Its recommended as the place for setting up HTTP headers which can only be set before any content and/or whitespace is written (although if autoflush is disabled, this is less of an issue; see <a href="#filtering_autoflush" >The Autoflush Option</a> for more details).</p>
<p>In this example, a login function is queried to detect if the current browser is a logged in user. If not, the component wants to redirect to a login page. Since a redirect should occur before any output is generated, the login function and redirect occurs within an init-scoped Python block:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="init"></span>
<span class="python_comment"># check that the user is logged in, else</span>
<span class="python_comment"># redirect them to a login page</span>
<span class="python_operator"> </span><span class="python_keyword">if not </span><span class="python_name">user_logged_in</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"/login.myt"</span><span class="python_operator">, </span><span class="python_name">hard </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="doctag"><%doc></span><span class="doctag_text">rest of page follows....</span><span class="doctag"></%doc></span><span class="text">
<html>
<head>
....</span></pre></div>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
<A name="scopedpython_cleanup"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Cleanup Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="cleanup">
<p><b>Also called:</b> <%cleanup></p>
<p>Cleanup-scoped Python is Python code executed at the end of everything else within a component's execution. It is executed within the scope of a <span class="codeline">try..finally</span> construct so its guaranteed to execute even in the case of an error condition.</p>
<p>In this example, a hypothetical LDAP database is accessed to get user information. Since the database connection is opened within the scope of the component inside its init-scoped block, it is closed within the cleanup-scoped block:</p>
<div class="code">
<pre><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">userid</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_comment"># open a connection to an expensive resource</span>
<span class="python_operator"> </span><span class="python_name">ldap </span><span class="python_operator">= </span><span class="python_name">Ldap</span><span class="python_operator">.</span><span class="python_name">connect</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">userrec </span><span class="python_operator">= </span><span class="python_name">ldap</span><span class="python_operator">.</span><span class="python_name">lookup</span><span class="python_enclosure">(</span><span class="python_name">userid</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
name: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">userrec</span><span class="python_enclosure">[</span><span class="python_literal">'name'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"><br/>
address: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">userrec</span><span class="python_enclosure">[</span><span class="python_literal">'address'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"><br/>
email: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">userrec</span><span class="python_enclosure">[</span><span class="python_literal">'email'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"><br/>
</span><span class="blocktag"><%python scope="cleanup"></span>
<span class="python_comment"># insure the expensive resource is closed</span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">ldap </span><span class="python_keyword">is not </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">ldap</span><span class="python_operator">.</span><span class="python_name">close</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
<A name="scopedpython_request"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Request Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="request">
<p><b>Also called:</b> <%requestlocal>, <%requestonce> or <%shared></p>
<p>A request-scoped Python block has similarities to a global-scoped block, except instead of executing at the top of the generated component's module, it is executed within the context of a function definition that is executed once per request. Within this function definition, all the rest of the component's functions and variable namespaces are declared, so that when variables, functions and objects declared within this function are referenced, they are effectively unique to the individual request.</p>
<div class="code">
<pre><span class="blocktag"><%python scope="request"></span>
<span class="python_operator"> </span><span class="python_name">context </span><span class="python_operator">= </span><span class="python_enclosure">{}</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">context</span><span class="python_enclosure">[</span><span class="python_literal">'start'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator"></span>
<span class="compcall"><& </span><span class="compname">dosomething </span><span class="compcall">&></span><span class="text">
</span><span class="deftag"><%def</span><span class="compname"> dosomething</span><span class="deftag">></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">context</span><span class="python_operator">.</span><span class="python_name">has_key</span><span class="python_enclosure">(</span><span class="python_literal">'start'</span><span class="python_enclosure">)</span><span class="python_operator">:</span>
<span class="text"> hi
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">else</span><span class="python_operator">:</span>
<span class="text"> bye
</span><span class="deftag"></%def></span></pre></div>
<p>The good news is, the regular Myghty variables <i>m</i>, <i>ARGS</i>, <i>r</i> etc. are all available within a request-scoped block. Although since a request-scoped block executes within a unique place in the call-chain, the full functionality of <i>m</i>, such as component calling, is not currently supported within such a block.</p>
<p>Request-scoped sections can only be used in top-level components, i.e. cannot be used within %def or %method.</p>
</div>
<A name="scopedpython_request_value"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Using Pass-By-Value</span>
<div class="sectiontext">
<p>While the net result of a request-scoped Python block looks similar to a global-scoped block, there are differences with how declared variables are referenced. Since they are not module-level variables, they can't be used with the Python <span class="codeline">global</span> keyword. There actually is no way to directly change what a request-scoped variable points to; however this can be easily worked around through the use of pass-by-value variables. A pass-by-value effect can be achieved with an array, a dictionary, a user-defined object whose value can change, or the automatically imported Myghty datatype <span class="codeline">Value()</span>, which represents an object whose contents you can change:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="request"></span>
<span class="python_operator"> </span><span class="python_name">status </span><span class="python_operator">= </span><span class="python_name">Value</span><span class="python_enclosure">(</span><span class="python_literal">"initial status"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">some_status_changed</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_name">status</span><span class="python_operator">.</span><span class="python_name">assign</span><span class="python_enclosure">(</span><span class="python_literal">"new status"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
the status is </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">status</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
<A name="scopedpython_request_alternative"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Alternative - Request Attributes</span>
<div class="sectiontext">
<p>An alternative to using request-scoped blocks is to assign attributes to the request object, which can then be accessed by any other component within that request. This is achieved via the member <a href="#request_members_attributes" >attributes</a>:</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'whatmawsaw'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'i just saw a flyin turkey!'</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="doctag"># .... somewhere in some other part of the template
</span><span class="text">
JIMMY: Hey maw, what'd ya see ?
MAW: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'whatmawsaw'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>Produces:</p>
<div class="code">
<pre><span class="text">JIMMY: Hey maw, what'd ya see ?
MAW: i just saw a flyin turkey!</span></pre></div>
<p>Also see <a href="#request" >The Request</a> which lists all request methods, including those used for attributes.
</p>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
</div>
<A name="scopedpython_thread"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Thread Scope</span>
<div class="sectiontext">
<p><b>Usage:</b> <%python scope="thread"></p>
<p><b>Also called:</b> <%threadlocal>, <%threadonce></p>
<p>A thread-scoped Python block is nearly the same as a <a href="#scopedpython_request" >Request Scope</a> block, except its defining function is executed once per thread of execution, rather than once per request. In a non-threaded environment, this amounts to once per process. The standard global variables <i>m</i>, <i>r</i> etc. are still available, but their usefulness is limited, as they only represent the one particular request that happens to be the first request to execute within the current thread. Also, like request-scope, variables declared in a thread-scoped block cannot be changed except with pass-by-value techniques, described in <a href="#scopedpython_request_value" >Using Pass-By-Value</a></p>
<p>In this example, a <span class="codeline">gdbm</span> file-based database is accessed to retreive weather information keyed off of a zipcode. Since gdbm uses the
<span class="codeline">flock()</span> system call, it's a good idea to keep the reference to a gdbm handle local to a particular thread (at least, the thread that opens the database must be the one that closes it). The reference to gdbm is created and initialized within a thread-scoped block to insure this behavior:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="thread"></span>
<span class="python_comment"># use GNU dbm, which definitely doesnt work in </span>
<span class="python_comment"># multiple threads (unless you specify 'u')</span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">gdbm</span><span class="python_operator">
</span><span class="python_name">db </span><span class="python_operator">= </span><span class="python_name">gdbm</span><span class="python_operator">.</span><span class="python_name">open</span><span class="python_enclosure">(</span><span class="python_literal">"weather.dbm"</span><span class="python_operator">, </span><span class="python_literal">'r'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">zipcode</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
temperature in your zip for today is: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">db</span><span class="python_enclosure">[</span><span class="python_name">zipcode</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>Use a thread-scoped block to declare global resources which are not thread-safe. A big candidate for this is a database connection, or an object that contains a database-connection reference, for applications that are not trying too hard to separate their presentation code from their business logic (which, of course, they should be). </p>
<p>Thread-scoped sections can only be used in top-level components, i.e. cannot be used within %def or %method.</p>
</div>
<A name="scopedpython_thread_threadlocal"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Alternative to Thread Scope: ThreadLocal()</span>
<div class="sectiontext">
<p>A possibly higher-performing alternative to a thread-scoped section is to declare thread-local variables via the automatically imported class <span class="codeline">ThreadLocal()</span>. The <span class="codeline">ThreadLocal()</span> class works similarly to a <span class="codeline">Value()</span> object, except that assigning and retrieving its value attaches the data internally to a dictionary, keyed off of an identifier for the current thread. In this way each value can only be accessed by the thread which assigned the value, and other threads are left to assign their own value:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="global"></span>
<span class="python_operator"> </span><span class="python_name">x </span><span class="python_operator">= </span><span class="python_name">ThreadLocal</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">time</span><span class="python_operator">
</span><span class="python_name">x</span><span class="python_operator">.</span><span class="python_name">assign</span><span class="python_enclosure">(</span><span class="python_literal">"the current time is " </span><span class="python_operator">+ </span><span class="python_name">repr</span><span class="python_enclosure">(</span><span class="python_name">time</span><span class="python_operator">.</span><span class="python_name">time</span><span class="python_enclosure">()))</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
value of x: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">x</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p><span class="codeline">ThreadLocal()</span> also supports automatic creation of its value per thread, by supplying a pointer to a function to the parameter <span class="codeline">creator</span>. Here is the above gdbm example with <span class="codeline">ThreadLocal()</span>, using an anonymous (lambda) creation function to automatically allocate a new <span class="codeline">gdbm</span> handle per thread:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="global"></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">gdbm</span><span class="python_operator">
</span><span class="python_name">db </span><span class="python_operator">= </span><span class="python_name">ThreadLocal</span><span class="python_enclosure">(</span><span class="python_name">creator </span><span class="python_operator">= </span><span class="python_keyword">lambda</span><span class="python_operator">: </span><span class="python_name">gdbm</span><span class="python_operator">.</span><span class="python_name">open</span><span class="python_enclosure">(</span><span class="python_literal">"weather.dbm"</span><span class="python_operator">, </span><span class="python_literal">'r'</span><span class="python_enclosure">))</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">zipcode</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
temperature in your zip for today is: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">db</span><span class="python_enclosure">()[</span><span class="python_name">zipcode</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
</div>
<a href="#scopedpython" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="globals"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#scopedpython">Scoped <%python> Blocks</a>
|
Next: <a href="#components">Components</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Standard Global Variables</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#globals_globalm">Your Best Friend: <i>m</i></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#globals_globalargs">Your Other Best Friend: <i>ARGS</i></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#globals_globalr">Your Pal: <i>r</i></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#globals_globals">Your Fair Weather Friend: <i>s</i></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#globals_globalcustom">Make your Own Friends</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#globals_globalcustom_assignment">Assignment to Request-Scoped Globals</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Myghty templates and components always have access to a set of global variables that are initialized on a per-request basis. The Myghty request object <i>m</i> is always available, as are the component arguments <i>ARGS</i>. When running with any HTTPHandler-based environment, the HTTP request object <i>r</i> is also available, which in mod_python is the actual mod_python request object, else it is a compatible emulating object. The Myghty session object, or mod_python's own session object, may be configured to be available as the variable <i>s</i>. Finally, any set of user-configured global variables can be defined as well; the value of these globals can be specified on a per-interpreter or per-request basis.</p>
</div>
<A name="globals_globalm"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Your Best Friend: <i>m</i></span>
<div class="sectiontext">
<p><i>m</i> is known as the "request", which represents the runtime context of the template being executed. Its not the same as the HTTP-specific request object <i>r</i> and is mostly agnostic of HTTP. <i>m</i> includes methods for handling output and writing content, calling other components, as well as other services that a template will usually need. The full list of request methods is described in <a href="#request" >The Request</a>.
</p>
</div>
<a href="#globals" class="toclink">back to section top</a>
</div>
<A name="globals_globalargs"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Your Other Best Friend: <i>ARGS</i></span>
<div class="sectiontext">
<p>ARGS represents a dictionary of all arguments sent to the current component. While a component can specify arguments to be available in the component's namespace via the <%args> tag, the ARGS dictionary contains all arguments supplied to a component regardless of them being named in the <%args> section or not.</p>
<p>In the case of a top-level component called in an HTTP context, ARGS contains the full set of client request parameters. Each field is one of: a string, a list of strings, or for handling file upload objects, a Field object (from the FieldStorage API) or a list of Field objects.</p>
<p>For components called by other components, ARGS contains all the arguments sent by the calling component. </p>
<p>In all cases, the HTTP request arguments, or whatever arguments were originally sent to the request, are available via the request member <a href="#request_members_request_args" >request_args</a>.
<p>Component arguments are described in <a href="#components_args" >Component Arguments - the <%args> tag</a>.</p>
</div>
<a href="#globals" class="toclink">back to section top</a>
</div>
<A name="globals_globalr"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Your Pal: <i>r</i></span>
<div class="sectiontext">
<p>When running Myghty with any of the HTTPHandlers, i.e. ApacheHandler, CGIHandler, WSGIHandler, or HTTPServerHandler, variable <i>r</i> is a reference to either the mod python request object or a compatible emulation object. In the case of ApacheHandler, it is the actual mod_python request. In other cases, it attempts to provide a reasonably compatible interface, including the member variables headers_in, headers_out, err_headers_out, args, content_type, method, path_info, and filename (more can be added...just ask/submit patches). The request object is useful applications that need awareness of HTTP-specific concepts, such as headers and cookies, beyond what the more generic <i>m</i> object provides which attempts to be largely agnostic with regards to HTTP.</p>
<p>
Under WSGIHandler, <i>r</i> also contains the member variables <span class="codeline">environ</span> and <span class="codeline">start_response</span>, so that an application may also have direct access to WSGI-specific constructs if needed.
</p>
</div>
<a href="#globals" class="toclink">back to section top</a>
</div>
<A name="globals_globals"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Your Fair Weather Friend: <i>s</i></span>
<div class="sectiontext">
<p><i>s</i> references the Myghty session object. It can also be configured to reference the mod_python session object when running with mod_python 3.1 To use <i>s</i>, you need to turn it on via <a href="#session_options_use_session" >use_session</a>.
</p>
<p>The Myghty session is still available even if <i>s</i> is not configured. See the section <a href="#session" >Session</a> for full information on the session object.
</div>
<a href="#globals" class="toclink">back to section top</a>
</div>
<A name="globals_globalcustom"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Make your Own Friends</span>
<div class="sectiontext">
<p>Myghty supports the addition of any number of global variables that will be compiled into the namespace of all templates. The value of these variables can be specified on a per-application basis or a per-request basis. As of version 0.98, both scopes can be used simultaneously. Per-application globals can be specified via the initial interpreter configurational parameters, or within the httpd.conf file in a mod_python environment. Per-request globals require that the variables be initialized before the Myghty request begins, which requires programmatic "chaining" to the Interpreter via the methods described in <a href="#configuration_programmatic" >Programmatic Configuration</a>.
</p>
<p>The two configuration parameters to add global arguments are <span class="codeline">allow_globals</span>, which specifies a list of global variable names to compile into templates, and <span class="codeline">global_args</span>, which is a dictionary containing the names of the variables mapped to their desired values. A basic example of programmatic global variables looks like:
</p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">application</span><span class="python_enclosure">(</span><span class="python_name">environ</span><span class="python_operator">, </span><span class="python_name">start_response</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_operator"> </span><span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">WSGIHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
<span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
<span class="python_name">component_root</span><span class="python_operator">=</span><span class="python_literal">'/path/to/htdocs'</span><span class="python_operator">, </span>
<span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/datadirectory'</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span>
<span class="python_name">environ</span><span class="python_operator">, </span>
<span class="python_name">start_response</span><span class="python_operator">,</span>
<span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal' </span><span class="python_operator">: </span><span class="python_literal">'hi'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>Above, all Myghty components will have access to the global variable "myglobal" which has a per-request value of "hi". Note that the <span class="codeline">allow_globals</span> parameter is only used on the first request, when constructing a new Interpreter object, whereas <span class="codeline">global_args</span> may be specified for each request.</p>
<p>Another example, using Interpreter:</p>
<div class="code">
<pre><span class="python_name">interpreter </span><span class="python_operator">= </span><span class="python_name">interp</span><span class="python_operator">.</span><span class="python_name">Interpreter</span><span class="python_enclosure">(</span>
<span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
<span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_literal">'/path/to/datadir'</span><span class="python_operator">,</span>
<span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">'/foo/components'</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">(</span><span class="python_literal">"file.myt"</span><span class="python_operator">, </span>
<span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal'</span><span class="python_operator">:</span><span class="python_name">MyGlobalThingy</span><span class="python_enclosure">()}</span>
<span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>Here is an ApacheHandler example which specifies globals within both scopes:</p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">http</span><span class="python_operator">.</span><span class="python_name">ApacheHandler </span><span class="python_keyword">as </span><span class="python_name">ApacheHandler</span><span class="python_operator">
</span>
<span class="python_comment"># create per-application global object</span>
<span class="python_name">appglobal </span><span class="python_operator">= </span><span class="python_literal">'myappglobal'</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># create per-request global object</span>
<span class="python_operator"> </span><span class="python_name">myglob </span><span class="python_operator">= </span><span class="python_name">MyGlobal</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_name">handler </span><span class="python_operator">= </span><span class="python_name">ApacheHandler</span><span class="python_operator">.</span><span class="python_name">get_handler</span><span class="python_enclosure">(</span>
<span class="python_name">req</span><span class="python_operator">, </span>
<span class="python_name">allow_globals </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'appglobal'</span><span class="python_operator">, </span><span class="python_literal">'myglobal'</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
<span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'appglobal' </span><span class="python_operator">: </span><span class="python_name">appglobal</span><span class="python_enclosure">}</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_keyword">return </span><span class="python_name">handler</span><span class="python_operator">.</span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_operator">, </span><span class="python_name">global_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'myglobal'</span><span class="python_operator">:</span><span class="python_name">myglob</span><span class="python_enclosure">})</span><span class="python_operator"></span></pre></div>
<p>Here is an application-scoped global added in a mod_python environment via the httpd.conf file:</p>
<div class="code">
<pre># specify list of global variable names
PythonOption MyghtyAllowGlobals ['myglobal']
# specify the value of the global variable
PythonOption MyghtyGlobalArgs "{'myglobal': \
__import__('mystuff.util').util.MyGlobalThingy()}"</pre></div>
</div>
<A name="globals_globalcustom_assignment"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Assignment to Request-Scoped Globals</span>
<div class="sectiontext">
<p>When the <span class="codeline">allow_globals</span> configuration parameter specifies global variables to be compiled into all templates, if the variable is not present at request time, it is assigned the value of <span class="codeline">None</span> (as of 0.98a). This is handy for global variables whos value is not determined until within a request.
</p>
<p>To assign to a global variable, use <span class="codeline">m.global_args</span>:</p>
<div class="code">
<pre><span class="doctag"># assume the configuration parameter global_args = ['x','y','z'] is set
</span><span class="compcall"><& </span><span class="compname">hi </span><span class="compcall">&></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">global_args</span><span class="python_enclosure">[</span><span class="python_literal">'x'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'im x!'</span><span class="python_operator"></span>
<span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">global_args</span><span class="python_enclosure">[</span><span class="python_literal">'y'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'im y!'</span><span class="python_operator"></span>
<span class="compcall"><& </span><span class="compname">hi </span><span class="compcall">&></span><span class="text">
</span><span class="deftag"><%def</span><span class="compname"> hi</span><span class="deftag">></span><span class="text">
x is '</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">x</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">'
y is '</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">y</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">'
z is '</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">z</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">'
</span><span class="deftag"></%def></span></pre></div>
<p>this will produce:
</p>
<div class="code">
<pre><span class="text">x is: ''
y is: ''
z is: ''
x is: 'im x!'
y is: 'im y!'
z is: ''</span></pre></div>
</div>
<a href="#globals" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="components"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#globals">Standard Global Variables</a>
|
Next: <a href="#modulecomponents">Module Components</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Components</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#components_example">Component Calling Example</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_pathscheme">Component Path Scheme</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_args">Component Arguments - the <%args> tag</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_args_argscope">Argument Scope: component/request/subrequest/dynamic</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#components_subcomponent">How to Define a Subcomponent</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_subcomponent_calling">Calling a Subcomponent</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#components_method">How to Define a Method</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_method_calling">Calling a Method</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#components_closure">How to Define a Closure</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_flags">Subcomponent Flags</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_callwithcontent">Component Calls with Content</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_programmatic">Calling Components Programmatically</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_comp">m.comp(component, **params)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_scomp">m.scomp(component, **params)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_subrequests">Subrequests</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#components_programmatic_callself">call_self(buffer, retval)</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#components_methods">Component Methods</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#components_members">Component Members</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>All templates in Myghty are referred to as "Components". Components, while they may look like plain HTML pages with a few lines of Python in them, are actually callable units of code which have their own properties, attributes, input arguments, and return values. One can think of a Component anywhere within the spectrum between "HTML page" and "callable Python object", and use it in either way or a combination of both.</p>
<p>A single template, while it is a component itself, also can contain other components within it, which are referred to as "subcomponents", and a subcategory of subcomponents called "methods". The template's component itself is called a "file-based component", and when it is the main component referenced by a request it is also known as the "top level component".</p>
<p>When a component is instantiated within the runtime environment, it is a Python object with the usual reference to "self" as well as its own attributes and methods, and the body of the component occurs within a function call on that object. All components extend from the base class <span class="codeline">myghty.component.Component</span>. File-based components extend from <span class="codeline">myghty.component.FileComponent</span> and subcomponents extend from <span class="codeline">myghty.component.SubComponent</span>.
<p>Additionally, unique to Myghty is a non-template form of component called a "module component", which is written instead as a regular Python class. These components are described in the next section, <a href="#modulecomponents" >Module Components</a>, extending from the class <span class="codeline">myghty.component.ModuleComponent</span>.</p>
</div>
<A name="components_example"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Calling Example</span>
<div class="sectiontext">
<p>The most basic component operation is to have one template call another. In the simplest sense, this is just an HTML include, like a server side include. To have a template "page.myt" call upon another template "header.myt":</p>
<div class="code">
<div class="codetitle">page.myt</div>
<pre><span class="text"><html>
</span><span class="compcall"><& </span><span class="compname">header.myt </span><span class="compcall">&></span><span class="text">
<body>
... rest of page
</body>
</html></span></pre></div>
<div class="code">
<div class="codetitle">header.myt</div>
<pre><span class="text"><head>
<title>header</title>
</head></span></pre></div>
<p>Produces:</p>
<div class="code">
<pre><html>
<head>
<title>header</title>
</head>
<body>
... rest of page
</body>
</html></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_pathscheme"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Path Scheme</span>
<div class="sectiontext">
<p>
When calling components, the path to the component is given as an environment-specific URI, and not an actual filesystem path. While the path can be specified as absolute, it is still determined as relative to one or more of the configured Myghty component roots. Myghty uses the <a href="#parameters_component_root" >component_root</a> parameter as a list of filesystem paths with which to search for the requested component. If a relative path is used, the path is converted to an absolute path based on its relation to the location of the calling component, and then matched up against the list of component roots.
</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_args"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Arguments - the <%args> tag</span>
<div class="sectiontext">
<p>Components, since they are really Python functions, support argument lists. These arguments are supplied to the top-level component from the client request arguments, such as via a POST'ed form. When a component is called from another component, the calling component specifies its own local argument list to be sent to the called component.</p>
<p>A component can access all arguments that were sent to it by locating them in the ARGS dictionary. More commonly, it can specify a list of arguments it would like to receive as local variables via the <%args> tag:</p>
<div class="code">
<pre><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator">
</span><span class="python_name">password</span><span class="python_operator">
</span>
<span class="python_comment"># sessionid defaults to None</span>
<span class="python_name">sessionid </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">sessionid </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">sessionid </span><span class="python_operator">= </span><span class="python_name">create_sid</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">if </span><span class="python_name">password </span><span class="python_operator">!= </span><span class="python_name">get_password</span><span class="python_enclosure">(</span><span class="python_name">username</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"loginfailed.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>In the above example, the 'username' and 'password' arguments are required; if they are not present in the argument list sent to this component, an error will be raised. The 'sessionid' argument is given a default value, so it is not required in the argument list.</p>
<P>A component like the one above may be called with a URL such as:</p>
<div class="code">
<pre>http://foo.bar.com/login.myt?username=john&password=foo&sessionid=57347438</pre></div>
<p>The values sent in an <%args> section are analgous to a Python function being called with named parameters. The above set of arguments, expressed as a Python function, looks like this:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">do_run_component</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">username</span><span class="python_operator">, </span><span class="python_name">password</span><span class="python_operator">, </span><span class="python_name">sessionid </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:</span></pre></div>
<p>What this implies is that the default value sent for "sessionid" only takes effect within the body of the component. It does <b>not</b> set a default value for "sessionid" anywhere else. Different components could easily set different default values for "sessionid" and they would all take effect if "sessionid" is not present in the argument list.</p>
<p>Components can pass argument lists to other components when called. Below, a component 'showuser.myt' is called by another component 'page.myt':</p>
<div class="code">
<div class="codetitle">showuser.myt</div>
<pre><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator">
</span><span class="python_name">email</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
Username: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"><br/>
Email: <a href="mailto:</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">email</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">"></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">email</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></a><br/></span></pre></div>
<div class="code">
<div class="codetitle">page.myt</div>
<pre><span class="text">Login information:
</span><span class="compcall"><& </span><span class="compname">showuser.myt</span><span class="python_operator">, </span><span class="python_name">username</span><span class="python_operator">=</span><span class="python_literal">'john'</span><span class="python_operator">, </span><span class="python_name">email</span><span class="python_operator">=</span><span class="python_literal">'jsmith@foo.com'</span><span class="python_operator"> </span><span class="compcall">&></span></pre></div>
<p>The component call tags "<& &>" take a named-parameter list just like a Python function, and can also have as the very last argument dictionary with ** notation just like in regular Python:</p>
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">comp.myt</span><span class="python_operator">, </span><span class="python_name">arg1</span><span class="python_operator">=</span><span class="python_number">3.7</span><span class="python_operator">, **</span><span class="python_name">ARGS</span><span class="python_operator"> </span><span class="compcall">&></span></pre></div>
<p>Above, the dictionary ARGS always has a list of all arguments sent to the component, regardless of whether or not they were specified in the <%args> section. This is a way of passing through "anonymous" arguments from a component's caller to its components being called.</p>
</div>
<A name="components_args_argscope"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Argument Scope: component/request/subrequest/dynamic</span>
<div class="sectiontext">
<p>So far we have talked about "component-scoped" arguments, that is, the list of arguments that are sent directly to a component by its caller. While the very first component called in a request (i.e. the top-level component) will receive the client request arguments as its component-scoped arguments, any further component calls will only receive the arguments sent by its direct caller.</p>
<p>To make it easier for all components to see the original request arguments, the attribute <span class="codeline">scope="request"</span> may be specified in any <%args> section to indicate that arguments should be taken from the original request, and not the immediate caller. Normally, the default value of <span class="codeline">scope</span> is <span class="codeline">component</span>, indicating that only the immediate component arguments should be used.</p>
<div class="code">
<pre><span class="argstag"><%args scope="request"></span>
<span class="python_operator"> </span><span class="python_name">sessionid</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
</span><span class="argstag"><%args scope="component"></span>
<span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
hello </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">, to edit your preferences click
<a href="prefs.myt?sessionid=</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">sessionid</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">">here</a>.</span></pre></div>
<p>Above, the argument "sessionid" must be sent by client request, but the argument "username" must be sent by the calling component. If this component is called as the top-level component, both arguments must be present in the client request.</p>
<p>
Request arguments are also always available via the <a href="#request_members_request_args" >request_args</a> and <a href="#request_members_root_request_args" >root_request_args</a> members of the request object.
</p>
<p>Note that there is special behavior associated with request-scoped arguments when using subrequests (described later in this section). Since a subrequest is a "request within a request", it is not clear whether the "request" arguments should come from the originating request, or the immediate, "child" request. The attribute <span class="codeline">scope="subrequest"</span> indicates that arguments should be located in the immediate request, whether or not it is a subrequest, in contrast to <span class="codeline">scope="request"</span> which always refers to the arguments of the ultimate root request. Subrequests are described in the section <a href="#components_programmatic_subrequests" >Subrequests</a> below.
</p>
<p>
The component that wants to be flexible about its arguments may also specify its arguments with "dynamic" scope. In dynamic scope, the argument is located within the most local arguments first, and then upwards towards the request until found. The following component will retrieve its arguments locally if present, or if not, from the request, no matter where it is called:
</p>
<div class="code">
<pre><span class="argstag"><%args scope="dynamic"></span>
<span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator">
</span><span class="python_name">email</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
hello </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">, your email address is </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">email</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">.</span></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
</div>
<A name="components_subcomponent"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">How to Define a Subcomponent</span>
<div class="sectiontext">
<p>A subcomponent is a component defined within a larger template, and acts as a callable "subsection" of that page. Subcomponents support almost all the functionality of a file-based component, allowing Python blocks of init, cleanup and component scope, but not global, request or thread scope.</p>
<p>A subcomponent, albeit a nonsensical one, looks like this:</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> mycomponent</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">arg1 </span><span class="python_operator">= </span><span class="python_literal">'foo'</span><span class="python_operator">
</span><span class="python_name">arg2 </span><span class="python_operator">= </span><span class="python_literal">'bar'</span><span class="python_operator">
</span> <span class="argstag"></%args></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_name">string </span><span class="python_operator">= </span><span class="python_name">arg1 </span><span class="python_operator">+ </span><span class="python_literal">" " </span><span class="python_operator">+ </span><span class="python_name">arg2</span><span class="python_operator">
</span> <span class="blocktag"></%python></span><span class="text">
i am mycomponent !
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">string</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</span><span class="deftag"></%def></span></pre></div>
<p>A regular subcomponent like this one is always called by another component, i.e. it can never be called directly from the request as a top-level component. Furthermore, subcomponents defined with the <span class="codeline"><%def></span> tag are private to the template file they appear in.</p>
<p>The subcomponent has access to all global variables, such as <i>m</i> and <i>r</i>, but it does not have access to the local variables of its containing component. This would include variables specified in the body of the main component, i.e. in init-, cleanup- and component-scoped <%python> blocks. Variables declared in global-, request- and thread-scoped <%python> blocks are available within subcomponents, subject to the restrictions on variables declared in those blocks. Variables declared within the body of a subcomponent remain local to that subcomponent.</p>
</div>
<A name="components_subcomponent_calling"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Calling a Subcomponent</span>
<div class="sectiontext">
<p>Subcomponents are called in a similar manner as a file-based component:</p>
<div class="code">
<pre><span class="text">welcome to </span><span class="compcall"><& </span><span class="compname">title</span><span class="python_operator">, </span><span class="python_name">username</span><span class="python_operator">=</span><span class="python_literal">'john'</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="deftag"><%def</span><span class="compname"> title</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator">
</span> <span class="argstag"></%args></span><span class="text">
<b>bling bling bling </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">username</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"> bling bling bling</b
</span><span class="deftag"></%def></span></pre></div>
<p>Note that a subcomponent can be defined at any point in a template and is still available throughout the entire template.</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
</div>
<A name="components_method"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">How to Define a Method</span>
<div class="sectiontext">
<p>A method is similar to a subcomponent, except its functionality is available outside of the file it appears in, and it can take advantage of inheritance from other template files. </p>
<div class="code">
<pre><span class="deftag"><%method</span><span class="compname"> imamethod</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">radius</span><span class="python_operator">
</span><span class="python_name">coeffiecient </span><span class="python_operator">= </span><span class="python_number">.5424</span><span class="python_operator">
</span> <span class="argstag"></%args></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_name">foob </span><span class="python_operator">= </span><span class="python_name">call_my_func</span><span class="python_enclosure">(</span><span class="python_name">radius</span><span class="python_operator">, </span><span class="python_name">coefficient</span><span class="python_enclosure">)</span><span class="python_operator">
</span> <span class="blocktag"></%python></span><span class="text">
fractional fizzywhatsle: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">foob</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</span><span class="deftag"></%method></span></pre></div>
</div>
<A name="components_method_calling"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Calling a Method</span>
<div class="sectiontext">
<p>A method can be called from within the file it appears in the same fashion as a subcomponent, i.e. simply by its name, in which case it is located in the same way as a subcomponent. The other format of method calling is <location>:<methodname>, where <i>location</i> specifies what component to initially search for the method in. The location may be specified as the URI of the desired component file, or one of the special keywords SELF, REQUEST, or PARENT.</p>
<div class="code">
<pre><span class="doctag"># call the method print_date in
</span><span class="doctag"># component file /lib/functions.myt
</span><span class="compcall"><& </span><span class="compname">/lib/functions.myt:print_date</span><span class="python_operator">, </span><span class="python_name">date</span><span class="python_operator">=</span><span class="python_literal">"3/12/2004"</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="doctag"># call a method in the local template
</span><span class="compcall"><& </span><span class="compname">tablerow</span><span class="python_operator">, </span><span class="python_name">content</span><span class="python_operator">=</span><span class="python_literal">"cell content"</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="doctag"># call a method in the base component, taking
</span><span class="doctag"># advantage of inheritance
</span><span class="compcall"><& </span><span class="compname">SELF:printtitle </span><span class="compcall">&></span></pre></div>
<p>
With the compound method calling format, if the method is not located in the specified component, the component's inherited parent will be searched, and in turn that component's inherited parent, etc., until no more parents exist. The parent-child relationship of components, as well as the keywords SELF, REQUEST, and PARENT are described in the section <a href="#inheritance" >Inheritance</a>.</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
</div>
<A name="components_closure"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">How to Define a Closure</span>
<div class="sectiontext">
Version 0.98 introduces a lightweight alternative to %def and %method called <span class="codeline"><%closure></span>. This tag defines a local function definition using Python keyword <span class="codeline">def</span>, which is callable via the same mechanism as that of subcomponents. A closure is in fact not a component at all and can only be used within the block that it is defined, and also must be defined before it is called. It offers the advantage that it is created within the scope of the current code body, and therefore has access to the same variable namespace:
<div class="code">
<pre><span class="blocktag"><%closure format_x></span>
<span class="python_operator"> <%</span><span class="python_name">args</span><span class="python_operator">>
</span><span class="python_name">format </span><span class="python_operator">= </span><span class="python_literal">'%d'</span><span class="python_operator">
</%</span><span class="python_name">args</span><span class="python_operator">>
<% </span><span class="python_name">format </span><span class="python_operator">% </span><span class="python_name">x </span><span class="python_operator">%>
</span><span class="blocktag"></%closure></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">x </span><span class="python_keyword">in </span><span class="python_enclosure">(</span><span class="python_number">1</span><span class="python_operator">,</span><span class="python_number">2</span><span class="python_operator">,</span><span class="python_number">3</span><span class="python_enclosure">)</span><span class="python_operator">:</span>
<span class="text"> </span><span class="compcall"><& </span><span class="compname">format_x</span><span class="python_operator">, </span><span class="python_name">format</span><span class="python_operator">=</span><span class="python_literal">'X:%d'</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"></span></pre></div>
<p>Closures support the <%args> tag, as well as <a href="#scopedpython_init" >Init Scope</a> and <a href="#scopedpython_cleanup" >Cleanup Scope</a>. Closures can also be nested. They currently do not support the "component call with content" calling style but this may be added in the future.</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_flags"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Subcomponent Flags</span>
<div class="sectiontext">
<p>Subcomponents and methods also may specify flags as described in the section <a href="#otherblocks_flags" ><%flags></a>. The most useful flags for a subcomponent are the <span class="codeline">trim</span> and <span class="codeline">autoflush</span> flags, described in <a href="#filtering" >Filtering and Flushing (and Escaping)</a>.</p>
<p>There are two formats for specifing flags in a subcomponent:</p>
<div class="code">
<pre><span class="text">
# traditional way
</span><span class="deftag"><%def</span><span class="compname"> buffered</span><span class="deftag">></span><span class="text">
</span><span class="blocktag"><%flags></span>
<span class="python_operator"> </span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_operator">
</span> <span class="blocktag"></%flags></span><span class="text">
this is a buffered component
</span><span class="deftag"></%def></span><span class="text">
# inline-attribute way
</span><span class="deftag"><%method</span><span class="compname"> hyperlink trim="both"</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">link</span><span class="python_operator">
</span><span class="python_name">name</span><span class="python_operator">
</span> <span class="argstag"></%args></span><span class="text">
<a href="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">link</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">">name</a>
</span><span class="deftag"></%method></span></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_callwithcontent"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Calls with Content</span>
<div class="sectiontext">
<p>Subcomponents and methods can also be called with a slightly different syntax, in a way that allows the calling component to specify a contained section of content to be made available to the called component as a Python function. Any subcomponent can query the global <i>m</i> object for a function that executes this content, if it is present. When the function is called, the code sent within the body of the component call with content is executed; this contained code executes within the context and namespace of the calling component.</p>
<div class="code">
<pre><span class="compcall"><&|</span><span class="compname"> printme </span><span class="compcall">&></span><span class="text">
i am content that will be grabbed by PRINTME.
</span><span class="compcall"></&></span></pre></div>
<P>The called component can then reference the contained content like this:</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> printme</span><span class="deftag">></span><span class="text">
I am PRINTME, what do you have to say ?<br/>
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">content</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</span><span class="deftag"></%def></span></pre></div>
<p>The method <span class="codeline">m.content()</span> executes the code contained within the <&| &>/</&> tags in its call to "printme", and returns it as a string. A component may query the request object <i>m</i> for the presense of this function via the method <span class="codeline">m.has_content()</span>.</p>
<p>A component call with content is one of the most powerful features of Myghty, allowing the creation of custom tags that can produce conditional sections, iterated sections, content-grabbing, and many other features. It is similar but not quite the same as the template inheritance methodology, in that it allows the body of a component to be distilled into a callable function passed to an enclosing component, but it involves a client explicitly opting to wrap part of itself in the body of another component call, rather than a client implicitly opting to wrap its entire self in the body of another component call.
</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_programmatic"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Calling Components Programmatically</span>
<div class="sectiontext">
<p>The special component calling tags described above are just one way to call components. They can also be called directly off of the request object <i>m</i>, which is handy both for calling components within %python blocks as well as for capturing either the return value or the resulting content of a subcomponent. Component objects can also be directly referenced and executed via these methods.
</p>
<p>The full index of request methods and members can be found in <a href="#request" >The Request</a>.</p>
</div>
<A name="components_programmatic_comp"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">m.comp(component, **params)</span>
<div class="sectiontext">
<p>This method allows you to call a component just like in the regular way except via Python code. The arguments are specified in the same way to the function's argument list. The output will be streamed to the component's output stream just like any other content. If the component specifies a return value, it will be returned. A component, since it is really just a python function, can have a return value simply by using the python statement <span class="codeline">return</span>. The value of <i>component</i> can be an actual component object obtained via <span class="codeline">fetch_component()</span>, or a string specifying a filesystem path or local subcomponent or method location.</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">'/foo/bar.myt'</span><span class="python_operator">, </span><span class="python_name">arg1</span><span class="python_operator">=</span><span class="python_literal">'hi'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_programmatic_scomp"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">m.scomp(component, **params)</span>
<div class="sectiontext">
<p>This method is the same as "comp" except the output of the component is captured in a separate buffer and returned as the return value of scomp().</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_name">component </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">fetch_component</span><span class="python_enclosure">(</span><span class="python_literal">'mycomponent'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">content </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">scomp</span><span class="python_enclosure">(</span><span class="python_name">component</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"<pre>" </span><span class="python_operator">+ </span><span class="python_name">content </span><span class="python_operator">+ </span><span class="python_literal">"</pre>"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_programmatic_subrequests"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Subrequests</span>
<div class="sectiontext">
<p>
A subrequest is an additional twist on calling a component, it calls the component with its own request object that is created from the current request. A subrequest is similar to an internal redirect which returns control back to the calling page. The subrequest has its own local argument list as well, separate from the original request arguments.
</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'/my/new/component.myt'</span><span class="python_operator">, </span><span class="python_name">arg1</span><span class="python_operator">=</span><span class="python_literal">'hi'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>The <span class="codeline">subexec</span> method takes either a string URI or a component object as its first argument, and
the rest of the named parameters are sent as arguments to the component.</p>
<p>Use subrequests to call a component when you want its full inheritance chain, i.e. its autohandlers, to be called as well.</p>
<p>The <span class="codeline">subexec</span> method is comprised of several more fine-grained methods as illustrated in this example:</p>
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_comment"># get a component to call</span>
<span class="python_operator"> </span><span class="python_name">component </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">fetch_component</span><span class="python_enclosure">(</span><span class="python_literal">'mysubreq.myt'</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># make_subrequest - </span>
<span class="python_comment"># first argument is the component or component URI,</span>
<span class="python_comment"># following arguments are component arguments</span>
<span class="python_name">subreq </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">make_subrequest</span><span class="python_enclosure">(</span><span class="python_name">component</span><span class="python_operator">, </span><span class="python_name">arg1 </span><span class="python_operator">= </span><span class="python_literal">'foo'</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># execute the request. return value is sent</span>
<span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">subreq</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>The make_subrequest method can also be called as create_subrequest, which in addition
to supporting component arguments, lets you specify all other request object arguments as well:
<div class="code">
<pre><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">StringIO</span><span class="python_operator">
</span>
<span class="python_comment"># get a component to call</span>
<span class="python_name">component </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">fetch_component</span><span class="python_enclosure">(</span><span class="python_literal">'mysubreq.myt'</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># make a subrequest with our own </span>
<span class="python_comment"># output buffer specified </span>
<span class="python_name">buf </span><span class="python_operator">= </span><span class="python_name">StringIO</span><span class="python_operator">.</span><span class="python_name">StringIO</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">subreq </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">create_subrequest</span><span class="python_enclosure">(</span><span class="python_name">component</span><span class="python_operator">, </span>
<span class="python_name">out_buffer </span><span class="python_operator">= </span><span class="python_name">buf</span><span class="python_operator">,</span>
<span class="python_name">request_args </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'arg1'</span><span class="python_operator">:</span><span class="python_literal">'foo'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># execute the request. </span>
<span class="python_comment"># return value is sent, our own buffer</span>
<span class="python_comment"># is populated with the component's </span>
<span class="python_comment"># content output</span>
<span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">subreq</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_operator"></span> <span class="blocktag"></%python></span></pre></div>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_programmatic_callself"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">call_self(buffer, retval)</span>
<div class="sectiontext">
<p>
The "call_self" method is provided so that a component may call itself and receive its own content in a buffer as well as its return value. "call_self" is an exotic way of having a component filter its own results, and is also the underlying method by which component caching operates. Note that for normal filtering of a component's results, Myghty provides a full set of methods described in the section <a href="#filtering_filtering" >Filtering</a>, so call_self should not generally be needed.
</p>
<p>call_self uses a "reentrant" methodology, like this:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">StringIO</span><span class="python_operator">
</span>
<span class="python_comment"># value object to store the return value</span>
<span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">Value</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># buffer to store the component output</span>
<span class="python_name">buffer </span><span class="python_operator">= </span><span class="python_name">StringIO</span><span class="python_operator">.</span><span class="python_name">StringIO</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_keyword">if </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_self</span><span class="python_enclosure">(</span><span class="python_name">buffer</span><span class="python_operator">, </span><span class="python_name">ret</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"woop! call self !" </span><span class="python_operator">+ </span>
<span class="python_name">buffer</span><span class="python_operator">.</span><span class="python_name">getvalue</span><span class="python_enclosure">() </span><span class="python_operator">+ </span><span class="python_literal">" and we're done"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">ret</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># ... rest of component</span>
<span class="python_operator"></span><span class="blocktag"></%python></span></pre></div>
<p>The initial call to call_self will return True, indicating that the component has been called and its output and return value captured, at which point the component should return. Within the call_self call, the component is executed again; call_self returns False to indicate that the thread of execution is "inside" of the initial call_self and that content is being captured.</p>
<p>It is recommended that call_self be called only in an init-scoped Python block before any other content has been written, else that content will be printed to the output as well as captured.</p>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
</div>
<A name="components_methods"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Methods</span>
<div class="sectiontext">
<p>
Instances of Component objects can be accessed many ways from the request object, including the <a href="#request_methods_fetch_component" >fetch_component</a> method, and the
<a href="#request_members_current_component" >current_component</a>,
<a href="#request_members_request_component" >request_component</a>, and
<a href="#request_members_base_component" >base_component</a> members. The <a href="#request_methods_fetch_next" >fetch_next</a> method returns the next component in an inheritance chain. Finally, <span class="codeline">self</span> refers to the current component.
</p>
<P>The methods available directly from <span class="codeline">Component</span> are listed below, followed by the members.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="components_methods_call_method"></a>
<b>call_method(<i>methodname</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Calls a method on the current component, and returns its return value. This method is shorthand for locating the current request via <span class="codeline">request.instance()</span>, locating the method via <span class="codeline">locate_inherited_method()</span> and calling <span class="codeline">m.comp()</span>.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_methods_get_flag"></a>
<b>get_flag(<i>key</i>, <i>inherit=False</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Returns the value of a flag for this component. If "inherit" is True, the value of the flag will be searched for in the chain of parent components, if it is not found locally.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_methods_get_sub_component"></a>
<b>get_sub_component(<i>name</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Returns the subcomponent denoted by <i>name</i>. For a subcomponent or method, returns the subcomponent of the owning (file-based) component. Note this is not for methods; for those, use locate_inherited_method.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_methods_has_filter"></a>
<b>has_filter()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Returns true if this component has a filter section, and or a "trim" flag.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_methods_locate_inherited_method"></a>
<b>locate_inherited_method(<i>name</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Returns the method component associated with <i>name</i>. The method is searched for in the current component and up the inheritance chain. For a subcomponent or method, returns the method of the owning (file-based) component. Note this is not for non-method subcomponents; for those, use get_sub_component().
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_methods_scall_method"></a>
<b>scall_method(<i>methodname</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Calls a method on the current component, captures its content and returns its content as a string. This method is shorthand for locating the current request via <span class="codeline">request.instance()</span>, locating the method via <span class="codeline">locate_inherited_method()</span> and calling <span class="codeline">m.scomp()</span>.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_methods_use_auto_flush"></a>
<b>use_auto_flush()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Returns True or False if this component requires autoflush be turned on or off for its execution, or returns None if no requirement is set. This method searches within the current components flags, or within parent component flags if not present.
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<A name="components_members"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Component Members</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="light">
<td>
<A name="components_members_args"></a>
<b>args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the component-scoped <%args> section, which have a default value specified.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_attr"></a>
<b>attr</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A dictionary of component attributes, corresponding to those set by the <%attr> tag. The attributes can be set at once
by assigning a dictionary to this member. However, to set and retrieve individual attributes, it is best to use the special <a href="#components_members_attributes" >attributes</a> member which takes advantage of inheritance.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_attributes"></a>
<b>attributes</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A dictionary accessor for the <a href="#components_members_attr" >attr</a> dictionary member that locates its members first in the local component attributes, then searches up the inheritance chain for the attribute.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_dir_name"></a>
<b>dir_name</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The web-specific directory name where the current component resides, i.e. for this component its "/". For a subcomponent or method, it is the directory name of the owning (file-based) component.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_file"></a>
<b>file</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The actual filesystem location of a component, for a component that was loaded directly from a Myghty template file, else it is <span class="codeline">None</span>.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_filter"></a>
<b>filter</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Reference to the function that will perform filtering on the component. This filter is directly stated in the <%filter> section described in <a href="#filtering_filtering_filter" >The <%filter> Tag</a>.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_flags"></a>
<b>flags</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Dictionary of flags for this component. Also can be accessed via the <b>get_flag</b> method.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_id"></a>
<b>id</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px"><p>A unique identifier for the current component, which is comprised of the key name for its component root joined with its web-specific path, i.e. for this component its "content|components.myt".
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_is_file_component"></a>
<b>is_file_component</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>True if this component is a file based component.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_is_method_component"></a>
<b>is_method_component</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>True if this component is a method component.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_is_module_component"></a>
<b>is_module_component</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>True if this component is a module component.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_is_sub_component"></a>
<b>is_sub_component</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>True if this component is a subcomponent or method component.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_name"></a>
<b>name</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The filename or name of the current component, i.e. for this component its "components.myt".
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_owner"></a>
<b>owner</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>For a subcomponent or method subcomponent, the owning file-based component, otherwise it is self.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_parent_component"></a>
<b>parent_component</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>For a component in an inheritance chain (i.e. via %flags or via autohandlers), the inheriting component. For a subcomponent or method, returns the parent of the owning (file-based) component. Inheritance is described in <a href="#inheritance" >Inheritance</a>.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_path"></a>
<b>path</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The URI corresponding to the component. For this component its "/components.myt". For a subcomponent or method, it is the URI of the owning (file-based) component.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_request_args"></a>
<b>request_args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the request-scoped <%args scope="request"> section, which do have a default value specified.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_required_args"></a>
<b>required_args</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the component-scoped <%args> section, which do not have a default value specified., i.e. they are required component arguments.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_required_request_args"></a>
<b>required_request_args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the request-scoped <%args scope="request"> section, which do not have a default value specified, i.e. are required request arguments.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="components_members_required_subrequest_args"></a>
<b>required_subrequest_args</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the subrequest-scoped <%args scope="subrequest"> section, which do not have a default value specified, i.e. are required subrequest arguments.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="components_members_subrequest_args"></a>
<b>subrequest_args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of argument names, corresponding to variable names in the subrequest-scoped <%args scope="subrequest"> section, which do have a default value specified.
</div>
</td>
</tr>
</table>
</div>
<a href="#components" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="modulecomponents"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#components">Components</a>
|
Next: <a href="#request">The Request</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Module Components</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#modulecomponents_example">Example Module Component</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#modulecomponents_flavor">Flavors of Module Component</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_function">Function</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_callable">Callable Object</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_method">Object Method</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_flavor_explicit">Class / Explicit Module Component</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#modulecomponents_initialization">Module Component Initialization</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#modulecomponents_controller">Using MCs as Controllers</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#modulecomponents_resolution">Configuring Module Component Resolution</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_components">module_components</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_components_additional">Passing Resolution Arguments</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_root">module_root</a>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_module_root_options">Module Root Options</a>
</div>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_resolution_routesresolver">Routes Resolver</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#modulecomponents_preprocessor">Module Component Pre and Post processing</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#modulecomponents_templates">Using Module Components within Templates</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#modulecomponents_templates_formexample">Example: Form Visitor</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<P>Module components build upon the component concept as introduced and explained in the previous section, <a href="#components" >Components</a>. They represent a way of writing Myghty components using regular Python code within importable .py modules. A module component can be used to handle requests, controlling the flow of an application across one or more templates; this role is known as a "controller". Module components can also be embedded as component calls within templates just like any other component. In both cases, Module Components are the appropriate place to place code-intensive control or view logic.</p>
<p>Module Components, or MC's, are not a new idea, and have analogies in other environments, such as the Java Servlet class, the mod_python handler() function, or the WSGI application() callable. To suit the preferences of the both the class-oriented and the function-oriented developer, MC's can be written either as classes that subclass a specific Myghty class (similar to subclassing the Java Servlet class) or just as a regular Python function or callable object (i.e., an object instance that has a __call__ method). Additionally, individual methods upon a class instance can also be called as MC's. </p>
<p>When a plain Python function, callable object, or arbitrary instance method (herein will be generically referred to as a "callable") is to be called as a Module Component, the resulting component is referred to as an <b>implicit</b> module component. In this case, the Myghty Interpreter is given the location of the callable either via a string pattern or via passing the callable itself, and is told to execute it as a component. The Interpreter then creates a "real" component behind the scenes which <i>proxies</i> the Myghty argument set to the callable. The developer need not be aware of this proxying component (though it is available).
</p>
<p>The flipside to the implicit module component is the <b>explicit</b> module component. Here, the developer creates a class that is a subclass of <span class="codeline">myghty.component.ModuleComponent</span>, and implements the method <span class="codeline">do_run_component()</span>, which satisfies the execution of the component. Like the implicit module component, the Interpreter is given its location either via a string pattern or via the Class object itself, and is told to execute it. The Interpreter, upon receiving a Class object, instantiates the class which becomes directly the component to be executed; no "proxy" component is created.
</p>
<p>The differences between implicit and explicit module components are mostly differences in style. The explicit form allows the developer more direct access to the flags, attributes, and argument lists of the component to be called, whereas the implicit form is more sparse, lightweight and flexible. Both styles can be mixed; essentially, the Intepreter receives the object and determines the calling style based on the type of object passed to it. In all cases, the rest of a Myghty application sees just more <span class="codeline">myghty.component.Component</span> objects, which have the same properties as any other component.
</p>
<p>An added layer of complexity to module components involves the configuration of URI resolution, which allows the mapping of arbitrary URI's to specific module component callables or classes based on different schemes. This is required for MC's that are to be called as the top-level, request-handling component. Myghty currently includes two methods of achieving this, which are described later in this section, as well as an API to allow any user-defined mapping algorithm (part of <a href="#resolver" >Advanced Resolver Configuration</a>).</p>
</div>
<A name="modulecomponents_example"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Example Module Component</span>
<div class="sectiontext">
<p>Lets start with hello world. All we need to do is create a new .py file, called <span class="codeline">hello.py</span>, and place the following function inside it:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">helloworld</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world !"</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>That is the extent of the module component itself. Since it is a plain function, this is an "implicit" module component.</p>
<p>To call the component, the request object is given a string starting with the prefix "MODULE:", followed by the module name and name of the callable or class, separated by a colon. In a template it is one of the following:</p>
<div class="code">
<pre><span class="doctag"># inline
</span><span class="compcall"><& </span><span class="compname">MODULE:hello:helloworld </span><span class="compcall">&></span><span class="text">
</span><span class="doctag"># code
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"MODULE:hello:helloworld"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>Alternatively (release 0.99b), the "MODULE:" prefix can also be an "at" sign as follows:</p>
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">@hello:helloworld </span><span class="compcall">&></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"@hello:helloworld"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>
Both the module name and the callable/class name can contain any number of periods to represent sub-modules or sub-properties of the module. Suppose <span class="codeline">helloworld</span> was a property on an object:
</p>
<div class="code">
<pre><span class="python_name">hello </span><span class="python_operator">= </span><span class="python_name">object</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">doit</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world !"</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">hello</span><span class="python_operator">.</span><span class="python_name">helloworld </span><span class="python_operator">= </span><span class="python_name">doit</span><span class="python_operator"></span></pre></div>
<p>This component can be called as:</p>
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">MODULE:hello:hello.helloworld </span><span class="compcall">&></span></pre></div>
<p>or just:</p>
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">@hello:hello.helloworld </span><span class="compcall">&></span></pre></div>
<p>The callable can have any argument list, and even the <i>m</i> variable is optional (though highly recommended). Myghty uses the <span class="codeline">inspect</span> library to determine the desired arguments based on the callable's signature. (for the performance minded, this is done only once when the component is first loaded). Using the names present in the argument list, Myghty will determine which of the available global variables will be specified, as well as what required and optional component arguments this MC will require. The component arguments are configured in exactly the same way as a template-based component configures its <%ARGS> section.</p>
<P>So to our "hello world" lets add the current and optionally tomorrow's weather:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">helloworld</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">today</span><span class="python_operator">, </span><span class="python_name">tomorrow </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world ! its a %s day today." </span><span class="python_operator">% </span><span class="python_name">today</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">tomorrow </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"Don't know what it is tomorrow, though."</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"But tomorrow, it'll be %s" </span><span class="python_operator">% </span><span class="python_name">tomorrow</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>This component can be called like these examples:</p>
<div class="code">
<pre><span class="doctag"># inline shorthand
</span><span class="compcall"><& </span><span class="compname">@hello:helloworld</span><span class="python_operator">, </span><span class="python_name">today</span><span class="python_operator">=</span><span class="python_literal">'sunny'</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="doctag"># inline longhand
</span><span class="compcall"><& </span><span class="compname">MODULE:hello:helloworld</span><span class="python_operator">, </span><span class="python_name">today</span><span class="python_operator">=</span><span class="python_literal">'sunny'</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">
</span><span class="doctag"># code
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"MODULE:hello:helloworld"</span><span class="python_operator">, </span><span class="python_name">today</span><span class="python_operator">=</span><span class="python_literal">'cloudy'</span><span class="python_operator">, </span><span class="python_name">tomorrow</span><span class="python_operator">=</span><span class="python_literal">'rainy'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>The argument list of a module component may specify any of the standard and/or user-configured global arguments (globals were introduced in <a href="#globals" >Standard Global Variables</a>). All arguments are passed by name, so the ordering is not important:
</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">handle_request</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">ARGS</span><span class="python_operator">, </span><span class="python_name">r</span><span class="python_operator">, </span><span class="python_name">s</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># ...</span><span class="python_operator"></span></pre></div>
<p>The above component specifies that it will receive the global variables <i>m</i>, <i>ARGS</i>, <i>r</i>, and <i>s</i>. It also defines <span class="codeline">**params</span>, so all remaining component arguments will be in this dictionary. A callable that defines simply <span class="codeline">**params</span> will receive <i>all</i> globals and component arguments within the dictionary.</p>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_flavor"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Flavors of Module Component</span>
<div class="sectiontext">
<p>A summary of the various styles of MC are as follows. For each of the below examples, assume the callable exists within a module named <span class="codeline">mylib.hello</span>:</p>
</div>
<A name="modulecomponents_flavor_function"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Function</span>
<div class="sectiontext">
This is the most basic type of implicit module component.
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">helloworld</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world!"</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
Called as:
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">MODULE:mylib.hello:helloworld </span><span class="compcall">&></span></pre></div>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_flavor_callable"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Callable Object</span>
<div class="sectiontext">
<p>A callable object must be instantiated, but to the outside world looks almost the same as a function:</p>
<div class="code">
<pre><span class="python_keyword">class </span><span class="python_name">HelloWorld</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">__call__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world!"</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># instantiate the class</span>
<span class="python_operator"></span><span class="python_name">helloworld </span><span class="python_operator">= </span><span class="python_name">HelloWorld</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
Called as:
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">MODULE:mylib.hello:helloworld </span><span class="compcall">&></span></pre></div>
Note that this is identical to the previous function example.
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_flavor_method"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Object Method</span>
<div class="sectiontext">
The object method is set up similarly to a callable object, the only difference being that a specific named method is called, instead of the generic <span class="codeline">__call__</span> method. The difference lies in how it is specified when called.
<div class="code">
<pre><span class="python_keyword">class </span><span class="python_name">HelloWorld</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">doit</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world!"</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># instantiate the class</span>
<span class="python_operator"></span><span class="python_name">helloworld </span><span class="python_operator">= </span><span class="python_name">HelloWorld</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
Called as:
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">MODULE:mylib.hello:helloworld.doit </span><span class="compcall">&></span></pre></div>
One particular quirk about the object method style is that if an object instance contains multiple methods that are called as MC's, the interpreter creates a <i>separate</i> "proxy" component for each method.</p>
<p>With both callable object styles, the <i>same</i> object instance handles <i>many</i> requests, including multiple simultaneous requests among different threads, if the application is running in a threaded environment. A developer should take care to store request-scoped information as attributes upon the request object and <i>not</i> as instance variables of the object, as well as to appropriately synchronize access to instance variables and module attributes.
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_flavor_explicit"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class / Explicit Module Component</span>
<div class="sectiontext">
<p>This style works differently from the previously mentioned styles, in that the developer is writing a class directly against the Myghty API. In this style, the developer directly defines the class of the component that is ultimately being accessed by the outside world. No "proxying" component is created; instead, the Interpreter instantiates the specified class the first time it is referenced. This also removes the need to explicitly instantiate the class:
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">component</span><span class="python_operator">
</span>
<span class="python_keyword">class </span><span class="python_name">HelloWorld</span><span class="python_enclosure">(</span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">component</span><span class="python_operator">.</span><span class="python_name">ModuleComponent</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">do_run_component</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world!"</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
Called as:
<div class="code">
<pre><span class="compcall"><& </span><span class="compname">MODULE:mylib.hello:HelloWorld </span><span class="compcall">&></span></pre></div>
<p>Note that the scoping rules for this style of component are the same, i.e. the same component instance is called for many requests and must be aware of variable scope as well as concurrency issues.</p>
<p>The <span class="codeline">do_run_component</span> method works similarly to the callable of an implicit component. Its argument list is dynamically inspected to determine the desired globals and component arguments, in the same way as that of implicit MC's. However, there also is the option to bypass this inspection process and name the arguments explicitly, as well as their desired scope. In previous versions of Myghty, this was the only way to define the arguments of an MC, but now its only optional. This method is described in the next section, as well as the configuration of flags and attributes for MC's.
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
</div>
<A name="modulecomponents_initialization"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module Component Initialization</span>
<div class="sectiontext">
<p>Explicit MCs as well as implicit MCs based on an object instance have an optional initialization step that is called the first time the object instance is referenced. The method is called on an explicit ModuleComponent subclass as:
</p>
<span class="code">def do_component_init(self)</span>
<p>
And is called on an implicit callable object as:
</p>
<span class="code">def do_component_init(self, component)</span>
<p>In the second version, the argument <span class="codeline">component</span> is an instance of <span class="codeline">myghty.component.FunctionComponent</span> that is <b>hosting</b> the implicit module component's <span class="codeline">__call__</span> method or other method. It is important to note that an object instance with many callable methods will actually have many FunctionComponents created, each one hosting an individual methods...<b>however</b>, the do_component_init() method is only called <b>once</b> with whatever FunctionComponent was first associated with the object.</p>
<p> In previous versions of Myghty, the initialization phase was required for components with arguments, which had to be explicitly declared within this stage. As of version 0.98, explicit declaration of component arguments is optional, and the argument lists are by default determined from the signature of the explicit <span class="codeline">do_run_component</span> method or the implicit callable.</p>
<p>Explicit specification of an MCs arguments in the init section are as follows:</p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">component </span><span class="python_keyword">as </span><span class="python_name">component</span><span class="python_operator">
</span>
<span class="python_keyword">class </span><span class="python_name">MyComponent</span><span class="python_enclosure">(</span><span class="python_name">component</span><span class="python_operator">.</span><span class="python_name">ModuleComponent</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">do_component_init</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># component arguments</span>
<span class="python_operator"> </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'arg1'</span><span class="python_operator">, </span><span class="python_literal">'arg2'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># required component arguments</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">required_args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'arg3'</span><span class="python_operator">, </span><span class="python_literal">'arg4'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># request-only arguments</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">request_args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'docid'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># required request-only arguments</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">required_request_args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'userid'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># subrequest or request arguments</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">subrequest_args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'foo'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># required subrequest or request arguments</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">required_subrequest_args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'bar'</span><span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>
A component as above would have the <span class="codeline">do_run_component</span> signature as follows:
</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">do_run_component</span><span class="python_enclosure">(</span>
<span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">userid</span><span class="python_operator">, </span><span class="python_name">arg3</span><span class="python_operator">, </span><span class="python_name">arg4</span><span class="python_operator">, </span><span class="python_name">bar</span><span class="python_operator">, </span>
<span class="python_name">docid </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">arg1 </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">arg2 </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">foo </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, **</span><span class="python_name">params</span>
<span class="python_enclosure">)</span><span class="python_operator">:</span></pre></div>
<p>Note that if a module component defines any arguments explicitly in the do_component_init method, all arguments for the do_run_component method must be specified; no automatic introspection of function arguments will occur.</p>
<p>Similarly, <%flags> and <%attr> sections can be achieved like this:
</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">do_component_init</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># flags</span>
<span class="python_operator"> </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">flags </span><span class="python_operator">= </span><span class="python_enclosure">{</span>
<span class="python_literal">'autoflush'</span><span class="python_operator">:</span><span class="python_name">True</span><span class="python_operator">,</span>
<span class="python_literal">'trim'</span><span class="python_operator">: </span><span class="python_literal">'both'</span>
<span class="python_enclosure">}</span><span class="python_operator">
</span>
<span class="python_comment"># attributes</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">attr </span><span class="python_operator">= </span><span class="python_enclosure">{</span>
<span class="python_literal">'style'</span><span class="python_operator">:</span><span class="python_literal">'green'</span><span class="python_operator">,</span>
<span class="python_literal">'docid'</span><span class="python_operator">:</span><span class="python_number">5843</span>
<span class="python_enclosure">}</span><span class="python_operator"></span></pre></div>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_controller"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Using MCs as Controllers</span>
<div class="sectiontext">
<p>The two most prominent features of an MC used as a controller includes that URI resolution is configured so that one or more URIs result in the component being called directly from a request, and that the component typically uses subrequests to forward execution onto a template, which serves as the view.</p>
<p>Here are two versions of a controller component that is used to pull documents from a database based on the request arguments, and displays them via a template called "documents.myt".
</p>
<p><b>Figure 1: Implicit Style, using a Callable Object</b></p>
<div class="code">
<pre>
<span class="python_operator"> </span><span class="python_keyword">class </span><span class="python_name">DocumentManager</span><span class="python_operator">:
</span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">do_component_init</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">component</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># load some application-wide constants via Interpreter attributes.</span>
<span class="python_comment"># the Interpreter is located via the hosting component.</span>
<span class="python_operator"> </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">document_base </span><span class="python_operator">= </span><span class="python_name">component</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'document_base'</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">db_string </span><span class="python_operator">= </span><span class="python_name">component</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'db_connect_string'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">__call__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">docid </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_comment"># if no document id, return '404 - not found' </span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">docid </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">abort</span><span class="python_enclosure">(</span><span class="python_number">404</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># access a hypothetical document database</span>
<span class="python_operator"></span><span class="python_name">docdb </span><span class="python_operator">= </span><span class="python_name">get_doc_db</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">document_base</span><span class="python_operator">, </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">db_string</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># load document</span>
<span class="python_name">document </span><span class="python_operator">= </span><span class="python_name">docdb</span><span class="python_operator">.</span><span class="python_name">find_document</span><span class="python_enclosure">(</span><span class="python_name">docid</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># couldnt find document - return '404 - not found'</span>
<span class="python_keyword">if </span><span class="python_name">document </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">abort</span><span class="python_enclosure">(</span><span class="python_number">404</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># run template</span>
<span class="python_operator"></span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'documents.myt'</span><span class="python_operator">, </span><span class="python_name">document </span><span class="python_operator">= </span><span class="python_name">document</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">documentmanager </span><span class="python_operator">= </span><span class="python_name">DocumentManager</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
<p><b>Figure 2: Explicit Style, with Pre-Declared Arguments</b></p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">component </span><span class="python_keyword">as </span><span class="python_name">component</span><span class="python_operator">
</span>
<span class="python_keyword">class </span><span class="python_name">DocumentManager</span><span class="python_enclosure">(</span><span class="python_name">component</span><span class="python_operator">.</span><span class="python_name">ModuleComponent</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">do_component_init</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># load some application-wide constants</span>
<span class="python_operator"> </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">document_base </span><span class="python_operator">= </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'document_base'</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">db_string </span><span class="python_operator">= </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'db_connect_string'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># establish the argument names we want (optional as of 0.98)</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">args </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'docid'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">do_run_component</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">ARGS</span><span class="python_operator">, </span><span class="python_name">docid </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span>
<span class="python_comment"># if no document id, return '404 - not found' </span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">docid </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">abort</span><span class="python_enclosure">(</span><span class="python_number">404</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># access a hypothetical document database</span>
<span class="python_operator"></span><span class="python_name">docdb </span><span class="python_operator">= </span><span class="python_name">get_doc_db</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">document_base</span><span class="python_operator">, </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">db_string</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># load document</span>
<span class="python_name">document </span><span class="python_operator">= </span><span class="python_name">docdb</span><span class="python_operator">.</span><span class="python_name">find_document</span><span class="python_enclosure">(</span><span class="python_name">docid</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># couldnt find document - return '404 - not found'</span>
<span class="python_keyword">if </span><span class="python_name">document </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">abort</span><span class="python_enclosure">(</span><span class="python_number">404</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># run template</span>
<span class="python_operator"></span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'documents.myt'</span><span class="python_operator">, </span><span class="python_name">document </span><span class="python_operator">= </span><span class="python_name">document</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>
The next section describes the two methods of configuring request URIs to execute "controller" components like this one.
</p>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_resolution"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Configuring Module Component Resolution</span>
<div class="sectiontext">
<p>
Module components can be used anywhere within the request, either right at the beginning (i.e. a controller) or within the scope of other components already executing. A module component can be fetched and/or called based on its importable module name followed by a path to a callable object, or the name of a class that subclasses <span class="codeline">myghty.components.ModuleComponent</span>. However, this doesn't work as a URL sent to a webserver. For request-level operation, MCs must be mapped to URIs. This resolution is achieved through two different configuration directives, <span class="codeline">module_components</span> and <span class="codeline">module_root</span>. A third option also exists which is to use the new <span class="codeline">routesresolver</span> resolver object.</p>
</div>
<A name="modulecomponents_resolution_module_components"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">module_components</span>
<div class="sectiontext">
The module_components configuration parameter looks like this:
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_enclosure">{</span><span class="python_literal">r'myapplication/home/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.home:HomeHandler'</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_enclosure">{</span><span class="python_literal">r'myapplication/login/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.login:LoginHandler'</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*/cart' </span><span class="python_operator">: </span><span class="python_literal">'myapp.cart:process_cart'</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.home:HomeHandler'</span><span class="python_enclosure">} </span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
Which in an apache configuration looks like:
<div class="code">
<pre>PythonOption MyghtyModuleComponents "[ \
{r'myapplication/home/.*' : 'myapp.home:HomeHandler'}, \
{r'myapplication/login/.*' : 'myapp.login:LoginHandler'}, \
{r'.*/cart' : 'myapp.cart:ShoppingCart'}, \
{r'.*' : 'myapp.home:HomeHandler'} \
]"</pre></div>
<p>
Each entry in the module_components array is a single-member hash containing a regular expression to be matched against the incoming URI, and an expression that can be resolved into a Module Component. This expression can be any of the following forms:
</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># a string in the form '<modulename>:<classname>' </span>
<span class="python_enclosure">{</span><span class="python_literal">r'myapplication/home/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.home:HomeHandler'</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_comment"># a string in the form '<modulename>:<functionname>'</span>
<span class="python_enclosure">{</span><span class="python_literal">r'myapplication/login/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.login:do_login'</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_comment"># a string in the form '<modulename>:<some>.<callable>.<thing>'</span>
<span class="python_enclosure">{</span><span class="python_literal">r'myapplication/status/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.status:handler.mcomp.get_status'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_comment"># a Class</span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*/cart' </span><span class="python_operator">: </span><span class="python_name">MyClass</span><span class="python_enclosure">}</span><span class="python_operator">, </span>
<span class="python_comment"># a function reference, or reference to a callable() object</span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*/dostuff' </span><span class="python_operator">: </span><span class="python_name">do_stuff</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_comment"># reference to a class instance method</span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*' </span><span class="python_operator">: </span><span class="python_name">mymodule</span><span class="python_operator">.</span><span class="python_name">processor</span><span class="python_operator">.</span><span class="python_name">main_process</span><span class="python_enclosure">}</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>
Generally, its better to use the string forms since they encompass all the information needed to load the class or callable object, which allows the Myghty interpreter to dynamically reload the object when the underlying module has changed.
</p>
<p>For module components that resolve to a Class, the Class will be instantiated by the Interpreter, and is expected to be a subclass of <span class="codeline">myghty.component.ModuleComponent</span>. This is also known as an <b>explicit</b> module component. For components that resolve to a function, object instance method, or callable object (i.e. any object that has a __call__ method), a "wrapper" module component will be created automatically which adapts to the callable's argument list. This is also known as an <b>implicit</b> module component.
</p>
<p>The corresponding Resolver class for module_components is ResolveModule.
</p>
</div>
<A name="modulecomponents_resolution_module_components_additional"></a>
<div class="subsection" style="margin-left:40px;">
<span class="sectionheadertext">Passing Resolution Arguments</span>
<div class="sectiontext">
<p>The module_components configuration parameter also includes some methods of returning information about the actual resolution of the component at request time.</p>
<p>Since module_components uses regular expressions to match URIs to components, the <span class="codeline">re.Match</span> object produced when a match occurs can be accessed via the <i>m</i> global variable. This example places capturing parenthesis in the regular expression to capture the additional path information:</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># place capturing parenthesis in the regexp</span>
<span class="python_enclosure">{</span><span class="python_literal">r'/catalog/(.*)' </span><span class="python_operator">: </span><span class="python_literal">'store:Catalog'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
The contents of the capturing parenthesis are available as:
<div class="code">
<pre><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">resolution</span><span class="python_operator">.</span><span class="python_name">match</span><span class="python_operator">.</span><span class="python_name">group</span><span class="python_enclosure">(</span><span class="python_number">1</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>User-defined arguments can also be configured which will be passed to the request object at resolution time. To use this form, a dictionary is used instead of a single string to specify the module and callable/class name of the component, and the address of the component itself is placed under the key 'component':</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># supply the component with some arguments</span>
<span class="python_enclosure">{</span><span class="python_literal">r'/login/' </span><span class="python_operator">: </span>
<span class="python_enclosure">{</span>
<span class="python_literal">'component' </span><span class="python_operator">: </span><span class="python_literal">'myapp:loginmanager'</span><span class="python_operator">,</span>
<span class="python_literal">'ldap_server' </span><span class="python_operator">: </span><span class="python_literal">'ldap://localhost:5678'</span>
<span class="python_enclosure">}</span>
<span class="python_enclosure">}</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
The contents of the <span class="codeline">ldap_server</span> argument are available as:
<div class="code">
<pre><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">resolution</span><span class="python_operator">.</span><span class="python_name">args</span><span class="python_enclosure">[</span><span class="python_literal">'ldap_server'</span><span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
</div>
<A name="modulecomponents_resolution_module_root"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">module_root</span>
<div class="sectiontext">
<p>This parameter locates module components based on paths. It is similar to the <a href="#parameters_component_root" >component_root</a> configuration parameter in that it defines one or more roots which will all be matched against the incoming URI. However, it not only traverses through directories, it also will traverse into a Python module where it attempts to locate a function or callable object instance. Currently, only the "implicit" style of module components can be used with module_root (but module_components, from the previous section, can be used with implicit or explicit MCs).
</p>
<p>The entries in module_root take the following forms:</p>
<div class="code">
<pre><span class="python_name">module_root </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># a regular file path</span>
<span class="python_literal">'/web/lib/modules/'</span><span class="python_operator">,</span>
<span class="python_comment"># the full file path of a Python module</span>
<span class="python_literal">'/web/extra/modules/mycontroller.py'</span><span class="python_operator">,</span>
<span class="python_comment"># the name of an importable Python module</span>
<span class="python_literal">'mylib.loginhandlers'</span><span class="python_operator">,</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Using the first path '/web/lib/modules', heres an example. Start with the following file:</p>
<div class="code">
<pre>/web/lib/modules/admin/login.py</pre></div>
<p>This file contains the following code:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">hello</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"hello world!"</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">_do_login</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">__call__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"please login"</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_comment"># ....</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">foo</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"this is foo"</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">index </span><span class="python_operator">= </span><span class="python_name">_do_login</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_name">_my_var </span><span class="python_operator">= </span><span class="python_number">12</span><span class="python_operator"></span></pre></div>
<p>Finally, lets have a module_root of:</p>
<div class="code">
<pre><span class="python_name">module_root </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'/web/lib/modules'</span><span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>With this configuration, URLs will be resolved as follows:</p>
<div class="code">
<pre>http://mysite.com/admin/login/hello/ ---> "hello world!" (login.py:hello())
http://mysite.com/admin/login/ ---> "please login" (login.py:index.__call__())
http://mysite.com/admin/login/foo/ ---> "this is foo" (login.py:index.foo())
http://mysite.com/admin/login/lala/ ---> "please login" (login.py:index.__call__())
http://mysite.com/admin/login/_my_var/ ---> "please login" (_my_var is private and is skipped)
http://mysite.com/admin/lala/ ---> 404 not found (no file named lala.py)</pre></div>
<p>The spirit of this resolver is that of the mod_python Publisher handler. Path tokens are converted into the names of .py files on the filesystem. When a file is located and it is a valid Python module, the module is loaded and further path tokens are resolved as attributes within the module itself. Attributes that start with an underscore are skipped, which is the default way to flag "private" attributes. There is also a "public" attribute marker which can be used to mark public functions instead of marking private functions, explained in the options section below. If no matching attribute exists for a path token, it looks for the attribute name "index", else returns a ComponentNotFound exception.
</p>
<p>module_root can also be combined with dhandler resolution (described in <a href="#specialtempl_dhandler" >dhandler</a>), so that a file named <span class="codeline">dhandler.py</span> in the current or parent directory serves as the "default" Python module for a path token that does not correspond to any other file. In the case of ResolvePathModule locating a dhandler.py file, the additional path tokens that normally reside within <a href="#request_members_dhandler_path" >dhandler_path</a> are also searched as attributes within the dhandler.py module.
</p>
<p>The corresponding Resolver class for module_root is ResolvePathModule.
</p>
</div>
<A name="modulecomponents_resolution_module_root_options"></a>
<div class="subsection" style="margin-left:40px;">
<span class="sectionheadertext">Module Root Options</span>
<div class="sectiontext">
<p>The underlying Resolver object for the module_root parameter is called ResolvePathModule (resolver objects are described in <a href="#resolver" >Advanced Resolver Configuration</a>). This object also has configuration options of its own. These options may be specified to the ResolvePathModule constructor directly. They can be specified as regular Myghty configuration parameters as well as of version 0.99b:
<ul>
<li><p>module_root_adjust=None (release 0.99b) - a reference to a function which receives the incoming URI and returns a modified version of that URI with which to resolve. The modified URI is not propigated onto other rules in the resolution chain, so therefore it represents a "local" alternative to <a href="#parameters_path_translate" >path_translate</a>.</p>
<p>This parameter is also called 'adjust' in all releases, but that name conflicts with the same name in the ResolveFile resolver, so should only be used when constructing individual ResolvePathModule objects and not as a global configuration parameter.</p>
</li>
<li><p>require_publish=False - when set to True, the callable object must have an attribute <span class="codeline">publish</span> set to True in order to mark it as publically accessible; else it will not be resolved. This effectively reverses the "negative publishing" model established via the underscore "_" syntax into a "positive publishing" model. Given this configuration:</p>
<div class="code">
<pre><span class="python_name">module_root </span><span class="python_operator">= </span><span class="python_enclosure">[</span><span class="python_literal">'/web/lib/modules'</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_name">require_publish </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator"></span></pre></div>
<p>Marking functions and methods public looks like this:
<div class="code">
<pre><span class="python_keyword">class </span><span class="python_name">MyController</span><span class="python_enclosure">(</span><span class="python_name">object</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">__call__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># ...</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'mytemplate.myt'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">__call__</span><span class="python_operator">.</span><span class="python_name">public </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">do_stuff</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># ...</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'dostuff.myt'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">do_stuff</span><span class="python_operator">.</span><span class="python_name">public </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">call_index</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_operator">,</span><span class="python_name">r</span><span class="python_operator">, </span><span class="python_name">s</span><span class="python_operator">, </span><span class="python_name">ARGS</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># ...</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_literal">'index.myt'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">call_index</span><span class="python_operator">.</span><span class="python_name">public </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span>
<span class="python_name">mycallable </span><span class="python_operator">= </span><span class="python_name">MyController</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
<p>The public attribute can also be set in Python 2.4 via decorator:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">mark_public</span><span class="python_enclosure">(</span><span class="python_name">func</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">func</span><span class="python_operator">.</span><span class="python_name">public </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">func</span><span class="python_operator">
</span>
<span class="python_operator">@</span><span class="python_name">mark_public</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">mycontroller</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># ...</span><span class="python_operator"></span></pre></div>
</li>
<li>path_moduletokens=['index'] - this is a list of special "default" token names when searching for module attributes. For example: If a given path "/foo/bar/bat" resolves to the module "bar.py" inside of directory "foo/", it will first look for an attribute named "bat" inside the module. If "bat" is not present, it will then look for all the names inside the moduletokens list, which defaults to the single entry "index". Therefore /foo/bar/bat not only looks for "bat", it also looks for "index". The tokens inside moduletokens are checked as defaults for every module token, so that a path such as "/foo/bar/bat" can also correspond to a module attribute "foo.index.bat", "index.bar.bat", etc.</li>
<li>path_stringtokens=[] - this is the path equivalent to the moduletokens parameter. It is a list of "default" path tokens when searching for files. In some ways, this parameter's functionality overlaps that of <a href="#parameters_dhandler_name" >dhandler_name</a>, except it allows multiple names and applies only to the module_root configuration. For example, if stringtokens is configured to ["default", "index"], and a given path "/foo/bar" resolves to the directory "foo/" but there is no file named "bar.py" inside the directory, it will then look for the files "default.py" and "index.py", respectively. Like moduletokens, stringtokens also checks these defaults for every path token, so a URL of "/foo/bar/bat" can also match "/default/bar/index", for example.</li>
</ul>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
</div>
<A name="modulecomponents_resolution_routesresolver"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Routes Resolver</span>
<div class="sectiontext">
<P>The Routes Resolver provides Rails-like functionality, building upon the resolution architecture described in <a href="#resolver" >Advanced Resolver Configuration</a>. Since it is not part of the default set of resolver objects, it must be included in the resolution chain via the <a href="#parameters_resolver_strategy" >resolver_strategy</a> configuration parameter.</p>
<p>A rudimentary example of the Routes resolver can be viewed by installing the <span class="codeline">myghty_routes</span> Paste template. Instructions for installing Paste templates are in <a href="#installation_paste" >Running Paste Templates</a>. The routes resolver also serves as the core resolver for the <a href="http://pylons.groovie.org">Pylons</a> web framework which is based on Myghty, and includes more comprehensive and up-to-date examples.
</p>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
</div>
<A name="modulecomponents_preprocessor"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module Component Pre and Post processing</span>
<div class="sectiontext">
<p>Request-handling module components can also be used to perform pre- and post-processing on a request. This means that the information about a request is modified before and/or after the main response is determined. The following two examples both wrap the main body of the request inside of a subrequest.</p>
<p>A module component that performs translations on incoming URI's, and then passes control onto the requested template, looks like this:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">translate_path</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">path </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_request_path</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">path </span><span class="python_operator">= </span><span class="python_name">re</span><span class="python_operator">.</span><span class="python_name">sub</span><span class="python_enclosure">(</span><span class="python_literal">'/sitedocs/john/'</span><span class="python_operator">, </span><span class="python_literal">'/'</span><span class="python_operator">, </span><span class="python_name">path</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">subexec</span><span class="python_enclosure">(</span><span class="python_name">path</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>A URI configuration for this component might look like:</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[{</span><span class="python_literal">r'/sitedocs/john/.*\.myt'</span><span class="python_operator">, </span><span class="python_literal">'mymodule:translate_path'</span><span class="python_enclosure">}]</span><span class="python_operator"></span></pre></div>
<p>Path translation is also accomplished in Myghty via the <a href="#parameters_path_translate" >path_translate</a> parameter, and can be controlled in finer detail through the use of custom resolution rules, described in <a href="#resolver" >Advanced Resolver Configuration</a>.</p>
<p>An example post processing component, which filters the output of the subrequest before returning data:
</p>
<div class="code">
<pre><span class="python_keyword">import </span><span class="python_name">StringIO</span><span class="python_operator">, </span><span class="python_name">re</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">filter</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># make a buffer</span>
<span class="python_operator"> </span><span class="python_name">buf </span><span class="python_operator">= </span><span class="python_name">StringIO</span><span class="python_operator">.</span><span class="python_name">StringIO</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># create a subrequest using that buffer</span>
<span class="python_comment"># our templates are located relative to the </span>
<span class="python_comment"># request URI underneath '/components'</span>
<span class="python_name">subreq </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">create_subrequest</span><span class="python_enclosure">(</span><span class="python_literal">'/components' </span><span class="python_operator">+ </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_request_uri</span><span class="python_enclosure">()</span><span class="python_operator">, </span><span class="python_name">out_buffer </span><span class="python_operator">= </span><span class="python_name">buf</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># execute the subrequest</span>
<span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">subreq</span><span class="python_operator">.</span><span class="python_name">execute</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># perform a meaningless filter operation on the content</span>
<span class="python_name">content </span><span class="python_operator">= </span><span class="python_name">re</span><span class="python_operator">.</span><span class="python_name">sub</span><span class="python_enclosure">(</span><span class="python_literal">r'foo'</span><span class="python_operator">, </span><span class="python_literal">r'bar'</span><span class="python_operator">, </span><span class="python_name">buf</span><span class="python_operator">.</span><span class="python_name">getvalue</span><span class="python_enclosure">()) </span><span class="python_operator">
</span>
<span class="python_comment"># write the content </span>
<span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_name">content</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>This component might be configured as:</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[{</span><span class="python_literal">r'/sitedocs/john/.*\.myt'</span><span class="python_operator">, </span><span class="python_literal">'mymodule:filter'</span><span class="python_enclosure">}]</span><span class="python_operator"></span></pre></div>
<p>Filtering is also built in to Myghty via the use of <%filter> section, described in <a href="#filtering" >Filtering and Flushing (and Escaping)</a>.
</p>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
<A name="modulecomponents_templates"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Using Module Components within Templates</span>
<div class="sectiontext">
<p>MCs can also be called from within templates. If an MC is configured to be callable against a URI using <span class="codeline">module_components</span> or <span class="codeline">module_root</span>, that URI can also be used within a regular <& &>-style component call. Or, the MODULE: prefix style described previously can be used.</p>
</div>
<A name="modulecomponents_templates_formexample"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Example: Form Visitor</span>
<div class="sectiontext">
<p>Here is an example of a module component that is used to generate HTML forms from a data object, using the visitor pattern. Such an architecture can be used to have form information stored in a database or XML file which can then be used to automatically construct a corresponding form. This example is included in working form with the Myghty distribution.
</p>
<p><b>Step 1: Data Model</b> - The data model consists of a hierarchy of <span class="codeline">FormElement</span> objects. Some <span class="codeline">FormElement</span> objects can contain collections of other <span class="codeline">FormElements</span> (the "composite" pattern):</p>
<div class="code">
<div class="codetitle">form.py</div>
<pre><span class="python_keyword">class </span><span class="python_name">FormElement</span><span class="python_enclosure">(</span><span class="python_name">object</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">""" abstract FormElement superclass."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">pass</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""subclasses override accept_visitor to provide
the appropriate type-based visitor method."""</span><span class="python_operator">
</span><span class="python_keyword">pass</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">Form</span><span class="python_enclosure">(</span><span class="python_name">FormElement</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""represents a <FORM> tag."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">action</span><span class="python_operator">, </span><span class="python_name">elements</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">name </span><span class="python_operator">= </span><span class="python_name">name</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">action </span><span class="python_operator">= </span><span class="python_name">action</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">elements </span><span class="python_operator">= </span><span class="python_name">elements</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">visitor</span><span class="python_operator">.</span><span class="python_name">visit_form</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">Field</span><span class="python_enclosure">(</span><span class="python_name">FormElement</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""abstract base class for individual user-entry fields, each
having a name, a description, and an optional value."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_operator">, </span><span class="python_name">value </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">name </span><span class="python_operator">= </span><span class="python_name">name</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">description </span><span class="python_operator">= </span><span class="python_name">description</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">value </span><span class="python_operator">= </span><span class="python_name">value</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">TextField</span><span class="python_enclosure">(</span><span class="python_name">Field</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""an <INPUT TYPE="text"> field."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_operator">, </span><span class="python_name">size</span><span class="python_operator">, </span><span class="python_name">value </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">Field</span><span class="python_operator">.</span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_operator">, </span><span class="python_name">value</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">size </span><span class="python_operator">= </span><span class="python_name">size</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">visitor</span><span class="python_operator">.</span><span class="python_name">visit_textfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">SelectField</span><span class="python_enclosure">(</span><span class="python_name">Field</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""a <SELECT></SELECT> tag."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_operator">, </span><span class="python_name">options</span><span class="python_operator">, </span><span class="python_name">value </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">Field</span><span class="python_operator">.</span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">name</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_operator">, </span><span class="python_name">value</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">options </span><span class="python_operator">= </span><span class="python_name">options</span><span class="python_operator">
</span><span class="python_keyword">for </span><span class="python_name">o </span><span class="python_keyword">in </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">options</span><span class="python_operator">:
</span><span class="python_name">o</span><span class="python_operator">.</span><span class="python_name">parent </span><span class="python_operator">= </span><span class="python_name">self</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">o</span><span class="python_operator">.</span><span class="python_name">id </span><span class="python_operator">== </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">value</span><span class="python_operator">:
</span><span class="python_name">o</span><span class="python_operator">.</span><span class="python_name">selected </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">visitor</span><span class="python_operator">.</span><span class="python_name">visit_selectfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">OptionField</span><span class="python_enclosure">(</span><span class="python_name">FormElement</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""an <OPTION></OPTION> tag.
contains a parent attribute that points to a <SELECT> field."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">id</span><span class="python_operator">, </span><span class="python_name">description</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">id </span><span class="python_operator">= </span><span class="python_name">id</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">description </span><span class="python_operator">= </span><span class="python_name">description</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">parent </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">selected </span><span class="python_operator">= </span><span class="python_name">False</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">visitor</span><span class="python_operator">.</span><span class="python_name">visit_option</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">SubmitField</span><span class="python_enclosure">(</span><span class="python_name">FormElement</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""an <INPUT TYPE="submit"> field."""</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">value</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">value </span><span class="python_operator">= </span><span class="python_name">value</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">visitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">visitor</span><span class="python_operator">.</span><span class="python_name">visit_submit</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p><b>Step 2: Visitor Interface</b> - This class provides the layout of a visitor object:</p>
<div class="code">
<div class="codetitle">form.py</div>
<pre><span class="python_keyword">class </span><span class="python_name">FormVisitor</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">visit_form</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">form</span><span class="python_enclosure">)</span><span class="python_operator">:</span><span class="python_keyword">pass</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">visit_textfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">textfield</span><span class="python_enclosure">)</span><span class="python_operator">:</span><span class="python_keyword">pass</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">visit_selectfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">selectfield</span><span class="python_enclosure">)</span><span class="python_operator">:</span><span class="python_keyword">pass</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">visit_option</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">option</span><span class="python_enclosure">)</span><span class="python_operator">:</span><span class="python_keyword">pass</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">visit_submit</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">submit</span><span class="python_enclosure">)</span><span class="python_operator">:</span><span class="python_keyword">pass</span><span class="python_operator"></span></pre></div>
<p><b>Step 3: HTML Rendering Components</b> - a set of Myghty methods that will render the HTML of each form element:
</p>
<div class="code">
<div class="codetitle">formfields.myc</div>
<pre><span class="doctag"><%doc></span><span class="doctag_text">
each method renders one particular HTML form element,
as well as <table> tags to provide basic layout for each.
the "form" and "select" methods are component calls with content,
to render the form elements within them.
</span><span class="doctag"></%doc></span><span class="text">
</span><span class="deftag"><%method</span><span class="compname"> form</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span><span class="python_name">form</span><span class="python_operator"></span><span class="argstag"></%args></span><span class="text">
<FORM name="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">name</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">" method="POST" action="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">action</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">">
<table>
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">content</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</table>
</FORM>
</span><span class="deftag"></%method></span><span class="text">
</span><span class="deftag"><%method</span><span class="compname"> textfield</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span><span class="python_name">textfield</span><span class="python_operator"></span><span class="argstag"></%args></span><span class="text">
<tr>
<td></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">textfield</span><span class="python_operator">.</span><span class="python_name">description</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">:</td>
<td>
<input type="text" name="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">textfield</span><span class="python_operator">.</span><span class="python_name">name</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">" value="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">textfield</span><span class="python_operator">.</span><span class="python_name">value</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">" size="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">textfield</span><span class="python_operator">.</span><span class="python_name">size</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">" >
</td>
</tr>
</span><span class="deftag"></%method></span><span class="text">
</span><span class="deftag"><%method</span><span class="compname"> submit</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span><span class="python_name">submit</span><span class="python_operator"></span><span class="argstag"></%args></span><span class="text">
<tr><td colspan="2">
<input type="submit" value="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">submit</span><span class="python_operator">.</span><span class="python_name">value</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">">
</td></tr>
</span><span class="deftag"></%method></span><span class="text">
</span><span class="deftag"><%method</span><span class="compname"> select</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span><span class="python_name">select</span><span class="python_operator"></span><span class="argstag"></%args></span><span class="text">
<tr>
<td></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">select</span><span class="python_operator">.</span><span class="python_name">description</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></td>
<td>
<select name="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">select</span><span class="python_operator">.</span><span class="python_name">name</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">">
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">content</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</select>
</td>
</tr>
</span><span class="deftag"></%method></span><span class="text">
</span><span class="deftag"><%method</span><span class="compname"> option</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span><span class="python_name">option</span><span class="python_operator"></span><span class="argstag"></%args></span><span class="text">
<option value="</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">option</span><span class="python_operator">.</span><span class="python_name">id</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">" </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">option</span><span class="python_operator">.</span><span class="python_name">selected </span><span class="python_keyword">and </span><span class="python_literal">"SELECTED" </span><span class="python_keyword">or </span><span class="python_literal">""</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">option</span><span class="python_operator">.</span><span class="python_name">description</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></option>
</span><span class="deftag"></%method></span></pre></div>
<p><b>Step 4: Module Component</b> - ties it all together. The FormGenerator serves as the traversal unit for the Form object, as well as the visitor implementation itself. The visit_form and visit_selectfield methods both involve contained formelements, and the corresponding myghty components are component calls with content; so for those, a content function is created to handle the embedded content.
</p>
<div class="code">
<div class="codetitle">form.py</div>
<pre><span class="python_keyword">def </span><span class="python_name">renderform</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, </span><span class="python_name">form</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">FormGenerator</span><span class="python_operator">.</span><span class="python_name">RenderForm</span><span class="python_enclosure">(</span><span class="python_name">m</span><span class="python_enclosure">))</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">class </span><span class="python_name">RenderForm</span><span class="python_enclosure">(</span><span class="python_name">FormVisitor</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">visit_form</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">form</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">formcontent</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_keyword">for </span><span class="python_name">element </span><span class="python_keyword">in </span><span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">elements</span><span class="python_operator">:
</span><span class="python_name">element</span><span class="python_operator">.</span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">execute_component</span><span class="python_enclosure">(</span><span class="python_literal">"formfields.myc:form"</span><span class="python_operator">, </span><span class="python_name">args </span><span class="python_operator">= </span><span class="python_name">dict</span><span class="python_enclosure">(</span><span class="python_name">form </span><span class="python_operator">= </span><span class="python_name">form</span><span class="python_enclosure">)</span><span class="python_operator">, </span><span class="python_name">content</span><span class="python_operator">=</span><span class="python_name">formcontent</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">visit_textfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">textfield</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"formfields.myc:textfield"</span><span class="python_operator">, </span><span class="python_name">textfield </span><span class="python_operator">= </span><span class="python_name">textfield</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">visit_selectfield</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">selectfield</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">def </span><span class="python_name">selectcontent</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_keyword">for </span><span class="python_name">element </span><span class="python_keyword">in </span><span class="python_name">selectfield</span><span class="python_operator">.</span><span class="python_name">options</span><span class="python_operator">:
</span><span class="python_name">element</span><span class="python_operator">.</span><span class="python_name">accept_visitor</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">execute_component</span><span class="python_enclosure">(</span><span class="python_literal">"formfields.myc:select"</span><span class="python_operator">, </span><span class="python_name">args </span><span class="python_operator">= </span><span class="python_name">dict</span><span class="python_enclosure">(</span><span class="python_name">select </span><span class="python_operator">= </span><span class="python_name">selectfield</span><span class="python_enclosure">)</span><span class="python_operator">, </span><span class="python_name">content</span><span class="python_operator">=</span><span class="python_name">selectcontent</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">visit_option</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">option</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"formfields.myc:option"</span><span class="python_operator">, </span><span class="python_name">option </span><span class="python_operator">= </span><span class="python_name">option</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">visit_submit</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">submit</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">comp</span><span class="python_enclosure">(</span><span class="python_literal">"formfields.myc:submit"</span><span class="python_operator">, </span><span class="python_name">submit </span><span class="python_operator">= </span><span class="python_name">submit</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p><b>Step 5: Fire it Up</b> - this myghty template actually calls the <span class="codeline">renderform</span> Module Component.
</p>
<div class="code">
<div class="codetitle">registration.myt</div>
<pre><span class="doctag"><%doc></span><span class="doctag_text">
an example firstname/lastname/occupation registration form.
</span><span class="doctag"></%doc></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">form</span><span class="python_operator">
</span><span class="python_name">registerform </span><span class="python_operator">= </span><span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">Form</span><span class="python_enclosure">(</span><span class="python_literal">'myform'</span><span class="python_operator">, </span><span class="python_literal">'register.myt'</span><span class="python_operator">, </span><span class="python_name">elements </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">TextField</span><span class="python_enclosure">(</span><span class="python_literal">'firstname'</span><span class="python_operator">, </span><span class="python_literal">'First Name'</span><span class="python_operator">, </span><span class="python_name">size</span><span class="python_operator">=</span><span class="python_number">50</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">TextField</span><span class="python_enclosure">(</span><span class="python_literal">'lastname'</span><span class="python_operator">, </span><span class="python_literal">'Last Name'</span><span class="python_operator">, </span><span class="python_name">size</span><span class="python_operator">=</span><span class="python_number">50</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">SelectField</span><span class="python_enclosure">(</span><span class="python_literal">'occupation'</span><span class="python_operator">, </span><span class="python_literal">'Occupation'</span><span class="python_operator">, </span>
<span class="python_name">options </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">OptionField</span><span class="python_enclosure">(</span><span class="python_literal">'skydiver'</span><span class="python_operator">, </span><span class="python_literal">'Sky Diver'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">OptionField</span><span class="python_enclosure">(</span><span class="python_literal">'programmer'</span><span class="python_operator">, </span><span class="python_literal">'Computer Programmer'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">OptionField</span><span class="python_enclosure">(</span><span class="python_literal">''</span><span class="python_operator">, </span><span class="python_literal">'No Answer'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_enclosure">]</span>
<span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">form</span><span class="python_operator">.</span><span class="python_name">SubmitField</span><span class="python_enclosure">(</span><span class="python_literal">'register'</span><span class="python_enclosure">)</span>
<span class="python_enclosure">]</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
Welcome to the Skydivers or Computer Programmers Club !
</span><span class="compcall"><& </span><span class="compname">MODULE:form:renderform</span><span class="python_operator">, </span><span class="python_name">form </span><span class="python_operator">= </span><span class="python_name">registerform</span><span class="python_operator"> </span><span class="compcall">&></span></pre></div>
</div>
<a href="#modulecomponents" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="request"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#modulecomponents">Module Components</a>
|
Next: <a href="#otherblocks">Other Blocks</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">The Request</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#request_methods">Request Methods</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#request_members">Request Members</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>The Request, available in all Myghty templates as the global variable <i>m</i>, is the central processor of a component and all the calls it makes to other components. Following are all the useful methods and members of a request. </p>
<p><b>Note:</b> many request methods have been converted to straight data members as of version 0.96, such as get_base_component(), get_request_args(), get_dhandler_arg(), etc. These methods are still present for existing applications but their use is deprecated. Their functionality can be located in the Request Members section.</p>
</div>
<A name="request_methods"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Request Methods</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="dark">
<td>
<A name="request_methods_abort"></a>
<b>abort(<i>status_code = None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Halts the currently executing component, and optionally sends the specified HTTP status code. Any content that is still in the output buffer is discarded. If the status code is None, the request simply ends with no further output, and the HTTP code 200:OK is returned as a normal request. </p>
<p>Abort can be used to send any HTTP status code desired to the client. However, to send a soft redirect via a subrequest, or a hard redirect via the "Location:" header along with 302:Moved, its easier to use m.send_redirect(), described below.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_apply_escapes"></a>
<b>apply_escapes(<i>text</i>, <i>flags</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
programmatically applies escape flags to the given text, the same as they would be used inside of a substitution. <i>text</i> is a string to be processed, and <i>flags</i> is an array of single-character escape flags. The two built in flags are "u" for url escaping and "h" for HTML escaping, and user-defined flags are supported as well. See <a href="#filtering_escaping" >Escaping Content</a> for more information on escape flags.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_cache"></a>
<b>cache(<i>component=None</i>, <i>cache_type=None</i>, <i>cache_container_class=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Returns the cache for the current component, or if called with an optional component argument, returns the cache for the specified component. If the cache does not yet exist within the scope of the current request, it will be created using the given list of arguments, else the arguments are disregarded and the previous request-scoped cache interface is returned (note that multiple instances of a cache interface may all reference the same underlying data store, if they are of the same type). The arguments here override those set in the global configuration for the interpreter, but will usually not override the arguments specified in the %flags section of the component.</p>
<p>The cache type defaults to 'dbm' if a data_dir is in use, else uses 'memory'. Additional arguments can be added that are specific to MemoryContainer, DBMContainer, or other custom types of containers. See the section <a href="#caching" >Data Caching</a>.
<br/><br/><b>Also called as:</b> get_cache
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_cache_self"></a>
<b>cache_self(<i>component=None</i>, <i>key=None</i>, <i>retval=None</i>, <i>cache_type=None</i>, <i>cache_container_class=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Caches the current component (or the specified component's) output and return value. All arguments are optional. The component argument is a component argument specifying a component other than the currently executing component. The key argument is the key to store the information under, which defaults to the string "_self". The key can be modified if you want to cache the comopnent's output based on some kind of conditional information such as component arguments. The retval argument is a <b>value</b> object which can be used to receive the return value of the component. The rest of the parameters are the same as those for the cache/get_cache method.</p>
<p>
The function returns True indicating that the retval has been populated and the component's output has been flushed to the output, or False indicating that the value is not yet cached (or needs refreshing) and execution should continue on into the rest of the component. See <a href="#caching" >Data Caching</a> for an example.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_callers"></a>
<b>callers(<i>index = None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px"><p>Returns a single component from the call stack object indicated by the given index, or if None returns the full list of components stored within the current call stack.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_caller_args"></a>
<b>caller_args(<i>index = None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px"><p>Returns a single dictionary of component arguments from the call stack object indicated by the given index, or if None returns the full list of argument dictionaries sent to each component stored within the current call stack.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_call_content"></a>
<b>call_content()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Similar to the content() method used within a component call with content, except does not push a new buffer onto the buffer stack. When combined with programmatic pushing and popping buffers onto the request via push_buffer() and pop_buffer(), it can be used for complicated content-grabbing schemes. For advanced usage.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_call_next"></a>
<b>call_next(<i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Within a chain of inheriting pages, calls the next component in the inheritance chain, i.e. the "wrapped" component. See <a href="#inheritance" >Inheritance</a> for more information on the inheritance chain. Optional **params specify arguments that will override the subclass-component's default argument list on a parameter-by-parameter basis.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_call_stack"></a>
<b>call_stack(<i>index = None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px"><p>Provides access to the current call stack. The call stack is a list of StackFrame objects, which are internal representations of components calling each other. Each StackFrame object contains the fields "component", "args", "base_component", "content", "is_call_self", and "filter". The given index refers to what index within the stack to return; if it is <span class="codeline">None</span>, the entire call stack is returned.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_comp"></a>
<b>comp(<i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
calls a component, subcomponent, or method.
See <a href="#components_programmatic_comp" >m.comp(component, **params)</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_component_exists"></a>
<b>component_exists(<i>path</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
returns True if the specified file-based component, identified by its URI, can be located. Performs the full filesystem check even if the requested component is already loaded, therefore repeated calls to this method can get expensive.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_content"></a>
<b>content()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
returns the content of an embedded component call in the context of a component call with content. See <a href="#components_callwithcontent" >Component Calls with Content</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_create_subrequest"></a>
<b>create_subrequest(<i>component</i>, <i>resolver_context='subrequest'</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Creates a subrequest, which is a child request to this one. The request can then serve a new component call, which will be serviced within the same output stream as this one. By default, the subrequest is configured in much the same way as the originating request. The **params dictionary can be used to override individual configuration parameters; any per-request parameter listed in <a href="#parameters" >Index of Configuration Parameters</a> is relevant.
<p>Users will usually prefer to use the methods make_subrequest() or subexec() since they are more compact for typical component-call scenarios. See <a href="#components_programmatic_subrequests" >Subrequests</a>.</p>
<p>Also see <a href="#resolver_context" >Resolver Contexts</a> for information on the resolver_context parameter.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_decline"></a>
<b>decline()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Used by a dhandler to forego processing a directory request, and to bump the interpreter up to the enclosing directory, where it will search again for a dhandler.
See <a href="#specialtempl_dhandler" >dhandler</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_execute"></a>
<b>execute()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Executes this request. Chances are you are already inside the execute call, which can only be called once on any given request object. However, if you make yourself a subrequest, then you can call execute on that object. See <a href="#components_programmatic_subrequests" >Subrequests</a>.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_execute_component"></a>
<b>execute_component(<i>component</i>, <i>args = {}</i>, <i>base_component = None</i>, <i>content = None</i>, <i>store = None</i>, <i>is_call_self = False</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The base component-calling method, at the root of all the other component calling methods (i.e. execute(), comp(), subexec(), etc.). The richer argument set of this method is useful for calling components with an embedded content call, and also for supplying a custom output buffer to capture the component output directly. The parameters are:
<ul>
<li>component - the string name/URI of the component, or an actual component argument
<li>args - dictionary of arguments sent to the component. this is supplied to the component via <i>ARGS</i> as well as via the component-scoped <%args> tag.
<li>base_component - the base component for the component call. This is best left as None, where it will be determined dynamically.
<li>content - reference to a function that will be attached to the <span class="codeline">m.content()</span> method inside the component call. this is used to programmatically call a "component call with content". The function takes no arguments and is normally a "closure" within the span of the code calling the enclosing component.
<li>store - reference to a buffer, such as a file, StringIO, or myghty.buffer object, where the component's output will be sent.
<li>is_call_self - used internally by the <span class="codeline">m.call_self()</span> method to mark a stack frame as the original "self caller". Just leave it as False.
</ul>
</p>
<p>Example: component call with content:</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> testcall</span><span class="deftag">></span><span class="text">
this is testcall. embedded content:
[ </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">content</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"> ]
</span><span class="deftag"></%def></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">mycontent</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"this is the embedded content."</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">execute_component</span><span class="python_enclosure">(</span><span class="python_literal">'testcall'</span><span class="python_operator">, </span><span class="python_name">args </span><span class="python_operator">= </span><span class="python_enclosure">{}</span><span class="python_operator">, </span><span class="python_name">content </span><span class="python_operator">= </span><span class="python_name">mycontent</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>This will produce:</p>
<div class="code">
<pre><span class="text">this is testcall. embedded content:
[ this is the embedded content. ]</span></pre></div>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_fetch_all"></a>
<b>fetch_all()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Returns a list of the full "wrapper chain" of components inheriting each other, beginning with the current inheriting component and going down to the innermost component. Each element is popped of the request's internal wrapper stack. See <a href="#inheritance" >Inheritance</a> for details on component inheritance.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_fetch_component"></a>
<b>fetch_component(<i>path</i>, <i>resolver_context='component'</i>, <i>raise_error=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Returns a component object corresponding to the specified component path. This path may be:</p>
<ul>
<li>a URI path relative to one of the application's configured component roots, with an optional clause ":methodname" indicating a method to be called from the resulting file-based component.
<li>one of the special names SELF, PARENT, REQUEST, with an optional clause ":methodname" indicating a method to be called from the resulting file-based component, or the current subcomponent's owner in the case of a subcomponent that calls SELF.
<li>the name of a method component stated in the form "METHOD:modulename:classname".
</ul>
When the component is located, it will be compiled and/or loaded into the current Python environment if it has not been already. In this way it is the Myghty equivalent of "import".</p>
<p>If the component cannot be located, it raises a <span class="codeline">myghty.exceptions.ComponentNotFound</span> error, unless raise_error is <span class="codeline">False</span>, in which case the method returns <span class="codeline">None</span>.
</p>
<p>More details on how to identify components can be found in <a href="#components" >Components</a>.</p>
<p>Also see <a href="#resolver_context" >Resolver Contexts</a> for information on the resolver_context parameter.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_fetch_lead_component"></a>
<b>fetch_lead_component(<i>path</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Fetches a component similarly to fetch_component(), but also resolves directory requests and requests for nonexistent components to dhandlers.</p>
<p>If the component cannot be located, or a useable dhandler cannot be located because either no dhandler was found or all valid dhandlers have already sent decline() within the span of this request, a <span class="codeline">myghty.exceptions.ComponentNotFound</span> error is raised.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_fetch_module_component"></a>
<b>fetch_module_component(<i>moduleorpath</i>, <i>classname</i>, <i>raise_error=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Fetches a module component. The value of "moduleorpath" is either a string in the form "modulename:classname", or it is a reference to a Python module containing the desired component. In the latter case, the argument "classname" must also be sent indicating the name of the desired class to load.
</p>
<p>
Using this method with a string is the same as using the fetch_component() method using the syntax "METHOD:modulename:classname".
</p>
<p>If the module component cannot be located, a <span class="codeline">myghty.exceptions.ComponentNotFound</span> error is raised, unless raise_error is <span class="codeline">False</span>, in which case the method returns <span class="codeline">None</span>.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_fetch_next"></a>
<b>fetch_next()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Within a chain of inheriting pages, this method returns the next component in the inheritance chain (also called the "wrapper" chain), popping it off the stack. The component can then be executed via the <span class="codeline">m.comp()</span> or similar method. See the section <a href="#inheritance" >Inheritance</a>.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_get_session"></a>
<b>get_session(<i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px"><p>Creates or returns the current Myghty session object (or optionally the mod_python Session object). If the session has not been created, the given **params are used to override defaults and interpreter-wide configuration settings during initialization.</p>
<p>Details on the Session are described in <a href="#session" >Session</a>.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_has_content"></a>
<b>has_content()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Inside of a subcomponent or method call, returns whether or not the component was a component call with content. See the section <a href="#components_callwithcontent" >Component Calls with Content</a>.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_has_current_component"></a>
<b>has_current_component()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Returns True if this request has a currently executing component. This becomes true once a request's execute() method has been called.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_instance"></a>
<b>instance()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This static method returns the request corresponding to the current process and thread. You can access the current request in a globally scoped block via this method. See <a href="#scopedpython_global" >Global Scope</a>.
<div class="code">
<pre><span class="blocktag"><%python scope="global"></span>
<span class="python_operator"> </span><span class="python_name">req </span><span class="python_operator">= </span><span class="python_name">request</span><span class="python_operator">.</span><span class="python_name">instance</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_is_subrequest"></a>
<b>is_subrequest()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Returns True if the currently executing request is a subrequest. See the section <a href="#components_programmatic_subrequests" >Subrequests</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_log"></a>
<b>log(<i>message</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Logs a message. The actual method of logging is specific to the underlying request implementation; for standalone and CGI it is the standard error stream, for mod_python it is a [notice] in the Apache error log.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_make_subrequest"></a>
<b>make_subrequest(<i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Creates a new subrequest with the given component object or string path <i>component</i> and the request arguments <i>**params</i>. The returned request object can then be executed via the execute() method. See <a href="#components_programmatic_subrequests" >Subrequests</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_scomp"></a>
<b>scomp(<i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Executes a component and returns its content as a string. See <a href="#components_programmatic_scomp" >m.scomp(component, **params)</a>.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_send_redirect"></a>
<b>send_redirect(<i>path</i>, <i>hard=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Sends a hard or soft redirect to the specified path. A hard redirect is when the http server returns the "Location:" header and instructs the browser to go to a new URL via the 302 - MOVED_TEMPORARILY return code. A soft redirect means the new page will be executed within the same execution context as the current component. In both cases, the current component is aborted, and any buffered output is cleared. For this reason, if auto_flush is enabled (which it is not by default), you would want to call this method, particular the soft redirect, only before any content has been output, most ideally in an %init section. If auto_flush is disabled, you can call either version of this method anywhere in a component and it will work fine.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_set_output_encoding"></a>
<b>set_output_encoding(<i>encoding</i>, <i>errors="strict"</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Change the output_encoding, and, optionally, the encoding error handling strategy.</p>
<p>Generally, you will not want to change the output encdoing after you have written any output (as then your output will be in two different encodings --- probably not what you wanted unless, for example, you are generating Mime multipart output.)</p>
<p>See the section on <a href="#unicode" >Unicode Support</a> for further details.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_methods_subexec"></a>
<b>subexec(<i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
All-in-one version of <span class="codeline">make_subrequest</span> and
<span class="codeline">m.execute()</span>. See <a href="#components_programmatic_subrequests" >Subrequests</a>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_methods_write"></a>
<b>write()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Writes text to the current output buffer. If auto_flush is enabled, will flush the text to the final output stream as well.
<br/><br/><b>Also called as:</b> out
</div>
</td>
</tr>
</table>
</div>
<a href="#request" class="toclink">back to section top</a>
</div>
<A name="request_members"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Request Members</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="light">
<td>
<A name="request_members_attributes"></a>
<b>attributes</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>A dictionary where request-local information can be stored. Also can be referenced by the member <a href="#request_members_notes" >notes</a>. If the request is a subrequest, this dictionary inherits information from its parent request.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_base_component"></a>
<b>base_component</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Represents the "effective" file-based component being serviced, from which methods and attributes may be accessed. When autohandlers or other inherited components are executing, this member always points to the file-based component at the bottom of the inheritance chain. This allows an inherited component to access methods or attributes that may be "dynamically overridden" further down the inheritance chain. It is equivalent to the special path <span class="codeline">SELF</span>. When a method or def component is called via the path of another file-based component, base_component will change to reflect that file-based component for the life of the subcomponent call.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_current_component"></a>
<b>current_component</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The component currently being executed. Within the body of a component, this is equivalent to <span class="codeline">self</span>.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_dhandler_path"></a>
<b>dhandler_path</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
In the case of a dhandler call, the request path adjusted to the current dhandler.
<p>For information on dhandlers see <a href="#specialtempl_dhandler" >dhandler</a>.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_encoding_errors"></a>
<b>encoding_errors</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The current output encoding error handling strategy. This is a read-only attribute, though you may change it using the <a href="#request_methods_set_output_encoding" >set_output_encoding</a> method.</p>
<p>See the section on <a href="#unicode" >Unicode Support</a> for further details.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_global_args"></a>
<b>global_args</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>A dictionary of custom-configured global variables to be used throughout the request. Global variables can be initialized or re-assigned here, and the new value will become available to all further component calls. Each key in this dictionary must already correspond to a value in the <span class="codeline">allow_globals</span> configuration parameter. See <a href="#globals_globalcustom" >Make your Own Friends</a> for full examples.</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_interpreter"></a>
<b>interpreter</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The Interpreter object that created this Request object.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_notes"></a>
<b>notes</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A synonym for <a href="#request_members_attributes" >attributes</a>.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_output_encoding"></a>
<b>output_encoding</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The current output encoding. This is a read-only attribute, though you may change it using the <a href="#request_methods_set_output_encoding" >set_output_encoding</a> method.</p>
<p>See the section on <a href="#unicode" >Unicode Support</a> for further details.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_parent_request"></a>
<b>parent_request</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
In a subrequest call, refers to the immediate parent request of this request, else defaults to None.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_request_args"></a>
<b>request_args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>A dictionary containing the initial request arguments sent when this request was created. In an HTTP context, this usually refers to the request arguments sent by the client browser. </p>
<p>In the case of a subrequest (described in <a href="#components_programmatic_subrequests" >Subrequests</a>), this member refers to the request arguments sent to the local subrequest. To get the original request arguments, use the root_request_args parameter.</p>
<p>For detailed description of component and request arguments, see <a href="#components_args" >Component Arguments - the <%args> tag</a>.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_request_component"></a>
<b>request_component</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Returns the top-level component corresponding to the current request.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_request_path"></a>
<b>request_path</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The original path sent to this request for resolution. In the case of a subrequest, the path sent to the subrequest. </p>
<p>In the case of a new request that is called with a pre-existing component object, such as in a custom application interfacing to the Myghty interpreter, the request_path defaults to None, but can also be set programmatically via the <a href="#parameters_request_path" >request_path</a> configuration argument.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_root_request"></a>
<b>root_request</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Refers to the ultimate originating request in a string of subrequests.
If this request is not a subrequest, this member references the current request.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="request_members_root_request_args"></a>
<b>root_request_args</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Used in subrequests, returns the request arguments sent to the ultimate root request in a chain of subrequests. For a regular request with no parent, this dictionary is synonymous with request_args.
</p>
<p>For detailed description of component and request arguments, see <a href="#components_args" >Component Arguments - the <%args> tag</a>.</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="request_members_root_request_path"></a>
<b>root_request_path</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The request path for the original root request, in a chain
of subrequests.</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#request" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="otherblocks"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#request">The Request</a>
|
Next: <a href="#inheritance">Inheritance</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Other Blocks</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#otherblocks_flags"><%flags></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#otherblocks_attr"><%attr></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#otherblocks_text"><%text></a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#otherblocks_doc"><%doc></a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Myghty has some miscellaneous <%xxxx> blocks, whose contents are less than pure Python. The most important is the <%flags> section, since it controls several important behaviors of a component.</p>
</div>
<A name="otherblocks_flags"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext"><%flags></span>
<div class="sectiontext">
<p>%flags is used to specify special properties of the component, which are significant to the execution of the component in the Myghty environment. Some flags can be inherited from a parent supercomponent, and overridden as well. Current flags are:</p>
<ul>
<li><p> <span class="codeline">inherit = "/path/to/template"</span> - used in a file-based component only, this flag indicates that this component should inherit from the given template file. This argument can also be None to indicate that this component should not inherit from anything, even the standard autohandler. This flag only applies to the component file that it appears in, and does not affect any super- or subclass components. See the section <a href="#inheritance" >Inheritance</a> for details.
</p>
<li> <p><span class="codeline">autoflush = [True|False]</span> - will override the configuration parameter <span class="codeline">auto_flush</span> for this individual component. This is mostly useful for a particularly large top-level component, or a filter component that requires the full output text in one chunk. When a comopnent has autoflush disabled, it essentially means that a buffer is placed between the component's output and the ultimate output stream. As a result, the delivery of any component within a buffered component is also going to be buffered - this includes when a superclass component calls <span class="codeline">m.call_next()</span> or for any subcomponent or method call.</p>
<p>
This flag is also inherited from a superclass component, such as the autohandler. See the section <a href="#filtering_autoflush" >The Autoflush Option</a> for information on auto_flush.
</p>
<li> <p><span class="codeline">trim = ["left"|"right"|"both"]</span> - provides automatic left and/or right whitespace trimming for the output of a component. This is the equivalent of a <%filter> section utilizing <span class="codeline">string.strip()</span> combined with <span class="codeline">autoflush=False</span>. This allows component source code to be laid out on multiple lines without the whitespace surrounding the component output being presented in the final output. For information on trim, see the section <a href="#filtering_filtering_trim" >Filtering Whitespace - the Trim Flag</a>.</p>
<li><p><span class="codeline">use_cache</span> - Enables caching for the component. See <a href="#caching" >Data Caching</a> for further cache options.
</p>
<li><p><span class="codeline">encoding = ["utf-8" | "latin-1" | etc ]</span> - Specifies the character encoding of the component's text file (such as utf-8, etc.). This encoding goes directly to the Python "magic comment" at the top of the generated Python component, so any character set is supported by Myghty templates.
</p>
<li><p><span class="codeline">persistent = [True|False]</span> - overrides the per-interpreter setting of <b>delete_modules</b> to specify that this file-based component should or should not specifically have it's module removed from sys.modules when it has fallen from scope. A file-based component that contains class definitions which may remain active after the component itself has fallen out of use may want to do this.</p>
</ul>
<p>Flags may be specified via the <%flags> tag, or for subcomponents and methods may be specified as inline attributes within the <%def> or <%method> tags. The <%flags> tag may appear anywhere in a component, or even across multiple %flags sections, and will still take effect before a component is actually executed.</p>
<p>Example: the <%flags> tag:</p>
<div class="code">
<pre><span class="blocktag"><%flags></span>
<span class="python_operator"> </span><span class="python_name">inherit </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">
</span><span class="python_name">autoflush </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span><span class="blocktag"></%flags></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> ...
</span><span class="blocktag"></%python></span></pre></div>
<p>Example: subcomponent flags as attributes:</p>
<div class="code">
<pre><span class="deftag"><%method</span><span class="compname"> getlink trim="both"</span><span class="deftag">></span><span class="text">
</span><span class="blocktag"><%init></span>
<span class="python_operator"></span> <span class="blocktag"></%init></span><span class="text">
<A href="foo.bar">lala</a>
</span><span class="deftag"></%method></span></pre></div>
</div>
<a href="#otherblocks" class="toclink">back to section top</a>
</div>
<A name="otherblocks_attr"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext"><%attr></span>
<div class="sectiontext">
<p>%attr simply sets some attributes on the component. These attributes are accessed via the <a href="#components_members_attributes" >attributes</a> member of the component. Below, two attributes are accessed from a component to provide style information. One uses <a href="#request_members_current_component" >current_component</a>, and the other uses <a href="#request_members_base_component" >base_component</a>. The difference is the former always returns the very same component that is currently executing, whereas the latter corresponds to the component at the bottom of the inheritance chain:</p>
<div class="code">
<pre><span class="blocktag"><%attr></span>
<span class="python_operator"> </span><span class="python_name">bgcolor </span><span class="python_operator">= </span><span class="python_literal">"#FF0000"</span><span class="python_operator">
</span><span class="python_name">fgcolor </span><span class="python_operator">= </span><span class="python_literal">"#FA456A"</span><span class="python_operator">
</span><span class="blocktag"></%attr></span><span class="text">
<style>
body {
background-color: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">current_component</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'bgcolor'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">;
text-color: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">base_component</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'fgcolor'</span><span class="python_enclosure">]</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">;
}
</style>
</span><span class="doctag"># ...</span></pre></div>
<p>In both cases, if the attribute does not exist in the current component or within futher inheriting child components, it will then traverse upwards via parent components to locate the attribute. For more information on parent/child relationships between components, see the section <a href="#inheritance" >Inheritance</a>. </p>
</div>
<a href="#otherblocks" class="toclink">back to section top</a>
</div>
<A name="otherblocks_text"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext"><%text></span>
<div class="sectiontext">
<p>%text surrounds a block where Myghty will not parse for control lines, line comments, substitutions, or any other Myghty tag. This allows the placement of free text which is intended to print as is, even if it may contain characters that are normally significant to the Myghty lexer. The %text tag is also essential for writing documentation that illustrates examples of Myghty (or similar) code.</p>
</div>
<a href="#otherblocks" class="toclink">back to section top</a>
</div>
<A name="otherblocks_doc"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext"><%doc></span>
<div class="sectiontext">
<p>%doc is simply a comment string - the content inside of a <%doc> section is discarded upon compilation. Comments can also be stated on a per-line basis using a '#' character as the very first character on a line, as described in <a href="#embedding_comment" >Comment Lines</a>.</p>
</div>
<a href="#otherblocks" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="inheritance"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#otherblocks">Other Blocks</a>
|
Next: <a href="#specialtempl">Special Templates</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Inheritance</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#inheritance_wrapper">The Wrapper Chain</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#inheritance_example">Example - Basic Wrapping</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#inheritance_basecomp">The Base Component</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#inheritance_method">Method and Attribute Inheritance</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#inheritance_methodexample">Method Inheritance Example</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Inheritance allows a file-based component to be "wrapped" by another file-based component. This means the requested page executes as a method call inside of the inheriting page, which executes first.
The basic idea of this is to allow a whole set of pages to have standardized behavior applied to them by an "inheriting" component, the application of which can be as simple as a standard header and footer, or something more complicated such as an authentication scheme, a content caching scheme, or a filtering scheme.
</p>
<p>Inheritance also establishes a relationship between pages with regards to method calling as well as component attributes. </p>
</div>
<A name="inheritance_wrapper"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">The Wrapper Chain</span>
<div class="sectiontext">
<p>A set of pages that all inherit each other is sometimes called the "wrapper chain". The wrapper chain is an actual property of the request, and is determined dynamically for each new request based on what files are present in the filesystem and what inheritance pattern they specify. When a template X inherits from a template Y, and that template in turn inherits from template Z, the wrapper chain is created:
</p>
<div class="code">
<pre><span class="text">Z -> Y -> X</span></pre></div>
<P>The request above was called specifying component X as the requested component. X inherits from Y, either via an explicit flag or an autohandler configuration (more on that later), and Y inherits from Z. Therefore a wrapper chain with Z at the beginning and X at the end is created.
When the request executes, control is passed to Z first. Z performs its component operations, then programmatically instructs the request to call the next component in the wrapper chain, which is Y. Y does the same thing and calls X, the originally requested component. When X is complete, control passes back to Y, and when Y is complete, control passes back to Z.</p>
<p>The flag used to specify that a component should inherit from another is called "inherit", and is specified in the <%flags> section of the component. The component to inherit from is specified by its component-root-relative URI. When an inherited parent component wants to call its inheriting child, it usually uses the <a href="#request_methods_call_next" >call_next</a> method of the request object. The child is only executed if its inherited parent explicitly does so.
</p>
<p>If no "inherit" flag is specified for a page, the page will attempt to inherit from a template in the nearest enclosing directory named "autohandler". Whereas the inherit flag allows a component to explicitly specify its inherited parent, the autohandler mechanism allows the configuration of implicitly inheriting parents. Autohandlers are described in the next section <a href="#specialtempl_autohandler" >Autohandlers</a>.</p>
</div>
<a href="#inheritance" class="toclink">back to section top</a>
</div>
<A name="inheritance_example"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Example - Basic Wrapping</span>
<div class="sectiontext">
<p>In this example, the requested page is called "index.myt", and its inherited parent is called "base.myt". base.myt supplies a standard HTML header and footer, and index.myt supplies the content in the middle of the <body> tags.</p>
<div class="code">
<div class="codetitle">index.myt, inherits from base.myt</div>
<pre><span class="blocktag"><%flags></span><span class="python_name">inherit</span><span class="python_operator">=</span><span class="python_literal">'/base.myt'</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
I am index.myt</span></pre></div>
<div class="code">
<div class="codetitle">base.myt, the parent template</div>
<pre><span class="text"><html>
<body>
<h3>example of content wrapping</h3>
</span><span class="doctag"># fetch the next component in the wrapper chain
</span><span class="doctag"># and call it
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator"></span>
<span class="text">
</body>
</html></span></pre></div>
The resulting document would be:
<div class="code">
<pre><span class="text"><html>
<body>
<h3>example of content wrapping</h3>
I am index.myt
</body>
</html></span></pre></div>
<p>While the <a href="#request_methods_call_next" >call_next</a> method of request is the simplest way to call the next component in the wrapper chain, the method <a href="#request_methods_fetch_next" >fetch_next</a> exists to pop the next component off the chain but not execute it, as well as <a href="#request_methods_fetch_all" >fetch_all</a> which pops off and returns the entire list of components in the wrapper chain.
</p>
</div>
<a href="#inheritance" class="toclink">back to section top</a>
</div>
<A name="inheritance_basecomp"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">The Base Component</span>
<div class="sectiontext">
<p>In the wrapper chain "Z -> Y -> X" described at the beginning of the section, the component X is known as the request component, and is accessible throughout the life of the request via the <a href="#request_members_request_component" >request_component</a> member of the request. It also is established as the initial "base component" of the request. The base component is accessible via the <a href="#request_members_base_component" >base_component</a> request member, and it is defined first as the lead requested component in a wrapper chain. When methods in other template files are called, the base component changes to be the file that the method appears in, throughout the life of that method's execution, and upon method completion returns to its previous value.</p>
<p>The base component is also referred to by the special component keyword 'SELF'. This keyword can be used directly via the <a href="#request_methods_fetch_component" >fetch_component</a> method, but it is more commonly referenced in method component calls, as detailed in the next section.
</div>
<a href="#inheritance" class="toclink">back to section top</a>
</div>
<A name="inheritance_method"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Method and Attribute Inheritance</span>
<div class="sectiontext">
<p>Methods, first described in <a href="#components_methods" >Component Methods</a>, are normally called with the <location>:<methodname> syntax, where <location> is the URI or special keyword identifier of a component, and <methodname> is the name of the method to search for.
This syntax enables the component to search not only its local method list for the requested method, it also will search its immediate parent for the method if not found, and that parent will continue the search up the wrapper chain.
</p>
<p>
It is for this reason that the base component and the SELF keyword is of particular value in fetch_component and method calls, since it indicates the innermost component in the current inheritance chain. An template at the end of a wrapper chain (i.e. template Z in the previous section) can specify the SELF keyword when calling a method, and the method will be located from the innermost template first (i.e. component X), and on up the wrapper chain until found.
</p>
<p>Similarly, component attributes are located using an inheritance scheme as well. Attributes are referenced via the <a href="#components_members_attributes" >attributes</a> member of the component object. The attributes dictionary, while it is a regular dictionary interface, will search for requested values in the parent of the component if not found locally.
</p>
</div>
<a href="#inheritance" class="toclink">back to section top</a>
</div>
<A name="inheritance_methodexample"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Method Inheritance Example</span>
<div class="sectiontext">
<P>Here is an example where the parent component is an autohandler, which because of its name, automatically becomes the inherited parent of the child component, as long as the child component does not explicitly specify otherwise.</p>
<p>Both in the parent component as well as the child component that inherits from it specify a method "title". The autohandler can render the title of the page via the "title" method, where it is guaranteed to exist at least in the autohandler's own version of the method, but can be overridden by the inheriting page. Additionally, the autohandler has an <%attr> section indicating the path to a file location. The child page will look in its own attribute dictionary for this location, where it will ultimately come from the inheriting parent.</p>
<div class="code">
<div class="codetitle">autohandler - specifies root title method and attributes</div>
<pre><span class="blocktag"><%attr></span>
<span class="python_comment"># path to some files</span>
<span class="python_operator"> </span><span class="python_name">fileroot </span><span class="python_operator">= </span><span class="python_literal">'/docs/myfiles'</span><span class="python_operator">
</span><span class="blocktag"></%attr></span><span class="text">
<html>
<head>
<title>
</span><span class="doctag"># the "title" method is called here from SELF,
</span><span class="doctag"># so the method will be searched in the base component first,
</span><span class="doctag"># then traverse up the inheritance chain until found
</span><span class="text"> </span><span class="compcall"><& </span><span class="compname">SELF:title </span><span class="compcall">&></span><span class="text">
</title>
</head>
<body>
</span><span class="doctag"># call the next component in the wrapper chain
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator"></span>
<span class="text">
</body>
</html>
</span><span class="doctag"># default "title" method implementation
</span><span class="deftag"><%method</span><span class="compname"> title</span><span class="deftag">></span><span class="text">
Welcome to My Site
</span><span class="deftag"></%method></span></pre></div>
<div class="code">
<div class="codetitle">pressrelease.myt - overrides title method</div>
<pre><span class="blocktag"><%python scope="init"></span>
<span class="python_comment"># locate the file root via a parent attribute</span>
<span class="python_operator"> </span><span class="python_name">pr </span><span class="python_operator">= </span><span class="python_name">get_press_releases</span><span class="python_enclosure">(</span><span class="python_name">fileroot </span><span class="python_operator">= </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'fileroot'</span><span class="python_enclosure">])</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
</span><span class="doctag"># specify a title method to override that of the parent's
</span><span class="deftag"><%method</span><span class="compname"> title</span><span class="deftag">></span><span class="text">
My Site: Press Releases
</span><span class="deftag"></%method></span><span class="text">
<h2>Press Releases</h2>
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_keyword">for </span><span class="python_name">release </span><span class="python_keyword">in </span><span class="python_name">pr</span><span class="python_operator">:</span>
<span class="text">
</span><span class="doctag"># ... print data ...
</span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"></span></pre></div>
</div>
<a href="#inheritance" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="specialtempl"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#inheritance">Inheritance</a>
|
Next: <a href="#filtering">Filtering and Flushing (and Escaping)</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Special Templates</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#specialtempl_autohandler">autohandler</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#specialtempl_dhandler">dhandler</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#specialtempl_modulecomponents">Using Module Components for autohandler/dhandler</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
</div>
<A name="specialtempl_autohandler"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">autohandler</span>
<div class="sectiontext">
<P>an autohandler is an optional file, by default named <span class="codeline">autohandler</span>, that will serve as the base inheriting template for all requests within a directory and its subdirectories. Inheritance is discussed in more detail in the section <a href="#inheritance" >Inheritance</a>. The basic idea is that the autohandler template executes first; it runs some code and/or outputs some HTML, and then calls a special method to deliver the content of the requested template. When the embedded template has completed its execution, the autohandler can then output some more HTML at the bottom and/or execute cleanup code:</p>
<div class="code">
<pre><span class="text"><html>
<head>autohandler demo</head>
<body>
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator"></span>
<span class="text"></body>
</html></span></pre></div>
<p>Autohandlers are searched for first in the current directory, then upwards in the enclosing directories, until the component root is reached. If more than one autohandler is found, they will all be executed within each other, with the most directory-specific autohandler executed at the innermost level. Any page or autohandler can deny the execution of an enclosing autohandler by setting the "inherit" flag to be None.</p>
<p>Autohandlers are ideal for standardized HTML enclosing schemes as above. There are also many more creative uses. An autohandler that automatically protects a whole directory based on a custom login scheme would look something like this:</p>
<div class="code">
<pre><span class="doctag"># autohandler
</span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_comment"># look in the apache request for some kind of </span>
<span class="python_comment"># login token</span>
<span class="python_operator"> </span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">login_manager</span><span class="python_operator">.</span><span class="python_name">check_login</span><span class="python_enclosure">(</span><span class="python_name">r</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">if not </span><span class="python_name">user</span><span class="python_operator">:
</span><span class="python_comment"># redirect out of here, the rest of the content</span>
<span class="python_comment"># in this page will not be sent</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"/login.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_comment"># otherwise, they are ok, deliver content</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
</div>
<a href="#specialtempl" class="toclink">back to section top</a>
</div>
<A name="specialtempl_dhandler"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">dhandler</span>
<div class="sectiontext">
<p>A dhandler, otherwise known as a directory handler, is a file, by default named <span class="codeline">dhandler</span>, that serves requests for which the requested Myghty template can not be located, or for a request that names a directory by itself without a file. dhandlers are searched for similarly to autohandlers, i.e. in the innermost enclosing directory first, then upwards towards the component root. However, only one dhandler is executed at a time. The code within the dhandler has access to the request member <a href="#request_members_dhandler_path" >dhandler_path</a> which refers to the path information for the requested (but unlocated) component, relative to the path of the current dhandler. It also can call <a href="#request_methods_decline" >decline</a> which will abort the current dhandler and search up the directory tree for the next enclosing dhandler.</p>
<p>Dhandlers are good for special path-based requests used in places such as news sites who want to have clean URLs that have no query strings, for writing components that process the contents of a directory dynamically, such as image or filesystem browsers, or custom per-directory "file not found" handlers.</p>
<p>Example: content management system. A lot of news sites have fancy URLs with dates and article keywords (sometimes called slugs) specified within them. These URLs sometimes are resolved into database parameters, and the actual content is retrieved from some source that is not the same as a local file with that path scheme. This example extracts tokens from a URI and uses them as parameters to retrieve content.</p>
<div class="code">
<pre><span class="doctag"># Hypothetical URL:
</span><span class="doctag"># http://foonews.com/news/2004/10/23/aapl.myt
</span><span class="text">
</span><span class="doctag"># dhandler, inside of the web directory /news/
</span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_keyword">import </span><span class="python_name">re</span><span class="python_operator">
</span>
<span class="python_comment"># get path</span>
<span class="python_name">path </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">dhandler_path</span><span class="python_operator">
</span>
<span class="python_comment"># get arguments from the path</span>
<span class="python_name">match </span><span class="python_operator">= </span><span class="python_name">re</span><span class="python_operator">.</span><span class="python_name">match</span><span class="python_enclosure">(</span><span class="python_literal">r"(\d+)\/(\d+)\/(\d+)\/(\w+)\.myt"</span><span class="python_operator">, </span><span class="python_name">path</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_keyword">if </span><span class="python_name">match</span><span class="python_operator">:
</span><span class="python_enclosure">(</span><span class="python_name">year</span><span class="python_operator">, </span><span class="python_name">month</span><span class="python_operator">, </span><span class="python_name">day</span><span class="python_operator">, </span><span class="python_name">slug</span><span class="python_enclosure">) </span><span class="python_operator">= </span><span class="python_name">match</span><span class="python_operator">.</span><span class="python_name">groups</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># look up a news article in a </span>
<span class="python_comment"># hypothetical content-management database </span>
<span class="python_comment"># based on this parameters from the path</span>
<span class="python_name">article </span><span class="python_operator">= </span><span class="python_name">db</span><span class="python_operator">.</span><span class="python_name">lookup</span><span class="python_enclosure">(</span><span class="python_name">year</span><span class="python_operator">, </span><span class="python_name">month</span><span class="python_operator">, </span><span class="python_name">day</span><span class="python_operator">, </span><span class="python_name">slug</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_name">article </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">if </span><span class="python_name">article </span><span class="python_keyword">is </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_comment"># improper URL, or no article found</span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"article_not_found.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
<!-- display the article -->
<h3></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">article</span><span class="python_operator">.</span><span class="python_name">get_headline</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></h3>
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">article</span><span class="python_operator">.</span><span class="python_name">get_text</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>The tricky part about a dhandler in conjunction with Apache is that the URL used to access the dhandler has to be identified by apache as a Myghty request. For a basic setup that associates *.myt with Myghty files, the URL used to access the dhandler would have to end with the string ".myt". To call dhandlers more flexibly, you would have to insure that Apache is configured to send all requests for a particular directory to Myghty for processing, using a directive like DirectoryMatch or FilesMatch.</p>
</div>
<a href="#specialtempl" class="toclink">back to section top</a>
</div>
<A name="specialtempl_modulecomponents"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Using Module Components for autohandler/dhandler</span>
<div class="sectiontext">
<p>First described in <a href="#modulecomponents" >Module Components</a>, these components can also be used as autohandlers or dhandlers. Simply configure the Myghty environment to recognize paths with "autohandler" and/or "dhandler" as module component paths:</p>
<div class="code">
<pre><span class="python_name">module_components </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># configure the root autohandler to resolve to Autohandler class</span>
<span class="python_enclosure">{</span><span class="python_literal">r'/autohandler$' </span><span class="python_operator">: </span><span class="python_literal">'modcomp:Autohandler'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_comment"># configure all dhandlers to resolve to Dhandler class</span>
<span class="python_enclosure">{</span><span class="python_literal">r'.*/dhandler$' </span><span class="python_operator">: </span><span class="python_literal">'modcomp:Dhandler'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>
In particular, code-intensive autohandlers and dhandlers such as content delivery mechanisms, translation components, or authentication controllers would be suitable as module components. Also see the section <a href="#resolver" >Advanced Resolver Configuration</a> for more information on the resolution of autohandlers and dhandlers.
</p>
</div>
<a href="#specialtempl" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="filtering"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#specialtempl">Special Templates</a>
|
Next: <a href="#session">Session</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Filtering and Flushing (and Escaping)</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#filtering_autoflush">The Autoflush Option</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_autoflush_subcomponents">Setting Autoflush in Subcomponents</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_autoflush_autohandlers">Non-Buffered with Autohandlers</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#filtering_filtering">Filtering</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_filter">The <%filter> Tag</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_escapefilter">Escaping Content in a Filter Section</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_filterflush">Filtering Behavior with Autoflush Enabled</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_filtering_trim">Filtering Whitespace - the Trim Flag</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#filtering_escaping">Escaping Content</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_substitutions">Escaping Substitutions</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_programmatic">Programmatic Escaping</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_custom">Custom Escape Flags</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#filtering_escaping_custom">Default Escape Flags</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>This section describes some options that can be applied to Myghty components which affect how the request object deals with their output. The request object supports the capturing of component output in a buffer which is flushed upon completion to provide simple and flexible component output behavior, or sending the output directly to the underlying output stream to provide faster perceived response time. This option is known as <b>autoflush</b>. Post-processing functions can be attached to the final output of a component at the top-level or callable component level, allowing user-defined text operations on the output, known as <b>filtering</b>. Autoflushing and filtering have some dependencies on each other, so they are described together.</p>
<p>As a convenient alternative to filtering, common text-escaping functions applicable to a web application environment, plus support for user-defined escape functions, are provided under the functionality of <b>escapes</b>, described at the end of the section.</p>
</div>
<A name="filtering_autoflush"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">The Autoflush Option</span>
<div class="sectiontext">
<p>The <span class="codeline">autoflush</span> option controls whether the output of a component is sent to the underlying output stream as it is produced, or if it is first captured in a buffer which is then sent in one chunk at the end of the request's lifecycle. This is significant in a web context, as it affects "perceived performance", which means the response time of an unbuffered page is nearly immediate, even though the time it takes to finish might be the same as that of a buffered page.</p>
<P>While the autoflush option can improve perceived performance, there are also increased complexities with an autoflushed, i.e. unbuffered page. HTTP headers, including hard redirects, must be sent before any content is written, else the response will have already begun and any new headers will simply be displayed with the page's content. A soft redirect, not being dependent on HTTP headers, will still function, but it's output also may be corrupted via any preceding output. Error messages also will appear inline with already existing content rather than on a page of their own.</p>
<p>
The option can be set for an entire application, for a set of files or directories via autohandlers/inherited superpages, for an individual page, or even an individual method or subcomponent within a page. Within all of those scopes, the flag can be set at a more specific level and will override the more general level. </p>
<p>With no configuration, the parameter defaults to <span class="codeline">False</span>, meaning that component output is captured in a buffer, which is flushed at the end of the request or subcomponent's execution. This produces the simplest behavior and is fine for most applications.</p>
<p>But, here you are and you want to turn <span class="codeline">autoflush</span> on. To set it across an entire application, specify <span class="codeline">autoflush=True</span> to the Interpreter or HTTPHandler being used. Or to configure via http.conf with mod_python:</p>
<div class="code">
<pre><span class="text">PythonOption MyghtyAutoflush True</span></pre></div>
<p>When autoflush is true for an entire application, no buffer is placed between the output of a component and the underlying request output stream. The flag can be overridden back to <span class="codeline">False</span> within directories and pages via the use of the <span class="codeline">autoflush</span> flag within the %flags section of the page. To set the value of autoflush for a particular directory, place an <span class="codeline">autohandler</span> file at the base of the directory as such:
<div class="code">
<pre><span class="blocktag"><%flags></span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator"></span></pre></div>
<p>The Myghty request will run the autohandler which then calls the inherited page via the <span class="codeline">m.call_next()</span> call. The autoflush flag indicates that buffering should be enabled for the execution of this page, overriding the per-application setting of True. </p>
<p>The ultimate <span class="codeline">autoflush</span> flag that is used for a page is the innermost occuring flag within the templates that comprise the wrapper chain. If no autoflush flag is present, the next enclosing template is used, and if no template contains an autoflush flag, the application setting is used. Even though an autohandler executes before the page that it encloses, the Myghty request figures out what the autoflush behavior should be before executing any components so that it takes the proper effect.</p>
<p>So any page can control its own autoflush behavior as follows:</p>
<div class="code">
<pre><span class="blocktag"><%flags></span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
<html>
<head>
...
</html></span></pre></div>
</div>
<A name="filtering_autoflush_subcomponents"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Setting Autoflush in Subcomponents</span>
<div class="sectiontext">
<p>
Subcomponent or methods can determine their autoflush behavior as follows:
</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> mycomp</span><span class="deftag">></span><span class="text">
</span><span class="blocktag"><%flags></span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
... stuff ...
</span><span class="deftag"></%def></span></pre></div>
<p>There is one limitation to the autoflush flag when used in a subcomponent. If autoflush is set to True on a subcomponent, within a request that has autoflush set to False, the component will send its unfiltered data directly to the output stream of its parent; however since the overall request is not autoflushing and is instead capturing its content in a buffer of its own, the content is still stored in a buffer, which does not get sent to the client until the request is complete. Note that this limitation does not exist the other way around; if an overall request is autoflushing, and a subcomponent sets autoflush to False, that subcomponent's output will be buffered, until the subcomponent completes its execution. This is significant for a subcomponent whos output is being processed by a <%filter> section. More on this later.
</p>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_autoflush_autohandlers"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Non-Buffered with Autohandlers</span>
<div class="sectiontext">
<p>What happens when a page in an autoflush=True environment interacts with one or more autohandlers or inherited superpages? The superpage will execute first, output whatever content it has before it calls the subpage, and then will call <span class="codeline">m.call_next()</span> to pass control to the subpage. If the subpage then wants to play with HTTP headers and/or perform redirects, it's out of luck:</p>
<div class="code">
<div class="codetitle">autohandler - autoflush enabled</div>
<pre><span class="blocktag"><%flags></span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
<html>
<head></head>
<body>
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">call_next</span><span class="python_enclosure">()</span><span class="python_operator"></span>
<span class="text"> </body>
</html></span></pre></div>
<div class="code">
<div class="codetitle">page.myt - wants to send a redirect</div>
<pre><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"page2.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>The above example will fail! Since the autohandler executes and prints the top HTML tags to the underlying output stream, by the time page.myt tries to send its redirect, the HTTP headers have already been written and you'll basically get a broken HTML page. What to do? Either page.myt needs to specify that it is not an autoflushing page, or it can detach itself from its inherited parent.</p>
<p>Solution One - Turn Autoflush On:</p>
<div class="code">
<div class="codetitle">page.myt</div>
<pre><span class="blocktag"><%flags></span><span class="python_name">autoflush</span><span class="python_operator">=</span><span class="python_name">False</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"page2.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>This is the most general-purpose method, which just disables autoflush for just that one page.</p>
<p>Solution Two - Inherit from None</p>
<div class="code">
<div class="codetitle">page.myt</div>
<pre><span class="blocktag"><%flags></span><span class="python_name">inherit</span><span class="python_operator">=</span><span class="python_name">None</span><span class="python_operator"></span><span class="blocktag"></%flags></span><span class="text">
</span><span class="blocktag"><%python scope="init"></span>
<span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">send_redirect</span><span class="python_enclosure">(</span><span class="python_literal">"page2.myt"</span><span class="python_operator">, </span><span class="python_name">hard</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>This method is appropriate for a page that never needs to output any content, i.e. it always will be performing a redirect. The autohandler here is not inherited, so never even gets called. This saves you the processing time of the autohandler setting up buffers and producing content. Of course, if there are autohandlers that are performing operations that this subpage depends upon, then you must be sure to inherit from those pages, possibly through the use of "alternate" autohandlers that inherit only from the desired pages.
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
</div>
<A name="filtering_filtering"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Filtering</span>
<div class="sectiontext">
<p>Filtering means that the output stream of a component is sent through a text processing function which modifies the content before it is passed on to the ultimate output stream. Typical usages of text filtering are modifying entity references, trimming whitespace, converting plain-text to HTML, and lots of other things. For the general purpose per-component filter, Myghty supplies the <nobr><%filter></nobr> tag.
</p>
</div>
<A name="filtering_filtering_filter"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">The <%filter> Tag</span>
<div class="sectiontext">
<p>%filter describes a filtering function that is applied to the final output of a component. This is more common on subcomponents or methods but works within the scope of any top-level component as well. The Python code within the %filter section provides the body of the to be used; the heading of the function is generated within the compiled component and not normally seen. The filter function is provided with one argument <i>f</i> which contains the content to be filtered; the function processes content and returns the new value.</p>
<p>Example:</p>
<div class="code">
<pre><span class="blocktag"><%filter></span>
<span class="python_keyword">import </span><span class="python_name">re</span><span class="python_operator">
</span><span class="python_keyword">return </span><span class="python_name">re</span><span class="python_operator">.</span><span class="python_name">sub</span><span class="python_enclosure">(</span><span class="python_literal">r"turkey"</span><span class="python_operator">, </span><span class="python_literal">"penguin"</span><span class="python_operator">, </span><span class="python_name">f</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%filter></span><span class="text">
dang those flyin turkeys !</span></pre></div>
<p> will produce:</p>
<div class="code">
<pre><span class="text">dang those flyin penguins !</span></pre></div>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_filtering_escapefilter"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Escaping Content in a Filter Section</span>
<div class="sectiontext">
<p>Myghty has some built in escaping functions, described in the next section <a href="#filtering_escaping" >Escaping Content</a>. While these functions are easy enough to use within substitutions or any other Python code, you can of course use them within a filter section as well.</p>
<p>This is a component that HTML escapes its output, i.e. replaces the special characters &, <, and > with entity reference encoding:</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> bodytext</span><span class="deftag">></span><span class="text">
</span><span class="blocktag"><%filter></span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">apply_escapes</span><span class="python_enclosure">(</span><span class="python_name">f</span><span class="python_operator">, </span><span class="python_literal">'h'</span><span class="python_enclosure">)</span><span class="python_operator">
</span> <span class="blocktag"></%filter></span><span class="text">
# ... component output
</span><span class="deftag"></%def></span></pre></div>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_filtering_filterflush"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Filtering Behavior with Autoflush Enabled</span>
<div class="sectiontext">
<p>The usual case when a %filter section is used is that all <span class="codeline">m.write()</span> statements, both explicit and implicit, send their content to a buffer. Upon completion of the component's execution, the buffer's content is passed through the function defined in the %filter section. However when autoflush is enabled, the extra buffer is not used and the filtering function is attached directly to each call to <span class="codeline">m.write()</span>. For regular blocks of HTML, the entire block is sent inside of one big <span class="codeline">write()</span> statement, but each python substitution or other code call splits it up, resulting in another call to <span class="codeline">write()</span>.</p>
<p>Since a non-autoflushing component is more predictable for filtering purposes than an autoflushing component, it is often useful to have autoflush disabled for a component that uses a %filter section. As stated in the autoflush section, autoflushing behavior can be changed per component, per page or for the whole application, and is the default value as well. There is also another configuration option
can be overridden for all filter components by the setting "dont_auto_flush_filters" - see the section <a href="#parameters" >Index of Configuration Parameters</a> for more information.</p>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_filtering_trim"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Filtering Whitespace - the Trim Flag</span>
<div class="sectiontext">
<p>A common need for components is to trim off the whitespace at the beginning and/or the end of a component output. It is convenient to define subcomponents and methods on multiple lines, but this inherently includes newlines in the output of that component, since Myghty sees the blank lines in the source. But lots of times the ultimate output of a component needs to not have any surrounding whitespace, such as a component that outputs a hyperlink. While a regular %filter section can be used for this, Myghty provides the <span class="codeline">trim</span> flag, as so:</p>
<div class="code">
<pre><span class="text">for more information, click </span><span class="compcall"><&m</span><span class="compname">akelink</span><span class="python_operator">, </span><span class="python_name">a</span><span class="python_operator">=</span><span class="python_literal">"here"</span><span class="python_operator">, </span><span class="python_name">p</span><span class="python_operator">=</span><span class="python_number">4.3</span><span class="python_operator">, </span><span class="python_name">xg</span><span class="python_operator">=</span><span class="python_literal">"foo"</span><span class="python_operator"> </span><span class="compcall">&></span><span class="text">.
</span><span class="deftag"><%def</span><span class="compname"> makelink trim="both"</span><span class="deftag">></span><span class="text">
</span><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">p</span><span class="python_operator">
</span><span class="python_name">xg</span><span class="python_operator">
</span><span class="python_name">a</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
</span><span class="doctag"><%doc></span><span class="doctag_text">note this component has a lot of whitespace in it</span><span class="doctag"></%doc></span><span class="text">
<A href="http://foo.myt?xg=</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">xg</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">&p=</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">p </span><span class="python_operator">| </span><span class="python_name">u</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">"></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">a</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></a>
</span><span class="deftag"></%def></span></pre></div>
<p>Output:</p>
<div class="code">
<pre><span class="text">for more information, click <A href="http://foo.myt?xg=foo&p=4.3">here</a>.</span></pre></div>
<p><span class="codeline">trim</span> supports the three options <span class="codeline">left</span>, <span class="codeline">right</span>, or <span class="codeline">both</span>, trimming whitespace on the left, right and both sides of component output, respectively.
</p>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
</div>
<A name="filtering_escaping"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Escaping Content</span>
<div class="sectiontext">
<p>Escaping usually refers to a kind of filtering that converts the characters in a string into encoded values that can be safely passed through other character-parsing systems without them interfering.</p>
<p>Myghty provides built in support for HTML and URL escaping (also called URL encoding), and has plans for entity-reference escaping. User-defined escape functions can be added to an application as well.
</p>
</div>
<A name="filtering_escaping_substitutions"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Escaping Substitutions</span>
<div class="sectiontext">
<p>Substitutions, first introduced in <a href="#embedding_substitutions" >Substitutions</a>, can include escape flags, specified by the following notation:</p>
<div class="code">
<pre><span class="text">
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_literal">"i am an argument" </span><span class="python_operator">| </span><span class="python_name">u</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>The above example will URL encode the embedded string. The two escape flags included with Myghty are "u" for url encoding, and "h" for HTML encoding. Entity reference encoding is in the works.</p>
<p>Multiple escape flags are separated by a comma:</p>
<div class="code">
<pre><span class="text">
</span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_literal">"multiple escapes" </span><span class="python_operator">| </span><span class="python_name">h</span><span class="python_operator">, </span><span class="python_name">u</span><span class="python_operator"> </span><span class="substitution">%></span></pre></div>
<p>Which will HTML and URL escape the given string.</p>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_escaping_programmatic"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Programmatic Escaping</span>
<div class="sectiontext">
<p>The HTML and URL-encoded escaping functions described above are easy enough to use programmatically as well. The request object provides the escaping functions via the <span class="codeline">apply_escapes()</span> method for this purpose. This method uses the same flags as an escaped substitution, the defaults being "h" for HTML escaping and "u" for URL encoding.</p>
<p>In this example, a component receives the argument "text" and displays it in a textarea, where HTML escaping is required:</p>
<div class="code">
<pre><span class="argstag"><%args></span>
<span class="python_operator"> </span><span class="python_name">text</span><span class="python_operator">
</span><span class="argstag"></%args></span><span class="text">
</span><span class="blocktag"><%python></span>
<span class="python_comment"># HTML escape the given text</span>
<span class="python_operator"> </span><span class="python_name">text </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">apply_escapes</span><span class="python_enclosure">(</span><span class="python_name">text</span><span class="python_operator">, </span><span class="python_literal">'h'</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%python></span><span class="text">
<textarea></span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">text</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text"></textarea></span></pre></div>
<p>The first argument to <span class="codeline">apply_escapes()</span> is the text to be escaped, and the second is a list of escape flags. Since strings are lists in Python, multiple flags can be specified either in a single string as in <span class="codeline">"hu"</span> or as a regular list such as <span class="codeline">['h', 'u']</span>.
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_escaping_custom"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Custom Escape Flags</span>
<div class="sectiontext">
<p>You can add your own escape flags to your application via the <span class="codeline">escapes</span> configuration parameter. <span class="codeline">escapes</span> is in the form of a dictionary, with the key names being the single-character escaping token and the values being function pointers to escaping functions.</p>
<p>In this example, an escape flag 'p' is added which provides the ability to convert the word "turkey" into "penguin":
<div class="code">
<pre><span class="text">escapes = {
'p':re.sub('turkey', 'penguin', f)
}</span></pre></div>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
<A name="filtering_escaping_custom"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Default Escape Flags</span>
<div class="sectiontext">
<p>Default escaping can be configured via the configuration parameter <span class="codeline">default_escape_flags</span> (PythonOption MyghtyDefaultEscapeFlags). The format of this parameter is a list of escape flag characters. This applies the given flags to <b>all</b> substitutions in an application.</p>
<p>When default escaping is used, the special flag "n" can be specified in the substitution to disable the default escape flags for that substitution.</p>
</div>
<a href="#filtering" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="session"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#filtering">Filtering and Flushing (and Escaping)</a>
|
Next: <a href="#caching">Data Caching</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Session</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#session_usage">Basic Usage</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#session_options">Session Options</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#session_methods">Session Methods</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#session_members">Session Members</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#session_object">Using the Session Object Standalone</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Myghty now has its own session storage class. This class offers some advantages over the mod python session, including:</p>
<ul>
<li>It is independent of mod_python, so it works with either version of Apache, other web connectors, and in CGI mode
<li>The file-based version keeps each user's session in separate DBM files, so no synchronization issues are present
between disparate sessions, session files are small, and old sessions can be cleaned up via an external file-deletion process.
<li>The session object loads its data in immediately from the persistent store and unlocks, so that a page containing multiple session-enabled requests (i.e., such as a page with IFRAMEs or image delivery servlets) can allow access to all of its sub-elements with a minimum of waiting between the concurrent requests.
<li>The package can also run directly with the mod_python request, independently of Myghty.
</ul>
</div>
<A name="session_usage"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Basic Usage</span>
<div class="sectiontext">
<p>The session is retrieved from the request object via the get_session() method, operated upon like a dictionary, and then can have its <span class="codeline">save()</span> method called to write its data to persistent storage:</p>
<div class="code">
<pre><span class="blocktag"><%python scope="init"></span>
<span class="python_comment"># get the session</span>
<span class="python_operator"> </span><span class="python_name">session </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_session</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># add data</span>
<span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'key1'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'foo'</span><span class="python_operator">
</span>
<span class="python_comment"># get data</span>
<span class="python_keyword">if </span><span class="python_name">session</span><span class="python_operator">.</span><span class="python_name">has_key</span><span class="python_enclosure">(</span><span class="python_literal">'user'</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'user'</span><span class="python_enclosure">]</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_name">user </span><span class="python_operator">= </span><span class="python_name">User</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">session</span><span class="python_enclosure">[</span><span class="python_literal">'user'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_name">user</span><span class="python_operator">
</span>
<span class="python_comment"># save new information</span>
<span class="python_operator"></span><span class="python_name">session</span><span class="python_operator">.</span><span class="python_name">save</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="blocktag"></%python></span></pre></div>
<p>The session handles generation of session IDs automatically as well as storing and retrieving them from cookies. Options exist to pass in custom session IDs, to not use cookies, to use "signed" session IDs, and to change the cookie-based session key (defaulting to <span class="codeline">myghty_session_id</span>). It loads its data in fully when instantiated and then unlocks, so no programmatic locking or unlocking is necessary (but lock methods are available if you want the session to stay locked throughout a request).</p>
</div>
<a href="#session" class="toclink">back to section top</a>
</div>
<A name="session_options"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Session Options</span>
<div class="sectiontext">
<p>Session options are specified as Myghty configuration parameters in the form <span class="codeline">session_XXXX</span>, to identify them as options being sent to the Session object. When calling the m.get_session() method, parameters may be specified with or without the "session_" prefix; they are stripped off. </p>
<p>The get_session method can take any of the configuration parameters that are identified below as used directly by the Session object or by the underlying Namespace objects.</p>
<table cellspacing="0">
<tr class="light">
<td valign="top">
<A name="session_options_session_cookie_expires"></a>
<b>session_cookie_expires</b> (boolean, datetime, timedelta)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: True<br/>
used by: Session
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The expiration time to use on the session cookie. Defaults to "True" which means, dont specify any expiration time (the cookie will expire when the browser is closed). A value of "False" means, never expire (specifies the maximum date that can be stored in a datetime object and uses that). The value can also be a datetime.timedelta() object which will be added to the current date and time, or a datetime.datetime() object.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_data_dir"></a>
<b>session_data_dir</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The data directory where sessions will be stored. If this argument is not present, the regular
<a href="#parameters_data_dir" >data_dir</a> parameter is used, with the path "./sessions" appended to it.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_session_dbmmodule"></a>
<b>session_dbmmodule</b> (dbm module)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: anydbm<br/>
used by: DBMNamespace
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
When dbm is used as the session type, this parameter points to a module to use for DBM support, such as gdbm, dbhash, etc.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_id"></a>
<b>session_id</b> (String)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Session id for this session. When using sessions with cookies, this parameter is not needed as the session automatically creates, writes and retrieves the value from the request. When using a URL-based method for the session, the id should be retreived from the <a href="#session_members_id" >id</a> data member when the session is first created, and then used in writing new URLs.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_session_invalidate_corrupt"></a>
<b>session_invalidate_corrupt</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: False<br/>
used by: Session
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>If there are any exceptions upon loading the session, the entire session will be invalidated and started clean. When object interfaces change in an application, old versions of those objects might still be present in existing session files, and exceptions will be raised when the session object tries to deserialize them into memory. Setting this to True allows those sessions to be cleaned out and started from scratch again.</p>
<p>This parameter should be used carefully since it can conceal real application errors in certain situations.</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_key"></a>
<b>session_key</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: myghty_session_id<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The key that will be used as a cookie key to identify sessions. Changing this could allow several different applications to have different sessions underneath the same hostname.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_session_log_file"></a>
<b>session_log_file</b> (file)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A file or buffer object where debugging information will be sent.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_namespace_class"></a>
<b>session_namespace_class</b> (class)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A class that will be used to create the underlying NamespaceManager used by this Session, when a custom NamespaceManager implementation is being used. By default, the implementation is determined among the built-in NamespaceManagers by the <a href="#session_options_session_type" >session_type</a> parameter.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_session_type"></a>
<b>session_type</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: dbm<br/>
used by: Session
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Type of storage used for the session, current types are "dbm" (also called "file"), and "memory". The storage uses the Container API that is also used by the cache system.
</p>
<p>
When using dbm files, each user's session is stored in its own dbm file, via the class <span class="codeline">myghty.container.DBMNamespaceManager</span> class. To get the dbm filename used by a session, use <span class="codeline">session.namespace.file.path</span>, or to retrieve a list of the actual files created by the particular dbm instance, use <span class="codeline">session.namespace.file.get_filenames()</span>.
</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_secret"></a>
<b>session_secret</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Secret key to enable encrypted session ids. When non-None, the session ids are generated with an MD5-signature created against this value.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_session_timeout"></a>
<b>session_timeout</b> (integer)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Session
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Time in seconds before the session times out. A timeout occurs when the session has not been loaded for more than timeout seconds.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_session_use_cookies"></a>
<b>session_use_cookies</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: True<br/>
used by: Session
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Whether or not to store and retrieve the session ID from the cookies present in the request. If False, the session ID must be present in the argument list to retrieve an existing session.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="session_options_use_modpython_session"></a>
<b>use_modpython_session</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: ApacheHandler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Instructs the get_session() method, or the global variable <i>s</i> if configured, to return an instance of the mod_python session object instead of the Myghty session object. If this is configured, only the <a href="#session_options_session_timeout" >session_timeout</a> parameter is supported.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="session_options_use_session"></a>
<b>use_session</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: ApacheHandler,CGIHandler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Establishes the global variable <i>s</i> as a reference to the Session object. This means all requests will automatically have the session initialized and loaded. If an application has a lot of templates that dont have use for the session, this could add unnecessary overhead.
</p>
</td>
</tr>
</table>
</div>
<a href="#session" class="toclink">back to section top</a>
</div>
<A name="session_methods"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Session Methods</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="light">
<td>
<A name="session_methods_delete"></a>
<b>delete()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
deletes the persistent storage for this session, but the session remains valid. When save() is called, the new data will be written.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_methods_invalidate"></a>
<b>invalidate()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
invalidates this session, creates a new session id, returns to the is_new state
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="session_methods_load"></a>
<b>load()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Loads the data from this session from persistent storage and updates the last modified time of the session. This method is called automatically upon session object construction and does not need to be called explicitly. If the session's persistant storage does not exist, it will be created. If the session has not been accessed since the timeout period, the invalidate() method will be called, and the session will return to the is_new state, as well as was_invalidated.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_methods_lock"></a>
<b>lock()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Locks this session against other accesses. This method is called automatically by the load() and save() methods. However, this method can be called to keep the session locked persistently until explicitly unlocked by the unlock() method.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="session_methods_unlock"></a>
<b>unlock()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Unlocks this session against other accesses. This method is called automatically by the load() and save() methods. However, this method can be called to unlock a persistent lock set up by the lock() method.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_methods_save"></a>
<b>save()</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Saves the data for this session to persistent storage. This should be called whenever you know the session has been modified.
</div>
</td>
</tr>
</table>
</div>
<a href="#session" class="toclink">back to section top</a>
</div>
<A name="session_members"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Session Members</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="light">
<td>
<A name="session_members_accessed"></a>
<b>accessed</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The last time this session was accessed.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_members_created"></a>
<b>created</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The time this session was created.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="session_members_id"></a>
<b>id</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>The id for this session. When using cookies, this is retrieved and set within the cookie referenced by the <a href="#session_members_key" >key</a> string. The id is automatically created when a new session is instantiated.</p>
<p>
When regular cookies are used (the default), this value is the same value sent in the session cookie to the client. When signed cookies are enabled via the <a href="#session_options_session_secret" >session_secret</a> parameter, this id is MD5 signed against the secret to form the client cookie value.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_members_is_new"></a>
<b>is_new</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
True if this session was newly created. This can be because no previous session existed,
or the session existed but was invalidated, usually due to a timeout.
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="session_members_key"></a>
<b>key</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The key used in cookies to set this session's id.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_members_secret"></a>
<b>secret</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="session_members_timeout"></a>
<b>timeout</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The timeout span of this session.
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="session_members_was_invalidated"></a>
<b>was_invalidated</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
True if this session was invalidated upon opening, usually due to a timeout. <a href="#session_members_is_new" >is_new</a> will always be True as well.
</div>
</td>
</tr>
</table>
</div>
<a href="#session" class="toclink">back to section top</a>
</div>
<A name="session_object"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Using the Session Object Standalone</span>
<div class="sectiontext">
<p>The session object is actually functionally independent of the rest of Myghty, and is compatible with the mod python request object directly, as well as the request emulator used by CGIHandler. To instantiate it, simply use its constructor as follows:</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">mod_python </span><span class="python_keyword">import </span><span class="python_name">apache</span><span class="python_operator">
</span><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">session </span><span class="python_keyword">import </span><span class="python_name">Session</span><span class="python_operator">
</span>
<span class="python_keyword">def </span><span class="python_name">handle</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">session </span><span class="python_operator">= </span><span class="python_name">Session</span><span class="python_enclosure">(</span><span class="python_name">req</span><span class="python_operator">, </span><span class="python_name">data_dir</span><span class="python_operator">=</span><span class="python_literal">'/path/to/session_dir'</span><span class="python_operator">, </span><span class="python_name">key</span><span class="python_operator">=</span><span class="python_literal">'user_session_id'</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>The full constructor signature for the Session object is as follows:</p>
<div class="code">
<pre><span class="python_name">Session</span><span class="python_enclosure">(</span><span class="python_name">request</span><span class="python_operator">, </span><span class="python_name">id </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">use_cookies </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">, </span>
<span class="python_name">invalidate_corrupt </span><span class="python_operator">= </span><span class="python_name">False</span><span class="python_operator">,</span>
<span class="python_name">type </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">data_dir </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span>
<span class="python_name">key </span><span class="python_operator">= </span><span class="python_literal">'myghty_session_id'</span><span class="python_operator">, </span><span class="python_name">timeout </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span>
<span class="python_name">secret </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, </span><span class="python_name">log_file </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>Note that the parameters are the same as the configuration arguments with the prefix "session_" removed.</p>
</div>
<a href="#session" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="caching"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#session">Session</a>
|
Next: <a href="#resolver">Advanced Resolver Configuration</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Data Caching</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#caching_component">Caching a Component's Output</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#caching_interface">Programmatic Interface</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#caching_details">More on Caching</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#caching_options">Cache Options</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#caching_types">Cache Types</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Myghty provides the ability to cache any kind of data, including component output, component return values, and user-defined data structures, for fast re-retrieval. All components, whether file-based or subcomponent, are provided with their own cache namespace, which in turn stores any number of key/value pairs. Included with Myghty are implementations using files, dbm files, direct in-memory dictionaries, and <a href="http://www.danga.com/memcached/">memcached</a>. User-defined implementations are also supported and can be specified at runtime. The particular implementation used can optionally be specified on a per-key basis, so that any single namespace can store individual values across any number of implementations at the same time.</p>
<p>
Caching is generally used when there are process-intensive and/or slow operations that must be performed to produce output, and those operations also have little or no dependencies on external arguments, i.e. their value is not likely to change in response to request variables. Examples of things that are good for caching include weather information, stock data, sports scores, news headlines, or anything other kind of data that can be expensive to retrieve and does not need to be updated with real-time frequency.
</p>
<p>The front-end to the mechanism is provided by the <span class="codeline">myghty.cache</span> package, and can be configured and used through global configuration parameters, per-component flags, and a programmatic interface.</p>
</div>
<A name="caching_component"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Caching a Component's Output</span>
<div class="sectiontext">
<p>The simplest form of caching is the caching of a component's return value and output content via flags. An example using a subcomponent (subcomponents are explained in <a href="#components_subcomponent" >How to Define a Subcomponent</a>):</p>
<div class="code">
<pre><span class="deftag"><%def</span><span class="compname"> heavytext</span><span class="deftag">></span><span class="text">
</span><span class="blocktag"><%flags></span>
<span class="python_operator"> </span><span class="python_name">use_cache </span><span class="python_operator">= </span><span class="python_name">True</span><span class="python_operator">
</span><span class="python_name">cache_type </span><span class="python_operator">= </span><span class="python_literal">'dbm'</span><span class="python_operator">
</span><span class="python_name">cache_expiretime </span><span class="python_operator">= </span><span class="python_number">30</span><span class="python_operator">
</span> <span class="blocktag"></%flags></span><span class="text">
</span><span class="blocktag"><%init></span>
<span class="python_operator"> </span><span class="python_name">data </span><span class="python_operator">= </span><span class="python_name">big_long_query</span><span class="python_enclosure">()</span><span class="python_operator">
</span> <span class="blocktag"></%init></span><span class="text">
Your big query returned: </span><span class="substitution"><%</span><span class="python_operator"> </span><span class="python_name">data</span><span class="python_operator">.</span><span class="python_name">get_info</span><span class="python_enclosure">()</span><span class="python_operator"> </span><span class="substitution">%></span><span class="text">
</span><span class="deftag"></%def></span></pre></div>
<p>In this example, the component's output text and its return value (if any) will be stored the first time it is called. Any calls to this component within the next 30 seconds will automatically return the cached value, and the %init section and body will not be executed. At the moment 30 seconds have elapsed, the first call to occur within this new period will result in the component executing in full again and recreating its output text and return value. Subsequent calls that occur during this second execution will continue to return the prior value until the new value is complete. Once the new value is complete, it is stored in the cache and the expiration counter begins again, for the next 30 seconds.</p>
<p>Note that the parameter <span class="codeline">cache_type</span> is set to <span class="codeline">'dbm'</span>, which indicates that dbm-based caching is used. This is the default setting when a data_dir parameter is configured with the Myghty application. </p>
<p>For components that contain a %filter section, the result of filtering is stored in the cache as well. This allows the cache to be useful in limiting the execution of a process-intensive or time-consuming filtering function.
</p>
<p>
When a component is recompiled, its cache contents are automatically expired, so that the cache can be refreshed with the value returned by the newly modified component. This means it is safe to set a cache setting with no expire time at all for a component whose output never changes, and in fact such a component only executes once per compilation and never at all again, for the life of the cache.
</p>
</div>
<a href="#caching" class="toclink">back to section top</a>
</div>
<A name="caching_interface"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Programmatic Interface</span>
<div class="sectiontext">
<p>The traditional caching interface looks like this:
<div class="code">
<pre><span class="blocktag"><%init></span>
<span class="python_operator"> </span><span class="python_keyword">def </span><span class="python_name">create_data</span><span class="python_enclosure">()</span><span class="python_operator">:
</span><span class="python_keyword">return </span><span class="python_name">get_some_data</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">cache </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_cache</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_name">data </span><span class="python_operator">= </span><span class="python_name">cache</span><span class="python_operator">.</span><span class="python_name">get_value</span><span class="python_enclosure">(</span><span class="python_literal">'mydata'</span><span class="python_operator">, </span><span class="python_name">type</span><span class="python_operator">=</span><span class="python_literal">'memory'</span><span class="python_operator">, </span>
<span class="python_name">createfunc</span><span class="python_operator">=</span><span class="python_name">create_data</span><span class="python_operator">, </span><span class="python_name">expiretime</span><span class="python_operator">=</span><span class="python_number">60</span><span class="python_enclosure">)</span><span class="python_operator">
</span><span class="blocktag"></%init></span></pre></div>
Where "mydata" is a key that the data will be keyed upon, the type of cache is in memory only, the create_data() function is used to create the initial value of 'mydata' as well as regenerating it when it is expired, and the expire time is 60 seconds. </p>
<p>The creation function argument is optional, and the cache can be populated externally as well:
<div class="code">
<pre><span class="blocktag"><%init></span>
<span class="python_operator"> </span><span class="python_name">cache </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">get_cache</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_keyword">if not </span><span class="python_name">cache</span><span class="python_operator">.</span><span class="python_name">has_key</span><span class="python_enclosure">(</span><span class="python_literal">'mydata'</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_name">cache</span><span class="python_operator">.</span><span class="python_name">set_value</span><span class="python_enclosure">(</span><span class="python_literal">'mydata'</span><span class="python_operator">, </span><span class="python_name">get_some_data</span><span class="python_enclosure">()</span><span class="python_operator">, </span><span class="python_name">expiretime</span><span class="python_operator">=</span><span class="python_number">60</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_name">data </span><span class="python_operator">= </span><span class="python_name">cache</span><span class="python_operator">.</span><span class="python_name">get_value</span><span class="python_enclosure">(</span><span class="python_literal">'mydata'</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="blocktag"></%init></span></pre></div>
This is a more familiar way to check a dictionary for a value and set it. However, the previous "creation function" methodology has a significant advantage, in that it allows the cache mechanism to execute the function in the context of a global "busy" lock, which prevents other processes and threads from executing the same function at the same time, and instead forces them to retrieve the previous expired value until the new value is completed. If no previous value exists, they all wait for the single process/thread to create the new value. For a creation function that is slow or uses a lot of resources, this limits those resources to only one concurrent usage at a time, and once a cache value exists, only one request will experience any slowness upon recreation.
</p>
<p>To programmatically cache the output text of a component, use the <span class="codeline">m.cache_self()</span> method on request, which is a <b>reentrant</b> component-calling method:
<div class="code">
<pre><span class="blocktag"><%init></span>
<span class="python_operator"> </span><span class="python_keyword">if </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">cache_self</span><span class="python_enclosure">(</span><span class="python_name">key</span><span class="python_operator">=</span><span class="python_literal">"mykey"</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">return</span><span class="python_operator">
</span><span class="blocktag"></%init></span><span class="text">
</span><span class="doctag"># rest of component</span></pre></div>
For an uncached component, the cache_self method will execute the current component a second time. Upon the second execution, when the cache_self line is encountered the second time, it returns false and allows the component to complete its execution. The return value and output is cached, after being sent through any output filters present. Then returning up to the initial cache_self call, it returns true and delivers the components output and optionally its return value. Filtering is also disabled in the component as it should have already occurred within the original caching step. The process for an already cached component is that it simply returns true and delivers the component output.
</p>
<p>To get the component's return value via this method:
<div class="code">
<pre><span class="blocktag"><%init></span>
<span class="python_operator"> </span><span class="python_name">ret </span><span class="python_operator">= </span><span class="python_name">Value</span><span class="python_enclosure">()</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">cache_self</span><span class="python_enclosure">(</span><span class="python_name">key</span><span class="python_operator">=</span><span class="python_literal">"mykey"</span><span class="python_operator">, </span><span class="python_name">retval </span><span class="python_operator">= </span><span class="python_name">ret</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">return </span><span class="python_name">ret</span><span class="python_enclosure">()</span><span class="python_operator">
</span>
<span class="python_comment"># rest of component</span>
<span class="python_operator"></span><span class="python_keyword">return </span><span class="python_number">3 </span><span class="python_operator">+ </span><span class="python_number">5</span><span class="python_operator">
</span><span class="blocktag"></%init></span></pre></div>
A <b>value</b> object is used here to pass a return value via a method parameter. The return value is simply the cached return value of the component.
</p>
<p>
Generally, the %flags method of caching a component's output and return value is a lot easier than the programmatic interface. The main advantage of the programmatic interface is if the actual key is to be programmatically decided based on component arguments it can be figured out at runtime and sent as the "key" argument. This also applies if any of the other properties of the cache are to be determined at run-time rather than compile time.
</p>
</div>
<a href="#caching" class="toclink">back to section top</a>
</div>
<A name="caching_details"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">More on Caching</span>
<div class="sectiontext">
<p>The cached information may be shared within the scope of one process or across multiple processes. Synchronization mechanisms are used to insure that the regeneration is only called by one thread of one process at a time, returning the expired value to other processes and threads while the regeneration is occuring. This maximizes performance even for a very slow data-regeneration mechanism. In the case of a non-memory-based cache, an external process can also access the same cache. </p>
<p>Note that Myghty only includes thread-scoped synchronization for the Windows platform (contributors feel free to contribute a Win32 file locking scheme). The "file" and "dbm" cache methodologies therefore may not be entirely synchronized across multiple processes on Windows. This only occurs if multiple servers are running against the same cache since Windows doesnt have any forking capability and therefore an Apache server or similar is only using threads.
</p>
<p>Caching has an assortment of container methodolgies, such as <span class="codeline">MemoryContainer</span> and <span class="codeline">DBMContainer</span>, and provides a base Container class that can be subclassed to add new methodologies. A single component's cache can have containers of any number of different types and configurations.</p>
<p>
Caching of the URI resolution step can also be done to improve performance. See <a href="#parameters_use_static_source" >use_static_source</a> for more information on using the URICache.
</p>
</div>
<a href="#caching" class="toclink">back to section top</a>
</div>
<A name="caching_options"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Cache Options</span>
<div class="sectiontext">
<p>Caching options are all specified as Myghty configuration parameters in the form <span class="codeline">cache_XXXX</span>, to identify them as options being sent to the Cache object. When calling the m.get_cache() method, parameters may be specified with or without the <span class="codeline">cache_</span> prefix; they are stripped off. While some cache options apply to the Cache object itself, others apply to specific forms of the Container class, the two current classes being <span class="codeline">MemoryContainer</span> and <span class="codeline">DBMContainer</span>.</p>
<p>The full list of current options is as follows:</p>
<table cellspacing="0">
<tr class="light">
<td valign="top">
<A name="caching_options_cache_container_class"></a>
<b>cache_container_class</b> (class object)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Cache
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This is a class object which is expected to be a subclass of <span class="codeline">myghty.container.Container</span>, which will be used to provide containment services. This option need only be used in the case of a user-defined container class that is not built into the static list of options in the Cache class. To use one of the built in container classes, use <span class="codeline">cache_type</span> instead.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="caching_options_cache_data_dir"></a>
<b>cache_data_dir</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: same as Interpreter data_dir<br/>
used by: DBMContainer
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This is the data directory to be used by the DBMContainer (file-based cache) to store its DBM files as well as its lockfiles. It is set by default to be the same as the data_dir parameter for the Myghty application. As it creates its own subdirectories for its files (as does Interpreter), the files are kept separate from Myghty compiled pages.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="caching_options_cache_dbm_dir"></a>
<b>cache_dbm_dir</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: cache_data_dir + '/container_dbm'<br/>
used by: DBMContainer
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This value indicates the directory in which to create the dbm files used by DBMContainer; if not present, defaults to a subdirectory beneath <span class="codeline">cache_data_dir</span>.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="caching_options_cache_dbmmodule"></a>
<b>cache_dbmmodule</b> (module)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: anydbm<br/>
used by: DBMContainer
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>DBMContainer uses dbm files via the Python built-in <span class="codeline">anydbm</span> module, which searches for a platform specific dbm module to use. Any Python dbm module can be specified here in place of it. To specify this option under mod_python as an Apache configuration directive, use this format:</p>
<div class="code">
<pre><span class="text">PythonOption MyghtyCacheDbmmodule "__import__('gdbm')"</span></pre></div>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="caching_options_cache_debug_file"></a>
<b>cache_debug_file</b> (file object)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: Cache
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
If pointing to a Python file object, container operations performed by the caching system will be logged, allowing the viewing of how often data is being refreshed as well as how many concurrent threads and processes are hitting various containers.
When running with ApacheHandler or CGIHandler, this parameter can be set to the standard Apache log via the
parameter <span class="codeline">log_cache_operations</span>.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="caching_options_cache_lock_dir"></a>
<b>cache_lock_dir</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: cache_data_dir + '/container_dbm_lock'<br/>
used by: DBMContainer
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This value indicates the directory in which to create the lock files used by DBMContainer; if not present, defaults to a subdirectory beneath <span class="codeline">cache_data_dir</span>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="caching_options_cache_url"></a>
<b>cache_url</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: None<br/>
used by: MemcachedNamespaceManager
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The memcached URL to connect to for memcached usage, e.g. "localhost:11211".
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="caching_options_cache_type"></a>
<b>cache_type</b> (module)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: file or memory<br/>
used by: Cache
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>This is the type of container being used. Current options are <span class="codeline">file</span>, <span class="codeline">dbm</span>, <span class="codeline">memory</span>, and <span class="codeline">ext:memcached</span>.</p>
<p>This option defaults to <span class="codeline">dbm</span> if a <span class="codeline">data_dir</span> option is present in the current application, else uses <span class="codeline">memory</span>.</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="caching_options_log_cache_operations"></a>
<b>log_cache_operations</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
default: False<br/>
used by: ApacheHandler or CGIHandler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Sets the Cache <span class="codeline">cache_debug_file</span> argument to point to the Apache error log or standard error output. See <span class="codeline">cache_debug_file</span>.
</p>
</td>
</tr>
</table>
</div>
<a href="#caching" class="toclink">back to section top</a>
</div>
<A name="caching_types"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Cache Types</span>
<div class="sectiontext">
<ul>
<li>'dbm' - uses the <span class="codeline">anydbm</span> module combined with <span class="codeline">cPickle</span> to store data.</li>
<li>'file' - uses the <span class="codeline">cPickle</span> module combined with regular file access to store data. This method may be faster than 'dbm' if the entire contents of the file are retrieved often, whereas dbm is faster for pulling a single key out of a larger set of data.</li>
<li>'memory' - uses a regular Python dictionary. Speed is the fastest, but the cache is not useable across processes nor is it persistent across server restarts. It also has the highest utilization of RAM.</li>
<li>'ext:memcached' - uses <a href="http://www.danga.com/memcached/">memcached</a> for caching and requires the Python memcached module to be installed.</li>
</ul>
</div>
<a href="#caching" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="resolver"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#caching">Data Caching</a>
|
Next: <a href="#unicode">Unicode Support</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Advanced Resolver Configuration</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#resolver_intro">Introduction</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_step1">Basic Example</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_realthing">The Real Set of Rules</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_conditionals">Conditionals, Groups and ConditionalGroups</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_context">Resolver Contexts</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_logging">Resolution Logging</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#resolver_custom">Custom Rules</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#resolver_custom_installing">Installing the Rule</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
</div>
<A name="resolver_intro"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Introduction</span>
<div class="sectiontext">
<p>With version 0.97 comes a new and highly configurable URI resolution engine. This engine is responsible for converting the URI address of a component into a ComponentSource object, from which an actual Component is created. Originally, components were only retrieved from one or more file-based component roots, configured by <a href="#parameters_component_root" >component_root</a>. Special logic existed for locating <a href="#specialtempl_dhandler" >dhandler</a> and <a href="#specialtempl_autohandler" >autohandler</a> components as well, and the resolution of URIs could be cached (i.e. <a href="#parameters_use_static_source" >use_static_source</a>). Myghty added the ability to load module-based components based on regular expressions (<a href="#parameters_module_components" >module_components</a>), and also to translate incoming URIs via <a href="#parameters_path_translate" >path_translate</a>. </p>
<p>With the new resolution engine, it is now possible to:</p>
<ul>
<li>Change the order of all resolution steps, or remove unneeded resolution steps. The steps that can be controlled are component root lookup, module component lookup, path translation, dhandler resolution, autohandler resolution (also called 'upwards resolution'), and URI caching (static source).
<li>Create conditional resolution rules or rule chains. Built-in conditional rules allow matching the URI with a regular expression, or matching the "resolution context" of the incoming request. Built-in resolution contexts include request, subrequest, component, and inherit. User-defined resolution contexts can be created as well and specified in component lookup calls and also as the default context to be used in a subrequest.
<li>Control the point at which the caching of URIs occurs, by placing a special rule above only those rules whose results should be reused, or to enable caching of just a single rule.
<li>Inspect the full series of steps involved in a URI resolution via logging, regardless of whether or not it succeeded. This is crucial for developing custom rule-chains.
<li>Add special behavior to file-based resolution, so that the conversion from a URI to a filesystem path can be more than just a straight path concatenation of the component root and URI.
<li>Retrieve an re.Match object that is created when a URI matches the regular expression used by a module component. Capturing parenthesis can also be added to the regular expressions, whose results will also be available in the resulting Match object.
<li>Create custom resolution rules using small and simple classes that can easily coexist with the built-in rules.
</ul>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_step1"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Basic Example</span>
<div class="sectiontext">
Lets start with some component code that wants to locate another component:
<div class="code">
<pre><span class="python_name">comp </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">fetch_component</span><span class="python_enclosure">(</span><span class="python_literal">"/training/index.myt"</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p>
In the above line, the code is using the request to fetch the component referenced by the <b>uri</b> "/training/index.myt". The process of looking up a component corresponding to a uri is called <b>resolution.</b>
</p>
<p>When the resolver attempts to locate the uri, it executes a series of <b>resolver rules</b> specified within the configuration option <b>resolver_strategy</b>, which is represented as a list. This list contains instances of one or more <span class="codeline">myghty.resolver.ResolverRule</span> subclasses, each of which represents a single rule along with configurational arguments for that rule. A list of ResolverRule objects to be executed in order is also referred to as a <b>chain</b>. A resolver strategy for the above search might look like:
</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">(</span>
<span class="python_enclosure">{</span><span class="python_literal">'htdocs' </span><span class="python_operator">: </span><span class="python_literal">'/web/htdocs'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">)</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Above, the resolver strategy has only one rule, an instance of <span class="codeline">ResolveFile</span>. This rule searches through one or more component roots given as constructor arguments and concatenates the incoming URI to each root, until one of them matches an actual file located on the filesystem. When a match is found, the rule cancels any further rule processing, and returns a result object from which the component can be loaded. If no match is found, the rule passes control onto the next rule, or if no further rules exist, the resolver determines that the component cannot be located. Since in the above example we have only one rule, if the file <span class="codeline">/web/htdocs/training/index.myt</span> doesn't exist, the fetch_component call will raise a <span class="codeline">ComponentNotFound</span> exception.</p>
<p>If no arguments are given to the constructor, ResolveFile instead uses the value of <a href="#parameters_component_root" >component_root</a> as its list of roots. From this one can see that when a Myghty installation specifies the component_root configuration parameter, this rule is implicitly activated behind the scenes.
</p>
<p>The rule classes themselves require the symbols from the resolver package to be imported, as in <span class="codeline">from myghty.resolver import *</span>. These symbols are also available in mod_python configuration within PythonOption directives, as of version 0.97a or the current CVS version.
</p>
<p>A few more rules can be added above, which allow more options for how this uri can be resolved:</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ResolveModule</span><span class="python_enclosure">(</span>
<span class="python_enclosure">{</span><span class="python_literal">r'/user/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.UserManager'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">{</span><span class="python_literal">r'/admin/.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp.Administration'</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">PathTranslate</span><span class="python_enclosure">(</span>
<span class="python_enclosure">(</span><span class="python_literal">r'/training/' </span><span class="python_operator">, </span><span class="python_literal">r'/newmembers/'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_enclosure">(</span><span class="python_literal">r'/$'</span><span class="python_operator">, </span><span class="python_literal">'/index.myt'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">(</span>
<span class="python_enclosure">{</span><span class="python_literal">'htdocs' </span><span class="python_operator">: </span><span class="python_literal">'/web/htdocs'</span><span class="python_enclosure">}</span>
<span class="python_enclosure">)</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Two more rules have been added. <span class="codeline">ResolveModule</span> will be the first to attempt resolving the uri, and it will attempt to match the uri against a series of regular expressions that each refer to a module component. Module components are described in the section <a href="#modulecomponents" >Module Components</a>. As our uri does not match either regular expression, the ResolveModule rule will give up, and pass control onto the next rule in the chain. The ResolveModule rule, if instantiated with no arguments, will instead use the value of <a href="#parameters_module_components" >module_components</a> as its list. As with ResolveFile, when a Myghty installation specifies the module_components configuration parameter, this rule is also implicitly activated.
</p>
<p>Next is the <span class="codeline">PathTranslate</span> rule. This rule is a <b>uri processing</b> rule which itself will never return a result, but rather changes the incoming uri and then passes the modified uri onto the remaining rules in the chain. PathTranslate executes a series of regular expression search-and-replace operations on the uri before passing it on, which are specified as a list of two-element tuples. PathTranslate, when given no arguments, will use the value of <a href="#parameters_path_translate" >path_translate</a> as its list.</p>
<p>We have specified a path translation rule that all uris starting with "/training/" should be changed to reference the same file within "/newmembers/" instead. Secondly, we specify that any uri which is a directory request, i.e. uris that end with a slash, should have the default file "index.myt" appended to it. Our uri does match the first regular expression, so upon matching it will be converted into <span class="codeline">/newmembers/index.myt</span>. We then arrive back at our ResolveFile rule, where either the existing file <span class="codeline">/web/htdocs/newmembers/index.myt</span> will be used as the source of the resolved component, or if no such file exists a <span class="codeline">ComponentNotFound</span> exception will be raised.</p>
<p class="tipbox">Behind the scenes, the <span class="codeline">myghty.resolver.Resolver</span> object is invoked to resolve the incoming uri, and when located it returns an instance of <span class="codeline">myghty.resolver.Resolution</span>, which in turn contains an instance of <span class="codeline">myghty.csource.ComponentSource</span>. Whereas the Resolution instance describes just one of potentially many resolution paths the same component, the ComponentSource instance is the only object that describes location information for the component exactly.</p>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_realthing"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">The Real Set of Rules</span>
<div class="sectiontext">
<p>The previous section illustrated the three basic ResolverRules that are behind the configuration parameters component_root, module_components, and path_translate. In fact, these three rules also have an ordering that is used by default, and there are also several more rules installed by default which accomplish some other important tasks. The default strategy is:</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">PathTranslate</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveDhandler</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">URICache</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveUpwards</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveModule</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolvePathModule</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">()</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Our familiar rules PathTranslate, ResolveModule and ResolveFile are all present, and as they are specified with no constructor arguments they will use the values of their correspoinding configuration parameters. Also one can see that path translation happens at the very front of everything before other resolution starts. ResolvePathModule is also a new rule which corresponds to the configuration parameter <a href="#modulecomponents_resolution_module_root" >module_root</a>.</p>
<p>Three new rules are introduced in this chain, <span class="codeline">ResolveDhandler</span>, <span class="codeline">URICache</span>, and <span class="codeline">ResolveUpwards</span>. All have two things in common which are different from the first three rules: they all are <b>conditional rules</b> that do not necessarily get activated, and also they are <b>rollup rules</b> which cannot resolve a component on their own, but rather rely upon the full list of rules that occur directly <b>below</b> them in order to retrieve results. </p>
<p>The <b>ResolveDhandler</b> rule is activated when the request looks for a top level component, with the option to serve a not-found component or directory request as a dhandler. After not matching any resolution rules or file lookups for the given URI, it looks instead for /path/dhandler, and searches "upwards" through successive parent paths to resolve a dhandler. The rules below are executed repeatedly with each new URI until a match is made, or no more path tokens exist. Additionally, any resolved dhandlers that have been declined by the current request are also bypassed.
</p>
<p>The <b>ResolveUpwards</b> rule is similar to the dhandler rule, except it is activated when a component searches for its inherited autohandler. This rule also searches upwards through successive parent paths to locate the module or file. In fact this rule can be used for any kind of upwards search but normally is used for autohandler only.
</p>
<p>The <b>URICache</b> rule caches the results of all rules below it, keyed against the incoming URI. If the component is located, the resulting ComponentSource object is cached. If it is not located, the resulting ComponentNotFound condition is cached. Whether or not this rule is enabled is based on the value of <a href="#parameters_use_static_source" >use_static_source</a>. URI caching has the effect of disabling repeated resolution/filesystem lookups for components that have already been located, as well as components that were not found when searched. URICache also takes an optional constructor parameter source_cache_size, which indicates that this URICache should use its own cache of the given size, separately from the per-interpreter source cache. Through custom configuration of URICache rules, parts of a site can be configured as static source and other parts can be configured as being more dynamically alterable.
</p>
<p>Since URICache caches data based only on the URI, it will complain if you try to put a dhandler rule below it. This is because the dhandler rule does not necessarily return the same result for the same URI each time, as its upwards logic is conditionally enabled. In theory, ResolveUpwards should have this effect as well, but since normal usage will use ResolveUpwards for all autohandlers and nothing else, it by default will not complain about a ResolveUpwards rule. If you construct ResolveUpwards using <span class="codeline">ResolveUpwards(enable_caching = False)</span>, then the URICache rule will complain about it.
</p>
<p>
URICache also has an additional parameter which allows it to cache the results of just a single rule, instead of all rules below it:
</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">URICache</span><span class="python_enclosure">(</span><span class="python_name">rule </span><span class="python_operator">= </span><span class="python_name">ResolveModule</span><span class="python_enclosure">())</span><span class="python_operator">,</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">()</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Above, only the results of ResolveModule will be cached. ResolveFile will be executed every time it is called.</p>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_conditionals"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Conditionals, Groups and ConditionalGroups</span>
<div class="sectiontext">
<p>Here is an example of conditional and group-based rules:
</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ConditionalGroup</span><span class="python_enclosure">(</span><span class="python_name">context </span><span class="python_operator">= </span><span class="python_literal">'subrequest'</span><span class="python_operator">, </span><span class="python_name">rules </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ResolveDhandler</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveUpwards</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">()</span><span class="python_operator">, </span>
<span class="python_name">NotFound</span><span class="python_enclosure">()</span>
<span class="python_enclosure">])</span><span class="python_operator">,</span>
<span class="python_name">Conditional</span><span class="python_enclosure">(</span><span class="python_name">regexp </span><span class="python_operator">= </span><span class="python_literal">'/login/.*'</span><span class="python_operator">, </span><span class="python_name">rule </span><span class="python_operator">= </span><span class="python_name">ResolveModule</span><span class="python_enclosure">({</span><span class="python_literal">'.*' </span><span class="python_operator">: </span><span class="python_literal">'myapp:LoginHandler'</span><span class="python_enclosure">}))</span><span class="python_operator">,</span>
<span class="python_name">AdjustedResolveFile</span><span class="python_enclosure">(</span>
<span class="python_name">adjust </span><span class="python_operator">= </span><span class="python_enclosure">[(</span><span class="python_literal">'/docs/'</span><span class="python_operator">, </span><span class="python_literal">'/'</span><span class="python_enclosure">)]</span><span class="python_operator">, </span>
<span class="python_enclosure">(</span><span class="python_literal">'main' </span><span class="python_operator">: </span><span class="python_literal">'/web/htdocs'</span><span class="python_enclosure">)</span><span class="python_operator">, </span>
<span class="python_enclosure">(</span><span class="python_literal">'comp' </span><span class="python_operator">: </span><span class="python_literal">'/web/comp'</span><span class="python_enclosure">) </span>
<span class="python_enclosure">)</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>
The above example routes all subrequests into a <b>rule subchain</b>, which resolves files only, including optional dhandler and autohandler resolution. The subchain is <b>terminated</b> by the rule NotFound, which always results in a ComponentNotFound error. If NotFound is not included, the resolution would fall through back into the main rule chain. Continuing on, all non-subrequest component requests will first check for the URI '/login/' which matches to a specific module component, and then onto the bottom where it does a special file resolution rule.</p>
<p>That last rule above is AdjustedResolveFile(), which is a subclass of ResolveFile() that performs path translation on the incoming URI before concatenating it to each of its file paths. In contrast to using PathTranslate(), the result of this translation is not propigated forward onto new requests nor is it used in the resulting component source; it is only used in the actual path concatenation.
</p>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_context"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Resolver Contexts</span>
<div class="sectiontext">
<p>The Resolver is used for all resolution of URIs into components, which is not just the URI used by a client browser, but also URIs used for all components called by a template, the inheriting component of a template, and subrequests. Custom resolver strategies allow different rules to execute based on this context, using the Conditional and ConditionalGroup rules.
</p>
<p>A common use for a conditional rule based on resolver context is to have module components be invoked only for request-based URIs, and all internal subreqests, component calls, and templates use file-based components:
</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ConditionalGroup</span><span class="python_enclosure">(</span><span class="python_name">context </span><span class="python_operator">= </span><span class="python_literal">'request'</span><span class="python_operator">, </span><span class="python_name">rules </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">ResolveModule</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_comment"># optional - dont allow requests to "fall through"</span>
<span class="python_comment"># into file-based resolution</span>
<span class="python_name">NotFound</span><span class="python_enclosure">()</span>
<span class="python_enclosure">])</span><span class="python_operator">,</span>
<span class="python_name">ResolveDhandler</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">URICache</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveUpwards</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveFile</span><span class="python_enclosure">()</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>Above, all requests from the outside world must be resolved by module components, as the conditional is terminated by a NotFound() rule. If the NotFound() rule is omitted, incoming uris that do not match a module component path will "fall through" into the file-based rules.</p>
<p>The resolver context is also customizable programmatically. The request methods <a href="#request_methods_create_subrequest" >create_subrequest</a> and <a href="#request_methods_fetch_component" >fetch_component</a> take the optional parameter <span class="codeline">resolver_context</span> which can be any user-defined string, or one of the standard names <span class="codeline">request, subrequest, component</span> or <span class="codeline">inherit</span>. Any Conditional or ConditionalGroup rule which specifies the name as the value of <span class="codeline">context</span> will be activated by this name.
</p>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_logging"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Resolution Logging</span>
<div class="sectiontext">
Details about a component resolution are attached to ComponentNotFound exceptions, when a page or component is not found. Additionally, if you add the configuration parameter <span class="codeline">debug_elements = ['resolution']</span> to your Interpreter config, the resolution of all components will be logged. This log details each step within a resolution with an identifying keyword, such as "resolvemodule:", "resolvefile:", or "dhandler". See <a href="#parameters_debug_elements" >debug_elements</a> for information on debug_elements.
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
<A name="resolver_custom"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Custom Rules</span>
<div class="sectiontext">
<p>The basic idea of a custom rule is to subclass the <span class="codeline">ResolverRule</span> class, overriding at least the <span class="codeline">do</span> method, which is tasked with returning a <span class="codeline">Resolution</span> object, which in turn contains a <span class="codeline">ComponentSource</span> object.
</p>
<p><b>Example 1 - File-based Custom Rule</b></p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">csource </span><span class="python_keyword">import </span><span class="python_operator">*
</span><span class="python_keyword">import </span><span class="python_name">os</span><span class="python_operator">
</span>
<span class="python_keyword">class </span><span class="python_name">MyFileResolver</span><span class="python_enclosure">(</span><span class="python_name">ResolverRule</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""a user-defined resolver rule that looks up file-based components"""</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">file_root</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""builds a new MyFileResolver."""</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">file_root </span><span class="python_operator">= </span><span class="python_name">file_root</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">do_init_resolver</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">resolver</span><span class="python_operator">, </span><span class="python_name">remaining_rules</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""called when the MyFileResolver is established in the rule chain.
'resolver' is the instance of Resolver being used to run the rules.
'remaining_rules' is a list of all ResolverRules that occur below this rule.
**kwargs receives the full dictionary of Myghty configuration parameters."""</span><span class="python_operator">
</span><span class="python_keyword">pass</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">do</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">uri</span><span class="python_operator">, </span><span class="python_name">remaining</span><span class="python_operator">, </span><span class="python_name">resolution_detail</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""attempts to resolve the given uri into a Resolution object.
'resolution_detail' is a list of log messages that will be appended to the debug log when
resolution is being logged, or to ComponentNotFound exceptions.
**kwargs contains extra resolution arguments, such as "resolver_context" and "enable_dhandler". """</span><span class="python_operator">
</span>
<span class="python_keyword">if </span><span class="python_name">resolution_detail </span><span class="python_keyword">is not </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">resolution_detail</span><span class="python_operator">.</span><span class="python_name">append</span><span class="python_enclosure">(</span><span class="python_literal">"MyFileResolver:" </span><span class="python_operator">+ </span><span class="python_name">uri</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># a simple resolution.</span>
<span class="python_operator"></span><span class="python_name">file </span><span class="python_operator">= </span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">file_root </span><span class="python_operator">+ </span><span class="python_name">uri</span><span class="python_operator">
</span><span class="python_keyword">if </span><span class="python_name">os</span><span class="python_operator">.</span><span class="python_name">access</span><span class="python_enclosure">(</span><span class="python_name">file</span><span class="python_operator">, </span><span class="python_name">os</span><span class="python_operator">.</span><span class="python_name">F_OK</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># file exists, so return a Resolution/FileComponentSource</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">Resolution</span><span class="python_enclosure">(</span>
<span class="python_name">FileComponentSource</span><span class="python_enclosure">(</span>
<span class="python_name">file_path </span><span class="python_operator">= </span><span class="python_name">file</span><span class="python_operator">,</span>
<span class="python_comment"># file modification time - this is not required as of 0.99b</span>
<span class="python_name">last_modified </span><span class="python_operator">= </span><span class="python_name">os</span><span class="python_operator">.</span><span class="python_name">stat</span><span class="python_enclosure">(</span><span class="python_name">srcfile</span><span class="python_enclosure">)[</span><span class="python_name">stat</span><span class="python_operator">.</span><span class="python_name">ST_MTIME</span><span class="python_enclosure">]</span><span class="python_operator">,</span>
<span class="python_name">path </span><span class="python_operator">= </span><span class="python_name">uri</span><span class="python_operator">,</span>
<span class="python_comment"># key to identify the 'compilation root' for the component</span>
<span class="python_name">path_id </span><span class="python_operator">= </span><span class="python_literal">'myfileresolve'</span><span class="python_operator">,</span>
<span class="python_comment"># unique key to identify the component</span>
<span class="python_name">id </span><span class="python_operator">= </span><span class="python_literal">"%s|%s" </span><span class="python_operator">% </span><span class="python_enclosure">(</span><span class="python_name">key</span><span class="python_operator">, </span><span class="python_name">path</span><span class="python_enclosure">)</span><span class="python_operator">, </span>
<span class="python_enclosure">)</span><span class="python_operator">, </span>
<span class="python_name">resolution_detail</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_comment"># file doesnt exist, so call the next resolver in the chain</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">remaining</span><span class="python_operator">.</span><span class="python_name">next</span><span class="python_enclosure">()</span><span class="python_operator">.</span><span class="python_name">do</span><span class="python_enclosure">(</span><span class="python_name">uri</span><span class="python_operator">, </span><span class="python_name">remaining</span><span class="python_operator">, </span><span class="python_name">resolution_detail</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
<p><b>Example 2 - Module Component Custom Rule</b></p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">csource </span><span class="python_keyword">import </span><span class="python_operator">*
</span><span class="python_keyword">import </span><span class="python_name">sys</span><span class="python_operator">, </span><span class="python_name">re</span><span class="python_operator">
</span>
<span class="python_keyword">class </span><span class="python_name">MyModuleResolver</span><span class="python_enclosure">(</span><span class="python_name">ResolverRule</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""a user-defined resolver rule that looks up module-based components"""</span><span class="python_operator">
</span><span class="python_keyword">def </span><span class="python_name">__init__</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">path</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""constructs a new MyModuleResover with the given module path."""</span><span class="python_operator">
</span><span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">path </span><span class="python_operator">= </span><span class="python_name">path</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">do_init_resolver</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">resolver</span><span class="python_operator">, </span><span class="python_name">remaining_rules</span><span class="python_operator">, **</span><span class="python_name">kwargs</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""initializes the MyModuleResolver."""</span><span class="python_operator">
</span><span class="python_keyword">pass</span><span class="python_operator">
</span>
<span class="python_operator"></span><span class="python_keyword">def </span><span class="python_name">do</span><span class="python_enclosure">(</span><span class="python_name">self</span><span class="python_operator">, </span><span class="python_name">uri</span><span class="python_operator">, </span><span class="python_name">remaining</span><span class="python_operator">, </span><span class="python_name">resolution_detail</span><span class="python_operator">, </span><span class="python_name">context </span><span class="python_operator">= </span><span class="python_name">None</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_literal">"""resolves the given URI to a specific callable."""</span><span class="python_operator">
</span>
<span class="python_keyword">if </span><span class="python_name">resolution_detail </span><span class="python_keyword">is not </span><span class="python_name">None</span><span class="python_operator">:
</span><span class="python_name">resolution_detail</span><span class="python_operator">.</span><span class="python_name">append</span><span class="python_enclosure">(</span><span class="python_literal">"MyModuleResolver: " </span><span class="python_operator">+ </span><span class="python_name">uri</span><span class="python_enclosure">)</span><span class="python_operator">
</span>
<span class="python_comment"># here we illustrate a variety of constructor arguments</span>
<span class="python_comment"># for Resolution and ModuleComponentSource.</span>
<span class="python_operator"></span><span class="python_keyword">if </span><span class="python_name">uri eq </span><span class="python_literal">'/shopping/'</span><span class="python_operator">:
</span><span class="python_comment"># return a ModuleComponentSource with a callable inside of it</span>
<span class="python_comment"># the "cache_arg" flag, new in version 0.99b, indicates that the </span>
<span class="python_comment"># given argument is not changing its type (i.e. function, object, class) and can be </span>
<span class="python_comment"># cached with regards to inspecting its type, parent module, etc.</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">Resolution</span><span class="python_enclosure">(</span>
<span class="python_name">ModuleComponentSource</span><span class="python_enclosure">(</span><span class="python_name">shopping</span><span class="python_operator">, </span><span class="python_name">cache_arg</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">resolution_detail</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">elif </span><span class="python_name">uri eq </span><span class="python_literal">'/checkout/'</span><span class="python_operator">:
</span><span class="python_comment"># or with the standard "package.module:callable" string</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">Resolution</span><span class="python_enclosure">(</span>
<span class="python_name">ModuleComponentSource</span><span class="python_enclosure">(</span><span class="python_literal">"mypackage.mymodule:checkout"</span><span class="python_operator">, </span><span class="python_name">cache_arg</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">resolution_detail</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">elif </span><span class="python_name">uri eq </span><span class="python_literal">'/inspector/'</span><span class="python_operator">:
</span><span class="python_comment"># the Resolution object will also attach any additional **kwargs as attributes</span>
<span class="python_comment"># which other components can then retreive via m.resolution</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">Resolution</span><span class="python_enclosure">(</span>
<span class="python_name">ModuleComponentSource</span><span class="python_enclosure">(</span><span class="python_name">inspector</span><span class="python_operator">, </span><span class="python_name">cache_arg</span><span class="python_operator">=</span><span class="python_name">True</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">resolution_detail</span>
<span class="python_name">param1 </span><span class="python_operator">= </span><span class="python_literal">'inspect'</span><span class="python_operator">,</span>
<span class="python_name">param2 </span><span class="python_operator">= </span><span class="python_number">3</span>
<span class="python_enclosure">)</span><span class="python_operator">
</span><span class="python_keyword">else</span><span class="python_operator">:
</span><span class="python_comment"># no component matches, return next resolver in the chain</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">remaining</span><span class="python_operator">.</span><span class="python_name">next</span><span class="python_enclosure">()</span><span class="python_operator">.</span><span class="python_name">do</span><span class="python_enclosure">(</span><span class="python_name">uri</span><span class="python_operator">, </span><span class="python_name">remaining</span><span class="python_operator">, </span><span class="python_name">resolution_detail</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator"></span></pre></div>
</div>
<A name="resolver_custom_installing"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Installing the Rule</span>
<div class="sectiontext">
<p>The new rule is then installed by specifying it within resolver_strategy, as in this example which first resolves via MyModuleResolver, and then resolves file components via MyFileResolver, plugged into the standard URICache/dhandler/autohandler chain:</p>
<div class="code">
<pre><span class="python_keyword">from </span><span class="python_name">myghty</span><span class="python_operator">.</span><span class="python_name">resolver </span><span class="python_keyword">import </span><span class="python_operator">*
</span>
<span class="python_name">resolver_strategy </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_name">MyModuleResolver</span><span class="python_enclosure">(</span><span class="python_literal">'/usr/local/mymodules'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_name">ResolveDHandler</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">URICache</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">ResolveUpwards</span><span class="python_enclosure">()</span><span class="python_operator">,</span>
<span class="python_name">MyFileResolver</span><span class="python_enclosure">(</span><span class="python_literal">'/web/htdocs'</span><span class="python_enclosure">)</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
</div>
<a href="#resolver" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="unicode"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#resolver">Advanced Resolver Configuration</a>
|
Next: <a href="#parameters">Index of Configuration Parameters</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Unicode Support</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#unicode_unicode_writes">What You Can Give to m.write() (and m.apply_escapes())</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#unicode_magic_comment">The Magic Encoding Comment</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#unicode_output_encoding">Controlling the Output Encoding</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#unicode_details">Other Details</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#unicode_disabling">Disabling Unicode Support</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Since version 1.1, Myghty provides support for writing unicode strings, and for including non-ASCII characters within component source files.</p>
</div>
<A name="unicode_unicode_writes"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">What You Can Give to m.write() (and m.apply_escapes())</span>
<div class="sectiontext">
<p>
When unicode support is enabled, you may pass either
<span class="codeline">unicode</span> or plain
<span class="codeline">str</span>s to
<a href="#request_methods_write" >m.write()</a>.
<span class="codeline">Str</span>s will be interpreted according
the Python's system default encoding (as returned by
<span class="codeline">sys.getdefaultencoding()</span>.
You may also write any other object, in which case the object
will be coerced to unicode by calling
<span class="codeline">unicode()</span> before it is output.
There is one exception to this rule: writing a
<span class="codeline">None</span> generates no output.
</p>
</div>
<a href="#unicode" class="toclink">back to section top</a>
</div>
<A name="unicode_magic_comment"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">The Magic Encoding Comment</span>
<div class="sectiontext">
<p>
If a myghty component source file contains contains characters other than those in the python system default encoding (as reported by <span class="codeline">sys.getdefaultencoding()</span> --- usually ASCII), you may so indicate this by placing a magic encoding comment at the top of the file.
The exact syntax of the magic comment is essentially the same as that <a href="http://docs.python.org/ref/encodings.html">used by python</a>, with the added restriction that the '#' which introduces the magic comment must start at the beginning of a line (without leading whitespace.)
</p>
<p>
The magic encoding comment has affects the interpretation of
any plain text in the component source file, and the contents
of any python unicode string literals.
It does not have any effect on the interpretation of bytes within
python plain str literals.
In particular, the following is likely to generate a UnicodeDecodeError:
</p>
<div class="code">
<pre><span class="doctag"># encoding: latin1
</span><span class="text">
</span><span class="doctag"># This is fine:
</span><span class="text">Français
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">u"Français"</span><span class="python_enclosure">) </span><span class="python_comment"># This is fine, too</span><span class="python_operator"></span>
<span class="text">
</span><span class="controlline">%</span><span class="python_operator"> </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">write</span><span class="python_enclosure">(</span><span class="python_literal">"Français"</span><span class="python_enclosure">) </span><span class="python_comment"># BAD! => UnicodeDecodeError</span><span class="python_operator"></span></pre></div>
</div>
<a href="#unicode" class="toclink">back to section top</a>
</div>
<A name="unicode_output_encoding"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Controlling the Output Encoding</span>
<div class="sectiontext">
<p>
The output encoding, and output encoding error handling strategy can be specified using the <a href="#parameters_output_encoding" >output_encoding</a> and <a href="#parameters_encoding_errors" >encoding_errors</a> configuration parameters. It can also be changed for a specific request (or portion thereof) by calling the <a href="#request_methods_set_output_encoding" >set_output_encoding</a> method.
</p>
<p>Choices for the value of <a href="#parameters_encoding_errors" >encoding_errors</a> include:</p>
<dl>
<dt><span class="codeline">strict</span></dt>
<dd>Raise an exception in case of an encoding error.</dd>
<dt><span class="codeline">replace</span></dt>
<dd>Replace malformed data with a suitable replacement marker,
such as <span class="codeline">"?"</span>.</dd>
<dt><span class="codeline">xmlcharrefreplace</span></dt>
<dd>Replace with the appropriate XML character reference.</dd>
<dt><span class="codeline">htmlentityreplace</span></dt>
<dd>Replace with the appropriate HTML character entity reference,
if there is one; otherwise replace with a numeric character reference.
(This is not a standard python encoding error handler. It is
provided by the <span class="codeline">mighty.escapes</span> module.)
</dd>
<dt><span class="codeline">backslashreplace</span></dt>
<dd>Replace with backslashed escape sequence.</dd>
<dt><span class="codeline">ignore</span></dt>
<dd>Ignore malformed data and continue without further notice.</dd>
</dl>
<p>See the Python <a href="http://docs.python.org/lib/module-codecs.html">codecs</a> documentation for more information on how encoding error handlers work, and on how you can define your own. </p>
<p>Generally, for components generating HTML output, it sufficient to set <a href="#parameters_output_encoding" >output_encoding</a> to <span class="codeline">'latin1'</span> (or even 'ascii'), and <a href="#parameters_encoding_errors" >encoding_errors</a> to <span class="codeline">'htmlentityreplace'</span>. (Latin1 is the default encoding for HTML, as specified in <a href="http://www.faqs.org/rfcs/rfc2616.html">RFC 2616</a>.)
The <span class="codeline">'htmlentityreplace'</span> error handler replaces any characters which can't be encoded by an HTML named character reference (or a numeric character reference, if that is not possible) so this setting can correctly handle the output of any unicode character to HTML.
</p>
</div>
<a href="#unicode" class="toclink">back to section top</a>
</div>
<A name="unicode_details"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Other Details</span>
<div class="sectiontext">
<p>With unicode support enable the return value from
<a href="#request_methods_scomp" >m.scomp()</a> will be either a
<span class="codeline">unicode</span> or a
<span class="codeline">str</span> in the system default encoding.
</p>
<p>Similarly, the input passed to any
<a href="#filtering_filtering" >component output filters</a>
will also be either a
<span class="codeline">unicode</span> or a
<span class="codeline">str</span>.
The filter may return any object which is coercable to
a <span class="codeline">unicode</span>.
</p>
<p>Output passed to the
<span class="codeline">.write()</span> method of component capture buffers
(specified using the
<span class="codeline">store</span> argument of
<a href="#request_methods_execute_component" >execute_component</a>)
will be either a <span class="codeline">unicode</span> or a
plain <span class="codeline">str</span>.
(Using a
<span class="codeline">StringIO.StringIO</span> buffer should
just work.
Using a
<span class="codeline">cStringIO.StringIO</span> buffer will
probably not work, as they don't accept unicode input.)
</p>
<p>Output passed to the
<span class="codeline">.write()</span> method of subrequest capture buffers
(specified using the
<span class="codeline">out_buffer</span> argument of
<a href="#request_methods_create_subrequest" >create_subrequest</a>)
will be encoded <span class="codeline">str</span>s.
The encoding and error strategy, by default,
will be the system default encoding and
<span class="codeline">'strict'</span>
respectively, irrespective of the
<a href="#request_members_output_encoding" >output_encoding</a>
of the parent request.
These can be changed using the
<span class="codeline">output_encoding</span> and
<span class="codeline">encoding_errors</span> arguments of
<a href="#request_methods_create_subrequest" >create_subrequest</a>
(or by calling
<a href="#request_methods_set_output_encoding" >set_output_encoding</a>
on the subrequest.)
</p>
</div>
<a href="#unicode" class="toclink">back to section top</a>
</div>
<A name="unicode_disabling"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Disabling Unicode Support</span>
<div class="sectiontext">
<p>
Myghty's unicode support may be disabled by setting the <a href="#parameters_disable_unicode" >disable_unicode</a> configuration parameter.
</p>
</div>
<a href="#unicode" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="parameters"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#unicode">Unicode Support</a>
|
Next: <a href="#technical">Myghty Guts (tech description)</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Index of Configuration Parameters</div>
<div class="topnavitems">
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>Configuration parameters in Myghty are basically a big dictionary of data that is initially passed to the constructor for <span class="codeline">myghty.interp.Interpreter</span>, which represents the entry point for running a Myghty template. Upon construction, the Interpreter instantiates all the other objects
it needs, such as the Compiler, the Resolver, and a prototype Request object (a prototype is an object that is used as a template to make copies of itself), passing in the same hash of configuration parameters. Each object takes what it needs out of the dictionary.</p>
<p>If you are writing your own interface to <span class="codeline">Interpreter</span>, such as a standalone or simple CGI client, you can pass one or more of these values programmatically to the constructor of the Interpreter. If running from mod python, values can be specified in the http.conf file using the format <span class="codeline">Myghty<<i>Name</i>></span>, where <i>Name</I> is the parameter name in InitialCaps format (i.e., data_dir becomes DataDir).
</p>
<p>Note also that there are configuration parameters specific to the caching mechanism, listed in <a href="#caching_options" >Cache Options</a>, as well as session specific parameters listed in <a href="#session_options" >Session Options</a>.</p>
<table cellspacing="0">
<tr class="dark">
<td valign="top">
<A name="parameters_allow_globals"></a>
<b>allow_globals</b> (list of strings)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of global variable names that will be compiled into Myghty templates, and will be expected to be provided upon template execution. The variable "r", representing the Apache Request, is delivered to templates via this parameter. To add your own variables, specify their names in this list, and also specify it as a key in the RequestImpl argument global_args to provide the values.
See the section <a href="#globals_globalcustom" >Make your Own Friends</a> for details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_attributes"></a>
<b>attributes</b> (dictionary)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A dictionary of data that will be stored by the Interpreter used throughout a particular Myghty application. This is a way
to set per-application global variables. The values are accessible via the <span class="codeline">interpreter.attributes</span>
dictionary. </p>
<div class="code">
<pre><span class="python_name">i </span><span class="python_operator">= </span><span class="python_name">interp</span><span class="python_operator">.</span><span class="python_name">Interpreter</span><span class="python_enclosure">(</span><span class="python_name">attributes </span><span class="python_operator">= </span><span class="python_enclosure">{</span><span class="python_literal">'param'</span><span class="python_operator">: </span><span class="python_literal">'value'</span><span class="python_enclosure">})</span><span class="python_operator"></span></pre></div>
Accessing attributes:
<div class="code">
<pre><span class="python_comment"># call interpreter off request,</span>
<span class="python_comment"># and get an attribute</span>
<span class="python_name">p </span><span class="python_operator">= </span><span class="python_name">m</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'param'</span><span class="python_enclosure">]</span><span class="python_operator">
</span>
<span class="python_comment"># call interpreter off component,</span>
<span class="python_comment"># and set an attribute</span>
<span class="python_name">self</span><span class="python_operator">.</span><span class="python_name">interpreter</span><span class="python_operator">.</span><span class="python_name">attributes</span><span class="python_enclosure">[</span><span class="python_literal">'param'</span><span class="python_enclosure">] </span><span class="python_operator">= </span><span class="python_literal">'value'</span><span class="python_operator"></span></pre></div>
<p>Interpreter attributes can be compared to component <a href="#components_members_attributes" >attributes</a>, as well
as request <a href="#request_members_attributes" >attributes</a>.
</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_auto_flush"></a>
<b>auto_flush</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: False<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Whether or not <span class="codeline">m.write</span> calls will be automatically flushed to the final output stream as they are called, or will be buffered until the end of the request. Autoflush being on makes things a little more tricky, as you can't do any kind of page redirects (neither external nor internal) once the content starts coming out. Error messages become messy as well since they are similar to an internal redirect.</p>
<p>Autoflush can be set in a variety of ways and is described fully in the section <a href="#filtering_autoflush" >The Autoflush Option</a>.
</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_auto_handler_name"></a>
<b>auto_handler_name</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: autohandler<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The name of the file used as a global page wrapper, defaults to 'autohandler'. See the section <a href="#specialtempl_autohandler" >autohandlers</a> for information on autohandlers.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_cache_debug_file"></a>
<b>cache_debug_file</b> (file object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: None<br/>
used by: Cache
<br/>since version: 0.94
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
If pointing to a Python file object, container operations performed by the caching system will be logged, allowing the viewing of how often data is being refreshed as well as how many concurrent threads and processes are hitting various containers.
When running with ApacheHandler or CGIHandler, this parameter can be set to the standard Apache log via the
parameter <span class="codeline">log_cache_operations</span>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_code_cache_size"></a>
<b>code_cache_size</b> (integer)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: 16777216<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Size of the cache used by Interpreter to cache loaded component objects, measured in bytes. The cache works on a "least recently used" scheme. This value has a great impact on performance, as too large a value can use up lots of memory for a very large site, and too small results in excessive "swapping" of components in and out of memory. Cache operations can be logged via <a href="#parameters_debug_file" >debug_file</a>.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_compiler"></a>
<b>compiler</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.compiler.Compiler<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.compiler.Compiler</span> used to generate object files. Not much reason to play with this unless you are seriously hacking your own engine. The default Compiler object will receive its optional parameters from the argument list sent to the constructor for <span class="codeline">Interpreter</span>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_component_root"></a>
<b>component_root</b> (string or list)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: Resolver
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>This parameter is almost always required; it is the filesystem location, or list of locations, with which to locate Myghty component files. </p>
<p>The two formats of component_root are as follows:</p>
<p>Single string</p>
<div class="code">
<pre><span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_literal">"/web/sites/mysite/htdocs"</span><span class="python_operator"></span></pre></div>
<p>List of hashes</p>
<div class="code">
<pre><span class="python_name">component_root </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_enclosure">{</span><span class="python_literal">'main'</span><span class="python_operator">:</span><span class="python_literal">"/web/sites/mysite/htdocs"</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">{</span><span class="python_literal">'components'</span><span class="python_operator">:</span><span class="python_literal">"/web/sites/mysite/components"</span><span class="python_enclosure">}</span><span class="python_operator">,</span>
<span class="python_enclosure">{</span><span class="python_literal">'alt'</span><span class="python_operator">:</span><span class="python_literal">"/usr/local/lib/special-comp"</span><span class="python_enclosure">}</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>The single string specifies one root for all component calls, which will be assigned the identifying key "main". The list of hashes specifies the keys and paths for a collection of locations which will be searched in order for a component. This allows you to have one file tree that is web-server accessible files, and another file tree that contains files which can only be used as embedded components, and can't be accessed by themselves. The key names are used to uniquely identify a component by both its location and its name, such as "main:/docs/index.myt".</p>
<p>For examples of component_root configuration, see the section <a href="#configuration" >Configuration</a>. For advanced options on file-based resolution, see <a href="#resolver" >Advanced Resolver Configuration</a>.
</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_data_dir"></a>
<b>data_dir</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Directory to be used to store compiled object files (.py files and .pyc files), lock files used for synchronization, as well as container files which store data for the component caching system and the session object. A non-None value implies True for the "use_object_files" setting. Compiled object files are stored in the <span class="codeline">obj</span> directory, and cache/session files are stored underneath <span class="codeline">container_XXX</span> directories.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_debug_elements"></a>
<b>debug_elements</b> (list)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: []<br/>
used by: Interpreter
<br/>since version: 0.97alpha3
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>A list of string names that refer to various elements that can send debug information to the Interpreter's debug output. An example with all allowed names:</p>
<div class="code">
<pre><span class="python_name">debug_elements </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># all resolution of components</span>
<span class="python_literal">'resolution'</span><span class="python_operator">, </span>
<span class="python_comment"># inspection of component objects and modules loaded into memory and later garbage-collected</span>
<span class="python_literal">'codecache'</span><span class="python_operator">, </span>
<span class="python_comment"># inspection of the generation and compilation of components</span>
<span class="python_literal">'classloading'</span><span class="python_operator">,</span>
<span class="python_comment"># cache operations, reloading of cached data</span>
<span class="python_literal">'cache'</span><span class="python_operator">, </span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_debug_file"></a>
<b>debug_file</b> (file object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: stderr<br/>
used by: Interpreter
<br/>since version: 0.93b
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>References a Python file object; if non-None, the Interpreter will send debugging information to this file. Note that line breaks are not sent by default; use code such as <span class="codeline">myghty.buffer.LinePrinter(sys.stderr)</span> to wrap the file in a line-based formatter.
</p>
<p>When running the Interpreter in an HTTP context, various implementations of HTTPHandler supply their own stream for debugging information, such as the ApacheHandler which supplies the Apache error log as a filehandle.</p>
<p>As of version 0.97alpha3, to actually enable debug logging requires the <a href="#parameters_debug_elements" >debug_elements</a> parameter to be set up.
</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_default_escape_flags"></a>
<b>default_escape_flags</b> (list)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This is a list of escape flags that will be automatically applied to all substitution calls, i.e. <% <i>string</i> %>. See <a href="#filtering_escaping" >Escaping Content</a> for more information on content escaping.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_dhandler_name"></a>
<b>dhandler_name</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: dhandler<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The name of the file used as a directory handler, defaults to 'dhandler'. See the section <a href="#specialtempl_dhandler" >dhandlers</a> for information on directory handlers.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_disable_unicode"></a>
<b>disable_unicode</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: False<br/>
used by: Request, Compiler
<br/>since version: 1.1
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Disable the new unicode support features. If set, all strings are assumed to be <span class="codeline">str</span>s in the system default encoding (usually ASCII).
See the section on <a href="#unicode" >Unicode Support</a> for further details.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_dont_auto_flush_filters"></a>
<b>dont_auto_flush_filters</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: False<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
If auto_flush is turned on, this option will keep auto_flush turned off for components that use <%filter> sections. This is useful if you have filters that rely upon receiving the entire block of text at once. See the section <a href="#filtering_filtering" ><%filter></a> for more information on filters.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_encoding_errors"></a>
<b>encoding_errors</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: strict<br/>
used by: Request
<br/>since version: 1.1
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Sets the initial value for the <span class="codeline">encoding_errors</span> of requests, which, in turn, determines how character set encoding errors are handled.</p>
<p>Some choices are:</p>
<dl>
<dt><span class="codeline">strict</span></dt>
<dd>Raise an exception in case of an encoding error.</dd>
<dt><span class="codeline">replace</span></dt>
<dd>Replace malformed data with a suitable replacement marker,
such as <span class="codeline">"?"</span>.</dd>
<dt><span class="codeline">xmlcharrefreplace</span></dt>
<dd>Replace with the appropriate XML character reference.</dd>
<dt><span class="codeline">htmlentityreplace</span></dt>
<dd>Replace with the appropriate HTML character entity reference,
if there is one; otherwise replace with a numeric character reference.
(This is not a standard python encoding error handler. It is
provided by the <span class="codeline">mighty.escapes</span> module.)
</dd>
<dt><span class="codeline">backslashreplace</span></dt>
<dd>Replace with backslashed escape sequence.</dd>
<dt><span class="codeline">ignore</span></dt>
<dd>Ignore malformed data and continue without further notice.</dd>
</dl>
<p>See also the section on <a href="#unicode" >Unicode Support</a>,
and the Python <a href="http://docs.python.org/lib/module-codecs.html">codecs</a> documentation.
</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_error_handler"></a>
<b>error_handler</b> (function)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: RequestImpl
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>A function object that will be passed all exceptions and given the chance to handle them before regular processing occurs. The format of the function is:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">handle_error</span><span class="python_enclosure">(</span><span class="python_name">e</span><span class="python_operator">, </span><span class="python_name">m</span><span class="python_operator">, **</span><span class="python_name">params</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_comment"># custom error handling goes here</span>
<span class="python_comment"># ...</span>
<span class="python_comment"># return False to continue handling error, True to disregard</span>
<span class="python_operator"> </span><span class="python_keyword">return </span><span class="python_name">False</span><span class="python_operator"></span></pre></div>
<p>Where 'e' is a <span class="codeline">myghty.exception.Error</span> object and m is the request object. The global variable 'r' will also be passed if running in an HTTP context. The function should return True to stop all further error handling, or False to continue error handling as normal.</p>
<p>
The request object, while it is the same instance used to handle the request initially, no longer will have any buffered content and will also not have a current component instance. It is safe to call subrequests from it, allowing the construction of custom error pages.
</p>
<p>See also <a href="#parameters_raise_error" >raise_error</a> to simply raise an error outside the Request and bypass all internal and custom error handling.</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_escapes"></a>
<b>escapes</b> (dict)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: {'h':html_escape, 'u':url_escape}<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Use this parameter to define your own custom escaping functions that are available within substitutions, as well as <span class="codeline">m.apply_escapes()</span>. Within a dictionary key/value pair, the key is the identifying character, and the value is a reference to a single-argument function that will be called with the string with which to apply the text escape. The function should return the filtered text.
</p>
<p>Escaping is described fully at <a href="#filtering_escaping" >Escaping Content</a>.
</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_generator"></a>
<b>generator</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.objgen.PythonGenerator<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.objgen.ObjectGenerator</span> that is used to generate object files. Again, for the brave hacker, you can write your own generator and output object files in whatever language you like.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_global_args"></a>
<b>global_args</b> (dictionary)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: RequestImpl
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of global argument names and values that will be available in all template calls. See the section <a href="#globals_globalcustom" >Make your Own Friends</a> for details.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_interpreter_name"></a>
<b>interpreter_name</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: None<br/>
used by: HTTPHandler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Specifies the name of the Myghty interpreter that should be used. All HTTP handlers modules maintain a dictionary of HTTPHandler instances, each of which references a Myghty interpreter, keyed off of a name.
When this name is explicitly specified, that particular handler will be created if it doesnt exist and then used.</p>
<p>This option is currently most useful for use within multiple Apache directives, so that different sets of configuration parameters can be used for different directives, without requiring the use mod_python's multiple Python interpreters feature. See the example in <a href="#configuration_mod_python_multiple" >Advanced mod_python Configuration - Multiple ApacheHandlers</a>.
</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_lexer"></a>
<b>lexer</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.lexer.Lexer<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.request.Lexer</span>, used to parse the text of template files.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_log_cache_operations"></a>
<b>log_cache_operations</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: False<br/>
used by: ApacheHandler or CGIHandler
<br/>since version: 0.93b
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Deprecated; use <a href="#parameters_debug_elements" >debug_elements</a> instead.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_log_component_loading"></a>
<b>log_component_loading</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: False<br/>
used by: ApacheHandler or CGIHandler
<br/>since version: 0.93b
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Deprecated; use <a href="#parameters_debug_elements" >debug_elements</a> instead.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_log_errors"></a>
<b>log_errors</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: False<br/>
used by: HTTPHandler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Specifies whether or not component errors should receive a full stack trace in the Apache error log, standard error output of CGIHandler, or other HTTP-specific logging system.
If false, component errors still produce a single-line description of the error in the log. See also <a href="#parameters_output_errors" >output_errors</a>. If <a href="#parameters_raise_error" >raise_error</a> is set to true, no logging of errors occurs.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_max_recursion"></a>
<b>max_recursion</b> (integer)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: 32<br/>
used by: Request
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The highest level of component recursion that can occur, i.e. as in recursive calls to a subcomponent.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_module_components"></a>
<b>module_components</b> (array of hashes)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: ResolveModule
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This parameter is used for resolving <a href="#modulecomponents" >Module Components</a> using regular expressions which are mapped to function, class or class instance objects. See <a href="#modulecomponents_resolution_module_components" >module_components</a> for examples.</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_module_root"></a>
<b>module_root</b> (array of hashes)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: ResolvePathModule
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This parameter is used for resolving <a href="#modulecomponents" >Module Components</a> using file paths which map to the locations of python files and the attributes within. See <a href="#modulecomponents_resolution_module_root" >module_root</a> for examples.</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_module_root_adjust"></a>
<b>module_root_adjust</b> (callable)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: None<br/>
used by: ResolvePathModule
<br/>since version: 0.99b
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This parameter is used in combination with <a href="#parameters_module_root" >module_root</a> to specify a callable that will translate an incoming URI before being resolved to a path-based module. See <a href="#modulecomponents_resolution_module_root" >module_root</a> for more detail.</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_out_buffer"></a>
<b>out_buffer</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: DefaultRequestImpl
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A Python file object, or similar, with which to send component output. See the <a href="#configuration" >Configuration</a> section for examples.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_output_encoding"></a>
<b>output_encoding</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: sys.getdefaultencoding()<br/>
used by: Request
<br/>since version: 1.1
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Sets the initial value for the <span class="codeline">output_encoding</span> of requests. The default value is python's system default encoding (usually ASCII.)
See the section on <a href="#unicode" >Unicode Support</a> for further details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_output_errors"></a>
<b>output_errors</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: True<br/>
used by: ApacheHandler or CGIHandler
<br/>since version: 0.93b
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Specifies whether or not component errors with full stack trace should be reported to the client application.
If false, component errors will produce a 500 Server Error. See also <a href="#parameters_log_errors" >log_errors</a>. If <a href="#parameters_raise_error" >raise_error</a> is set to True, this parameter is overridden and client will receive a 500 server error (unless the error is caught by an external handler).
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_parent_request"></a>
<b>parent_request</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: None<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This parameter specifies the parent request when making subrequests, and is automatically provided. For more information see <a href="#components_programmatic" >Programmatic Interface</a>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_path_moduletokens"></a>
<b>path_moduletokens</b> (list of strings)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: ['index']<br/>
used by: ResolvePathModule
<br/>since version: 0.99b
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Used by <a href="#parameters_module_root" >module_root</a> to specify default path tokens that should be searched in module attribute paths. See <a href="#modulecomponents_resolution_module_root_options" >Module Root Options</a> for details.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_path_stringtokens"></a>
<b>path_stringtokens</b> (list of strings)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: []<br/>
used by: ResolvePathModule
<br/>since version: 0.99b
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Used by <a href="#parameters_module_root" >module_root</a> to specify default path tokens that should be searched in file paths. See <a href="#modulecomponents_resolution_module_root_options" >Module Root Options</a> for details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_path_translate"></a>
<b>path_translate</b> (list of tuples, or a callable)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: administrators<br/>
default: None<br/>
used by: Resolver
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
A list of regular-expression translations that will be performed on paths before they are used to locate a component and/or module component. This can be useful for complicated web server configurations where aliases point to component roots, or specifying a default document for path requests. It looks as follows:
<div class="code">
<pre><span class="python_name">path_translate </span><span class="python_operator">= </span><span class="python_enclosure">[</span>
<span class="python_comment"># convert /store/* to /shop/*</span>
<span class="python_enclosure">(</span><span class="python_literal">r'^/store/(.*)'</span><span class="python_operator">, </span><span class="python_literal">r'/shop/\1'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_comment"># convert /documents/* to /docs/*</span>
<span class="python_enclosure">(</span><span class="python_literal">r'^/documents/'</span><span class="python_operator">, </span><span class="python_literal">'/docs/'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_comment"># convert /foo/bar/ to /foo/bar/index.myt</span>
<span class="python_enclosure">(</span><span class="python_literal">r'/$'</span><span class="python_operator">, </span><span class="python_literal">'/index.myt'</span><span class="python_enclosure">)</span><span class="python_operator">,</span>
<span class="python_enclosure">]</span><span class="python_operator"></span></pre></div>
<p>As of revision 0.99b, the argument to path_translate can alternatively be specified as a callable, which converts its given URI to the translated value:</p>
<div class="code">
<pre><span class="python_keyword">def </span><span class="python_name">my_translate</span><span class="python_enclosure">(</span><span class="python_name">uri</span><span class="python_enclosure">)</span><span class="python_operator">:
</span><span class="python_keyword">return </span><span class="python_literal">"/doc/" </span><span class="python_operator">+ </span><span class="python_name">uri</span><span class="python_operator">
</span><span class="python_name">path_translate </span><span class="python_operator">= </span><span class="python_name">my_translate</span><span class="python_operator"></span></pre></div>
<p>Note that the <a href="#request_members_request_path" >request_path</a> member of the request object will reference the original path before translation, whereas the <a href="#components_members_path" >path</a> of the component served will contain the translated path (for file-based components).</p>
<p>More detail about path translation can be found in <a href="#resolver" >Advanced Resolver Configuration</a>.</p>
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_python_post_processor"></a>
<b>python_post_processor</b> (function)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
References a function that will be invoked with the full text of each individual unit of Python code created during component generation (i.e., creation of .py files). The returned string will be used as the Python code that is actually placed within the generated .py file. Also see <a href="#parameters_text_post_processor" >text_post_processor</a>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_python_pre_processor"></a>
<b>python_pre_processor</b> (function)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
References a function that will be invoked with the full text of a template's source file before it is parsed. The returned string will then be used as the source to be parsed.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_raise_error"></a>
<b>raise_error</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: False<br/>
used by: Request
<br/>since version: 0.97a
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Indicates if errors should be raised when they occur, or be handled by error handling functionality. If set to True, no error logging, friendly client response, or custom internal error handler function will happen. Instead, an external error handler can be used.
This parameter overrides invalidates the functionality of <a href="#parameters_log_errors" >log_errors</a>, <a href="#parameters_output_errors" >output_errors</a> and <a href="#parameters_error_handler" >error_handler</a>.
</p>
<p>
This parameter allows the entire <span class="codeline">interpreter.execute()</span> or <span class="codeline">handler.handle()</span> call to be wrapped in a <span class="codeline">try: / except:</span> block, where the error can be handled externally to all Myghty functionality.
</p>
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_request"></a>
<b>request</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.request.Request<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.request.Request</span> used as a prototype to generate new requests. Its context-specific behavior is supplied by a separate instance of <span class="codeline">myghty.request.RequestImpl</span>, so there is not much reason to change this either.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_request_impl"></a>
<b>request_impl</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.request.DefaultRequestImpl<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.request.RequestImpl</span> that will be used either as a prototype to create new RequestImpls per request, or can be passed per individual interpreter execution. RequestImpl tells <span class="codeline">Request</span> how it should interact with its environment. Take a look at <span class="codeline">ApacheHandler.ApacheRequestImpl</span>, <span class="codeline">CGIHandler.CGIRequestImpl</span>, and <span class="codeline">myghty.request.DefaultRequestImpl</span> for examples.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_request_path"></a>
<b>request_path</b> (string)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: myghty.request.Request<br/>
used by: Request
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Sets the initial request path for this request. In most cases, this is set automatically by simply calling a request with a string-based component name, or with a file-based component which can return its originating path. However, in the case of a request being called with a memory or module-based component, the path defaults to None and must be set by the calling function if it is to be referenced by components.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_require_publish"></a>
<b>require_publish</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: all<br/>
default: False<br/>
used by: ResolvePathModule
<br/>since version: 0.99b
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>Indicates that callables located via <a href="#parameters_module_root" >module_root</a> resolution require an attribute named 'public' set to True attached to them, in order to allow access. See <a href="#modulecomponents_resolution_module_root_options" >Module Root Options</a> for details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_resolver"></a>
<b>resolver</b> (object)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: myghty.resolver.FileResolver<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
An instance of <span class="codeline">myghty.resolver.Resolver</span> that is used to locate component files. Both ApacheHandler and CGIHandler have their own instances of <span class="codeline">Resolver</span> but don't yet do anything special. If you wanted some kind of special file resolution behavior, you can swap in your own subclass of <span class="codeline">Resolver</span>.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_resolver_strategy"></a>
<b>resolver_strategy</b> (list)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: Resolver
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Allows configuration of the rules used in component resolution. See the section <a href="#resolver" >Advanced Resolver Configuration</a> for details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_source_cache_size"></a>
<b>source_cache_size</b> (integer)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: 1000<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Size of the cache used by Interpreter to cache the source of components. See <a href="#parameters_use_static_source" >use_static_source</a> for
a description of source caching, and see code_cache_size for a description of the LRU caching scheme.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_text_post_processor"></a>
<b>text_post_processor</b> (function)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
References a function that will be invoked with the full text of each individual unit of output text created during component generation (i.e., creation of .py files). The returned string will be used as the output text that is actually placed within the generated .py file. Also see <a href="#parameters_python_post_processor" >python_post_processor</a>.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_use_auto_handlers"></a>
<b>use_auto_handlers</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: True<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Whether or not to use autohandlers. See the section <a href="#specialtempl_autohandler" >autohandlers</a> for more information.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_use_dhandlers"></a>
<b>use_dhandlers</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: True<br/>
used by: Request
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Whether or not to use directory handlers. See the section <a href="#specialtempl_dhandler" >dhandlers</a> for more information.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_use_object_files"></a>
<b>use_object_files</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: True if data_dir is not null<br/>
used by: Interpreter
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Indicates whether or not components should be compiled into module files on the filesystem, or into strings held in memory. A value of None for the <a href="#parameters_data_dir" >data_dir</a> parameter will have the same effect. There is no advantage whatsoever to having components compiled in memory, and startup performance will be degraded for repeated calls to the same component. It might be useful if you are running the interpreter in a "one shot" fashion where there is no need to have compiled object files lying around.
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_use_session"></a>
<b>use_session</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: developers<br/>
default: None<br/>
used by: ApacheHandler
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
The additional global variable <i>s</i> to reference the Myghty session, or alternatively
the mod_python 3.1 session,
is turned on when this option is set to True. See the section <a href="#session" >Session</a> for details.
</p>
</td>
</tr>
<tr class="light">
<td valign="top">
<A name="parameters_use_source_line_numbers"></a>
<b>use_source_line_numbers</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: hackers<br/>
default: None<br/>
used by: Compiler
</div>
</td>
</tr>
<tr class="light">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
Whether or not to put source line numbers in compiled object files. This is used to generate friendly stack traces upon errors (when that feature is complete).
</p>
</td>
</tr>
<tr class="dark">
<td valign="top">
<A name="parameters_use_static_source"></a>
<b>use_static_source</b> (boolean)</td>
<td align="right" width="40%">
<div style="text-align:left">
for users: optimizers<br/>
default: False<br/>
used by: Interpreter, Resolver
</div>
</td>
</tr>
<tr class="dark">
<td colspan="2">
<p style="margin-left:15px;margin-bottom:5px;margin-top:5px">
This parameter, when set to <span class="codeline">True</span>:
<ul>
<li>Enables URI caching within the resolver, and/or turns on all configured URICache() resolution rules, so that visiting a URI a second time does not produce any filesystem checks, within the currently cached set of URIs. </li>
<li>Disables repeated last-modification time checks on all template files and module-component files</li>
<li>Disables last-modification time checks on compiled template object files against the template they were generated from, which in effect disables re-compilation of templates even across server restarts, unless the object file is removed from the <span class="codeline">obj</span> directory underneath the configured <a href="#parameters_data_dir" >data_dir</a> directory</li>
</ul>
Use use_static_source on production servers where the site's structure is not being changed, to prevent auto-recompilation of modified templates, and to prevent reloads of modified module component modules. There is both a performance increase due to fewer filesystem checks, and also a stability increase, as no Python modules are dynamically reloaded within a running server. Dynamic reloads in Python are somewhat error-prone, particularly if a module with a base class changes, and a corresponding subclass in a different, non-reloaded module attempts to instantiate itself.
</p>
</td>
</tr>
</table>
</div>
<a href="#parameters" class="toclink">back to section top</a>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="technical"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#parameters">Index of Configuration Parameters</a>
|
Next: <a href="#docstrings">Modules and Classes</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Myghty Guts (tech description)</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#technical_goals">Design Goals</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#technical_templates">Approaches to Templating</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#technical_generation">Generating Python Modules</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#technical_request">Handling a Request</a>
</div>
<div class="toclinkcontainer">
</div>
<div class="toclink">
<A style="" href="#technical_modules">Modules</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_request">request</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_interp">interp</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_lexer">lexer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_compiler">compiler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_objgen">objgen</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_component">component</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_resolver">resolver</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_escapes">escapes</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_buffer">buffer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_HTTPHandler">HTTPHandler</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_util">util</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_synchronizer">synchronizer</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_cache">cache</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_container">container</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#technical_modules_exception">exception</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#technical_differences">Differences from HTML::Mason</a>
</div>
<div class="toclinkcontainer">
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
<p>This section refers to the inner workings of Myghty and how it relates to HTML::Mason.</p>
</div>
<A name="technical_goals"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Design Goals</span>
<div class="sectiontext">
<p>The main goal in developing Myghty is, port HTML::Mason to Python ! Beyond that, it is important that it retain all the central features of HTML::Mason, to make it easy for people already familiar with Mason to use Myghty as well. </p>
<p>But even though the language should be similar to Mason's, it also should be altered as needed to appropriately fit the Python language style, which while having some notable similarities to Perl, is still a different beast. The design of the engine should model itself after that of Mason's at a high level, but also should take advantage of the opportunities the "clean start" porting to Python gives, including code streamlining, introduction of new design patterns, and putting to use the unique programming capabilities Python affords (since after all, I wouldnt be porting to Python if I didn't think Python had some unique things to offer). </p>
<p>Going forward, the design and featureset of Myghty is expected to diverge from that of HTML::Mason, which is seen as more of a "starting point" rather than a continuous benchmark to follow. Since it is intended for a different audience than that of Mason, i.e. the Python developmental community, I am hoping that its development can be steered into being a useful and "first choice" enterprise web development tool specifically for Python enthusiasts.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_templates"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Approaches to Templating</span>
<div class="sectiontext">
<p>Myghty is a <b>compiled page</b> system, as opposed to a <b>directly interpreted</b> system. A compiled page system means that templates are used to generate source code files consisting a programming language that is different from that of the actual template, typically the same language as that of the language compiler itself. Whereas a directly interpreted language provides its own language interpreter for templates. Compiled page systems include Java Server Pages, Embperl, HTML::Mason, Python Server Pages. Directly interpreted systems include PHP, Webmacro, and FreeMarker (whose early development history bears the name of Myghty's author). </p>
<p>Each approach has its own advantages and disadvantages. A directly interpreted system has the burden of providing a full programming language written from scratch, which can result in a language that is somewhat rigid and single-purposed, but can potentially deliver extremely fast performance. A compiled page system is much simpler to write, and typically allows full blocks of the host language to be dropped into templates. This allows great flexibility, but is also known to result in templates that are more complicated than is appropriate, depending on the developer's code practices.
For developers of Python code, Python is probably an elegant and powerful enough language that it deserves to live within templates unadulterated, as it does within Myghty.</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_generation"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Generating Python Modules</span>
<div class="sectiontext">
<p>A Myghty template file, which might have an extension such as ".myt", is parsed by the engine and converted into a python module, which contains a subclass of the class <span class="codeline">Component</span>. This new python module, which also gets compiled by python into a .pyc file, then forms the basis for generating the template's final output, and is only changed whenever the original template changes.</p>
<p>The majority of the template is encoded as Python statements inside of a class method called <span class="codeline">do_run_component()</span>. Straight text from the template file gets distilled into <span class="codeline">write</span> statements, lines and blocks of Python code get inserted inline as they are (with their whitespace adjusted to the appropriate context), and calls to other parts of the template or other templates get translated into calls that look like <span class="codeline">m.execute_component()</span>.
A pre-determined namespace of one or more helper variables is provided to statements within the template so that your template can attend to its daily chores, such as looking at the apache request, sending headers, ordering takeout, what have you. Other details to be dealt with by <span class="codeline">Component</span> include handling argument lists being passed around as well as properly specifying the scoping of variables and custom methods.</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_request"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Handling a Request</span>
<div class="sectiontext">
<p>
A request starts first with the module that is handling the host environment. This may be the ApacheHandler, the CGIHandler, a standalone handler, or any developer-custom handler (they're pretty easy to write).</p>
<p>The handler then is responsible for creating an instance of <span class="codeline">myghty.interp.Interpreter</span> with the proper arguments corresponding to the execution environment, and then calling the <span class="codeline">execute()</span> method on that interpreter with request-specific arguments, which will begin the process of compiling, loading, and running a Myghty template.</p>
<p>The Interpreter then creates an instance of <span class="codeline">myghty.request.Request</span> which represents the template and arguments we are actually going to serve, and optionally a <span class="codeline">myghty.request.RequestImpl</span> object which provides additional environment-specific behavior to the Request object, including the request arguments and the output buffer where content will be written.
</p>
<p>
Request is responsible for looking up the requested component and also other referenced components, which may be inherit components, methods in other component files, etc. The individual lookup operations are sent back to the hosting Interpreter object, which will coordinate amongst an instance of <span class="codeline">myghty.resolver.Resolver</span> to locate files, a cache of <span class="codeline">myghty.resolver.ComponentSource</span> instances representing located template files, and a thread-local instance of <span class="codeline">myghty.compiler.Compiler</span> which is responsible for parsing in new template files and producing compiled component files from them, from which Interpreter can receive new <span class="codeline">myghty.component.Component</span> objects. <span class="codeline">myghty.compiler.Compiler</span> makes use of the <span class="codeline">Lexer</span> and <span class="codeline">ObjectGenerator</span> objects to compile templates.
</p>
<p>
The Request object executes the components it locates, passing itself as the primary namespace variable <i>m</i> to components, manages a call-stack of components, and manages a stack of <span class="codeline">myghty.buffer.AbstractBuffer</span> objects which capture component output. Exceptions are also handled here and processed so that they contain clean stack traces.</p>
<p>Request then cleans up and finishes, Interpreter finishes, and its back up to the handler to send return codes and exit its handle method.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Modules</span>
<div class="sectiontext">
<p>To gain a deeper understanding of Myghty, heres a quick rundown of the modules and what their purpose is.</p>
</div>
<A name="technical_modules_request"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">request</span>
<div class="sectiontext">
<p>The request package is home to the Request object. Request is an object that is instantiated by Interpreter to service a top-level component exactly once. It is available within a component's namespace by the special variable <i>m</i>. It is responsible for locating all components and inherited components referenced by its top-level component, including autohandlers and dhandlers, calling them in the appropriate order, buffering their output, and handling exceptions. It interacts with the outside world via an embedded RequestImpl object, such as DefaultRequestImpl (also included in the request package) for dealing with a command-line environment, ApacheRequestImpl for dealing with mod_python, and CGIRequestImpl which handles a CGI environment.
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_interp"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">interp</span>
<div class="sectiontext">
<p>interp is home to the Interpreter object. Interpreter represents a Myghty application environment and its configuration parameters, and is the primary API used for executing requests within that environment. Interpreter contains logic for loading and compiling component objects at a high level, and dispatching those compiled component objects to new requests. It also deals with the filesystem structure where component files, lock files, and cache files are stored.</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_lexer"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">lexer</span>
<div class="sectiontext">
<p>
The lexer package contains the Lexer object, which is responsible for parsing component files or in-memory strings and sending the resulting tokens to an instance of Compiler. Lexer relies heavily on the regular expression package to produce its results.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_compiler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">compiler</span>
<div class="sectiontext">
<p>
Compiler represents a location for Lexer to send its parsing events, and aggregates a compiled parse tree structure for a particular compilation. Once complete it calls an instance of ObjectGenerator with the new parse tree to produce the source code of a Myghty component. The parse tree itself is an instance of Compiler.Compiled, which stores the various code blocks and supports visitor-based traversal.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_objgen"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">objgen</span>
<div class="sectiontext">
<p>
The home to ObjectGenerator, PythonGenerator, and PythonPrinter. ObjectGenerator is a generic interface for receiving visitor events from a compiled structure. The PythonGenerator extends ObjectGenerator to produce source code strings/files from that compiled structure. PythonPrinter handles printing of python code lines while keeping track of the indentation level, to allow all kinds of Myghty blocks to aggregate into one coherent Python source file.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_component"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">component</span>
<div class="sectiontext">
<p>
component contains the hierarchy of Component, FileComponent and SubComponent, which serve as the base classes for user-defined Myghty components. FileComponent contains initialization logic for handling requestlocal and threadlocal sections, as well as the initial determination of inheritance.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_resolver"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">resolver</span>
<div class="sectiontext">
<p>
contains the Resolver object and the various built in ResolverRule objects. The Resolver
is called by the Interpreter.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_escapes"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">escapes</span>
<div class="sectiontext">
<p>
Contains code for handling substitution escaping, which includes URL, HTML and XML escaping.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_buffer"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">buffer</span>
<div class="sectiontext">
<p>
Provides interfaces for Python file objects which allow structures of buffers to be created. This is used to direct the output of components, subcomponents, filter sections, etc. to its final destination according to autoflush rules.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_HTTPHandler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">HTTPHandler</span>
<div class="sectiontext">
<p>HTTPHandler is the base class for the the HTTP-oriented handlers, which includes
ApacheHandler, CGIHandler, WSGIHandler, and HTTPServerHandler.</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_util"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">util</span>
<div class="sectiontext">
<p>Util contains the data structure objects Value, ThreadLocal, OrderedDict as well as the cloning helper object ConstructorClone.</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_synchronizer"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">synchronizer</span>
<div class="sectiontext">
<p>
synchronizer contains code for synchronizing read and write operations on data structures against thread mutexes and file-based mutexes.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_cache"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">cache</span>
<div class="sectiontext">
<p>
The cache package provides the primary API for component output caching and data structure caching.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_container"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">container</span>
<div class="sectiontext">
<p>
The container package provides a system of storing namespaces of key/value pairs in memory or filesystem based storage units, with additional support for DBM and memcached. It is used as the common storage engine for the cache system as well as the session object.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<A name="technical_modules_exception"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">exception</span>
<div class="sectiontext">
<p>
The exception package defines a hierarchy of errors used across Myghty, as well as stack-trace formatting code used for logging and printing exceptions.
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
</div>
<A name="technical_differences"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Differences from HTML::Mason</span>
<div class="sectiontext">
<p>Myghty is not the same as Mason. Mason, which has established itself as a fast and efficient methodology for producing high capacity websites, has provided the initial starting point, but should the direction of Myghty go in a divergent direction, that is entirely OK. When porting Mason to Myghty, opportunities arose to rework a lot of sections in new ways, and also to take advantage of the unique features of Python. Browsing the source code of both applications can reveal a lot about this process. </p>
<p>As far as the user experience as well as the internal architecture, beyond the obvious "its python, not perl" as well as the python indentation scheme, the differences between Myghty and Mason continue to mount, with some significant syntactical differences as well as executional differences:
<ul>
<li>%python tag contains the "scope" attribute, which effectively replaces %shared, %once, %init, %cleanup.
<li>%args tag contains optional "scope" attribute, to specify component or request-scoped arguments
<li>%shared, %once, %init, %cleanup still exist, and %shared is also synonymous with %requestlocal and %requestonce, %once is synonymous with %global
<li>thread-scoped python was added, referenced by scope="thread" or alternatively %threadlocal, %threadonce
<li>the %flags section can also be specified inline inside the %method and %def tags as attributes
<li>filter sections and filter functions need to return a new instance of string with the filtered content since python strings are immutable. Mason filters modify content in place.
<li>the %cleanup section is guaranteed to execute even in the case of components that raise an error, as the section is executed in a <span class="codeline">finally</span> block.
<li>%cleanup is also available within methods and subcomponents
<li>additional component flags: <span class="codeline">autoflush</span> for fine-grained control of buffering,
<span class="codeline">trim</span> for whitespace trimming of component output. full cache functionality is available via the <span class="codeline">use_cache</span> flag as well as all the options as <span class="codeline">cache_XXXX</span>.
<li>the request object and component object interfaces were changed to be more pythonic, using properties as much as possible, as well as having different method names in some cases. the execution model is a little different as well.
<li>module components architecture added, provides servlet-like objects to applications
<li>The m and r objects are available in request-scoped (%shared) and thread-scoped blocks
<li>ApacheHandler and CGIHandler were rewritten entirely. They give their behavior to the Request object via their own implementations of RequestImpl.
<li>Caching API was rewritten entirely, and utilizes a genericized "container" API. It includes a mutex-based "busy lock" feature. The file storage system is DBM based. Component caching can also be configured via the %flags section of any component to avoid the more complicated programmatic interface.
<li>Building off of the container API, a Session object is included in the base distribution which can also be configured as a global variable.
<li>The Mason strategy of <span class="codeline">Class::Container</span> has been removed, and some of its functionality replaced with a small helper object called <span class="codeline">myghty.util.ConstructorClone</span> that is used to create clones of objects.
<li>The <span class="codeline">buffer</span> object was entirely rewritten as a hierarchy of classes that resemble Python's built-in file objects, and the attachment of buffers to each other is acheived through a "decorator" pattern.
<li>Object generation was completely rewritten using a "visitor" paradigm and is more decoupled from the Compiler.
<li>The Request object's context-specific behavior is provided by an internally-referenced RequestImpl object, which can be replaced with different implementations without the class of Request having to change.
</ul>
</p>
</div>
<a href="#technical" class="toclink">back to section top</a>
</div>
<hr width="400px" align="left" />
</div>
</div>
<div class="section">
<A name="docstrings"></a>
<div class="topnavmargin">
<div class="topnav">
<div class="topnavcontrol">
View: <a href="index.html">Paged</a> | <b>One Page</b>
</div>
<div class="topnavsectionlink">
<a href="#top">Table of Contents</a>
<div class="prevnext">
Previous: <a href="#technical">Myghty Guts (tech description)</a>
</div>
</div>
<div class="topnavmain">
<div class="topnavheader">Modules and Classes</div>
<div class="topnavitems">
<div class="toclink">
<A style="" href="#docstrings_myghty.request">Module myghty.request</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.request_modfunc">Module Functions</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.request_Request">Class Request(object)</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings_myghty.component">Module myghty.component</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_Component">Class Component(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_FileComponent">Class FileComponent(Component)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_HTTPModuleComponent">Class HTTPModuleComponent(ModuleComponent)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_ModuleComponent">Class ModuleComponent(Component)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.component_SubComponent">Class SubComponent(Component)</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings_myghty.interp">Module myghty.interp</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.interp_Interpreter">Class Interpreter</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings_myghty.resolver">Module myghty.resolver</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_AdjustedResolveFile">Class AdjustedResolveFile(ResolveFile)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Conditional">Class Conditional(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ConditionalGroup">Class ConditionalGroup(Conditional)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Group">Class Group(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_NotFound">Class NotFound(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_PathTranslate">Class PathTranslate(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveDhandler">Class ResolveDhandler(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveFile">Class ResolveFile(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveModule">Class ResolveModule(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolvePathModule">Class ResolvePathModule(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolveUpwards">Class ResolveUpwards(ResolverRule)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_Resolver">Class Resolver(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_ResolverRule">Class ResolverRule(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.resolver_URICache">Class URICache(ResolverRule)</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings_myghty.csource">Module myghty.csource</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ComponentSource">Class ComponentSource(object)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_FileComponentSource">Class FileComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_MemoryComponentSource">Class MemoryComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ModuleComponentSource">Class ModuleComponentSource(ComponentSource)</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.csource_ModuleComponentSourceSingleton">Class ModuleComponentSourceSingleton(type)</a>
</div>
</div>
</div>
<div class="toclink">
<A style="" href="#docstrings_myghty.session">Module myghty.session</a>
</div>
<div class="toclinkcontainer">
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_MyghtySessionArgs">Class MyghtySessionArgs</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_Session">Class Session</a>
</div>
</div>
<div class="toclinkcontainer">
<div class="smalltoclink">
<A href="#docstrings_myghty.session_SignedCookie">Class SignedCookie(BaseCookie)</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="subsection" style="margin-left:10px;">
<div class="sectiontext">
</div>
<A name="docstrings_myghty.request"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.request</span>
<div class="sectiontext">
<p>
The request package and its primary class, Request, provide the "m" object in Myghty templates.
The Request is instantiated by the Interpreter and handles component execution state as well as buffered state.
It provides the interface to all actions taken by components, such as writing output,
calling other components, calling subrequests, and controllling request state. Also provides the programmatic interface to key objects such as caches and sessions.</p>
<p></p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.request_modfunc"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Module Functions</span>
<div class="sectiontext">
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.request_modfunc_def instance"></a>
<b>def instance()</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the Request instance corresponding to the current thread
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_modfunc_def threadlocal"></a>
<b>def threadlocal(<i>value=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns a thread local container, with initial value that of the given variable
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.request_Request"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Request(object)</span>
<div class="sectiontext">
<p>
request object, calls components and directs output. also is the primary programmatic interface presented to a template's environment.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def __init__"></a>
<b>def __init__(<i>self</i>, <i>interpreter</i>, <i>component=None</i>, <i>request_impl=None</i>, <i>max_recursion=32</i>, <i>auto_flush=False</i>, <i>use_dhandlers=True</i>, <i>dont_auto_flush_filters=False</i>, <i>resolver_context='request'</i>, <i>parent_request=None</i>, <i>request_depth=0</i>, <i>request_path=None</i>, <i>raise_error=False</i>, <i>disable_wrapping=False</i>, <i>output_encoding='ascii'</i>, <i>encoding_errors='strict'</i>, <i>disable_unicode=False</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
init is called internally by the Interpreter.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def abort"></a>
<b>def abort(<i>self</i>, <i>status_code=None</i>, <i>reason=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
raises an abort exception.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def apply_escapes"></a>
<b>def apply_escapes(<i>self</i>, <i>text</i>, <i>escapes</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
applies the given escape flags to the given text. escapes is a list of escape flags, such as 'h', 'u', and 'x'.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_attributes = property()"></a>
<b>attributes = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
A dictionary where arbitrary attributes can be stored and retrieved. Inherits data from its parent request, if any.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def base_comp"></a>
<b>def base_comp(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the base_component property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_base_component = property()"></a>
<b>base_component = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Returns the "base component" for the current stack frame, which is either the top level component or the owning component of a method component.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def cache"></a>
<b>def cache(<i>self</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
a synonym for get_cache().
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def cache_self"></a>
<b>def cache_self(<i>self</i>, <i>key='_self'</i>, <i>component=None</i>, <i>retval=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
caches this component's output. this is called in a "reentrant" fashion; if it returns False, component execution should continue. If it returns True,
component execution should cease.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def call_content"></a>
<b>def call_content(<i>self</i>, <i>**kwargs</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
calls the "captured content" function within a component call with content
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def call_next"></a>
<b>def call_next(<i>self</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
used within an inheritance chain to call the next component in the chain. If **params are given, each parameter will override the arguments sent to this component when calling the next component.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def call_self"></a>
<b>def call_self(<i>self</i>, <i>output_buffer</i>, <i>return_buffer</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
calls this component and places its output and return value in the given buffers.
This component is called in a "reentrant" fashion, where a return value of False means to continue component execution and a return value of True means to halt execution and return.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def call_stack"></a>
<b>def call_stack(<i>self</i>, <i>index=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the current execution stack, which consists of StackFrame objects.
if an integer index is given, returns the StackFrame object at that position in the current call stack.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_caller = property()"></a>
<b>caller = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the calling component for the currently executing component.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def caller_args"></a>
<b>def caller_args(<i>self</i>, <i>index=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the list of component arguments in the current call stack. if an integer index is given, returns the component arguments at that position in the current call stack.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def callers"></a>
<b>def callers(<i>self</i>, <i>index=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the list of components in the current call stack. if an integer index is given, returns the component at that position in the current call stack.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def clear_buffer"></a>
<b>def clear_buffer(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
clears all content from the current output buffer.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def clone"></a>
<b>def clone(<i>self</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
creates a copy of this Request. Normally used to create subrequests.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def closure_with_content"></a>
<b>def closure_with_content(<i>self</i>, <i>func</i>, <i>content=None</i>, <i>args=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
given a function, will execute it with the given arguments, after pushing the given content function onto the call stack via a new StackFrame, enabling the function to call it via the content() method.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def comp"></a>
<b>def comp(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
component calling method which takes a simple parameter list.
this method is meant to be the default method to call when calling components programmatically.
compare to scomp().
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_component_args = property()"></a>
<b>component_args = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the argument dictionary from the current stack frame, corresponding to the arguments sent to the currently executing component.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def component_exists"></a>
<b>def component_exists(<i>self</i>, <i>path</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if the given component path exists.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def content"></a>
<b>def content(<i>self</i>, <i>**kwargs</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
when inside a component call with content, this method calls the "captured content" function and buffers the content, returning the string value.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_content_args = property()"></a>
<b>content_args = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the component-call-with-content argument dictionary from the current stack frame, corresponding to the arguments sent in an m.content() call.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def create_subrequest"></a>
<b>def create_subrequest(<i>self</i>, <i>component</i>, <i>resolver_context='subrequest'</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
base subrequest-creation method. A subrequest is a request that is a child to this one, enabling execution of a component and its full inheritance chain within this request.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def current_comp"></a>
<b>def current_comp(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the current_component property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_current_component = property()"></a>
<b>current_component = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the component currently executing from the current stack frame.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def decline"></a>
<b>def decline(<i>self</i>, <i>returnval=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
used by dhandlers to decline handling the current request. Control will be passed to the next enclosing dhandler, or if none is found a ComponentNotFound (and possibly 404 error) is raised.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_depth = property()"></a>
<b>depth = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Returns the current depth of the execution stack.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def dhandler_arg"></a>
<b>def dhandler_arg(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_path or dhandler_argument property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_dhandler_argument = property()"></a>
<b>dhandler_argument = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the current dhandler_argument, which corresopnds to the remaining path tokens in the request URI when executing a dhandler.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_encoding_errors = property()"></a>
<b>encoding_errors = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
The encoding error handling strategy for the request</p>
<p>This is the error handling strategy used when encoding text writtent to the output buffer of the top-level request.</p>
<p>This is a read-only attribute, though you can change its value using the `set_output_encoding`_ method.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def execute"></a>
<b>def execute(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
executes this request after constructed. This is the first method called,
and can only be called once per request.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def execute_component"></a>
<b>def execute_component(<i>self</i>, <i>component</i>, <i>args={}</i>, <i>base_component=None</i>, <i>content=None</i>, <i>store=None</i>, <i>is_call_self=False</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
component calling method which takes parameter list as a dictionary, and allows special execution options.
This method is used by component call tags and internally within the Request object.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def fetch_all"></a>
<b>def fetch_all(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
pops off the entire remaining list of components in the inheritance chain.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def fetch_component"></a>
<b>def fetch_component(<i>self</i>, <i>path</i>, <i>resolver_context='component'</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p>Given a component path (absolute or relative), returns a component.
Handles SELF, PARENT, REQUEST, comp:method, relative->absolute conversion, MODULE, and local subcomponents.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def fetch_lead_component"></a>
<b>def fetch_lead_component(<i>self</i>, <i>path</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
fetches the top level (initial) component to be executed by this request. Differs from fetch_component in that the resolver context is "request" or "subrequest" and the dhandler flag is enabled when resolving. Also does not support method calls.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def fetch_module_component"></a>
<b>def fetch_module_component(<i>self</i>, <i>moduleorpath</i>, <i>classname=None</i>, <i>raise_error=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
fetches a module-based component. Usually called by fetch_component when the 'MODULE' keyword is given as a prefix.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def fetch_next"></a>
<b>def fetch_next(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
in an inheritance chain (i.e. of autohandlers), returns the next component in the chain
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def flush_buffer"></a>
<b>def flush_buffer(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
flushes the current output buffer to its destination.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_attribute"></a>
<b>def get_attribute(<i>self</i>, <i>key</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the attributes property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_attributes"></a>
<b>def get_attributes(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the attributes property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_base_component"></a>
<b>def get_base_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the base_component property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_cache"></a>
<b>def get_cache(<i>self</i>, <i>component=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the given component's cache. **params is a dictionary of options used as the default options for individually cached elements.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_component_args"></a>
<b>def get_component_args(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the component_args property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_current_component"></a>
<b>def get_current_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the current_component property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_depth"></a>
<b>def get_depth(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the depth property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_dhandler_argument"></a>
<b>def get_dhandler_argument(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_path or dhandler_argument property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_encoding_errors"></a>
<b>def get_encoding_errors(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_interpreter"></a>
<b>def get_interpreter(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the interpreter property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_log"></a>
<b>def get_log(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the logger property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_output_encoding"></a>
<b>def get_output_encoding(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_request_args"></a>
<b>def get_request_args(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_args property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_request_component"></a>
<b>def get_request_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_component property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_request_path"></a>
<b>def get_request_path(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_path property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def get_session"></a>
<b>def get_session(<i>self</i>, <i>*args</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the Session object used by this request. If the session has not been created it will be created when this method is called. Once the session is created, this method will return the same session object repeatedly. **params is a dictionary of options used when the session is first constructed; if it already exists, the parameters are ignored.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def get_start_time"></a>
<b>def get_start_time(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the starttime property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def has_content"></a>
<b>def has_content(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns whether or not the current component call was called with captured content specified
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def has_current_component"></a>
<b>def has_current_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns if this request has a currently executing component.
This could return false if the request's top-level-component is in the loading stage.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def is_subrequest"></a>
<b>def is_subrequest(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if this request is a subrequest.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def load_component"></a>
<b>def load_component(<i>self</i>, <i>path</i>, <i>raise_error=True</i>, <i>resolver_context=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
a mirror of interpreter.load() which caches its results in a request-local dictionary, thereby bypassing all the filesystem checks that interp does for a repeated file-based request.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def log"></a>
<b>def log(<i>self</i>, <i>message</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
writes a message to the request log. The log is RequestImpl-specific and can be standard error, a webserver error log, or a user-defined file object.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_logger = property()"></a>
<b>logger = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the logger for this Request, which is a file-like object.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def make_subrequest"></a>
<b>def make_subrequest(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
creates a subrequest with the given component and request parameters.
see create_subrequest().
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_notes = property()"></a>
<b>notes = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
A synonym for m.attributes
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def out"></a>
<b>def out(<i>self</i>, <i>string</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
a synonym for write
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_output_encoding = property()"></a>
<b>output_encoding = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
The ouput encoding for the request</p>
<p>This is the encoding of the output written to the output buffer of the top-level request. (I.e. the encoding delivered to the user.)</p>
<p>This is a read-only attribute, though you can change its value using the `set_output_encoding`_ method.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def request_comp"></a>
<b>def request_comp(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the request_component property.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_root_request_args = property()"></a>
<b>root_request_args = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
The request argument dictionary sent to the ultimate root request of this Request.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_root_request_path = property()"></a>
<b>root_request_path = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
The URI sent to the ultimate root request of this Request.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def scomp"></a>
<b>def scomp(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
component calling method which returns output as a string
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def send_redirect"></a>
<b>def send_redirect(<i>self</i>, <i>path</i>, <i>hard=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
sends a redirect to the given path. If hard is True, sends an HTTP 302 redirect via the underlying RequestImpl being used. If False, clears out the current output buffer and executes a subrequest with the given path. The path can also contain url encoded query string arguments with a question mark which will be converted to key/value arguments for the next request, even if hard=False.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def set_attribute"></a>
<b>def set_attribute(<i>self</i>, <i>key</i>, <i>value</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deprecated. use the attributes property.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def set_output_encoding"></a>
<b>def set_output_encoding(<i>self</i>, <i>encoding</i>, <i>errors='strict'</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
Change the output_encoding.
Note that in most cases you do not want to change it after you have written any output (as then your output will be in two different encodings --- probably not what you wanted unless,
perhaps, you are generating Mime multipart output.)</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.request_Request_def subexec"></a>
<b>def subexec(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
creates a subrequest with the given component and request parameters and executes it.
see create_subrequest().
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.request_Request_def write"></a>
<b>def write(<i>self</i>, <i>string</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
writes textual content to the current output buffer.
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<A name="docstrings_myghty.component"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.component</span>
<div class="sectiontext">
<p>
the component package defines the Component class and several subclasses. FileComponent serves as the base class for template style-components, and ModuleComponent the base for module-based components.
</p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.component_Component"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Component(object)</span>
<div class="sectiontext">
<p>
Base class for all components. the primary method is the run() method which executes the Component in the context of a particular request. A Component instance is usually cached in memory based on its component ID and can execute many requests simultaneously.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def __init__"></a>
<b>def __init__(<i>self</i>, <i>interpreter</i>, <i>component_source</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
initializes a new Component. this method is called by the Interpreter.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def attribute_exists"></a>
<b>def attribute_exists(<i>self</i>, <i>key</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_attributes = property()"></a>
<b>attributes = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def call_method"></a>
<b>def call_method(<i>self</i>, <i>method_name</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
calls a method SubComponent of the given name on this component. This amounts to locating it via locate_inherited_method, retrieving the current request via request.instance(), and then calling execute_component on that request.</p>
<p>See also m.comp("component:methodname")</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def component_init"></a>
<b>def component_init(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
initializes the component after construction. Calls the do_component_init() method before setting up the component's arguments.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_dir_name = property()"></a>
<b>dir_name = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
relative directory name of the component
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def do_component_init"></a>
<b>def do_component_init(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
overridden by subclasses to perform per-instance initialization steps.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def do_run_component"></a>
<b>def do_run_component(<i>self</i>, <i>m</i>, <i>ARGS</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
overridden by subclasses to provide the main execution body of the component.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def do_thread_init"></a>
<b>def do_thread_init(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
overridden by subclasses to provide a per-thread initialization routine.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_file = property()"></a>
<b>file = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
the actual filename of the component, if one exists
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_attribute"></a>
<b>def get_attribute(<i>self</i>, <i>key</i>, <i>inherit=True</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_attributes"></a>
<b>def get_attributes(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_dir_name"></a>
<b>def get_dir_name(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_file"></a>
<b>def get_file(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_flag"></a>
<b>def get_flag(<i>self</i>, <i>key</i>, <i>inherit=False</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns a flag defines in this component's <%flags> section.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_id"></a>
<b>def get_id(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_name"></a>
<b>def get_name(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_owner"></a>
<b>def get_owner(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_parent_component"></a>
<b>def get_parent_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_path"></a>
<b>def get_path(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def get_source_id"></a>
<b>def get_source_id(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def get_sub_component"></a>
<b>def get_sub_component(<i>self</i>, <i>name</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns a SubComponent of the given name, represented within the source of this Component.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def has_filter"></a>
<b>def has_filter(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if this component defines a <%filter> section.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_id = property()"></a>
<b>id = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
unique identifier for this component
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def is_file_component"></a>
<b>def is_file_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def is_method_component"></a>
<b>def is_method_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def is_module_component"></a>
<b>def is_module_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def is_sub_component"></a>
<b>def is_sub_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def locate_inherited_method"></a>
<b>def locate_inherited_method(<i>self</i>, <i>method_name</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns a method SubComponent of the given name, represented either within the source of this Component or within the source of an inherited Component, i.e. the inheritance hierarchy will be searched for the approrpriate method call.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_name = property()"></a>
<b>name = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
name of this component
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_path = property()"></a>
<b>path = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
relative full path of the component
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def run"></a>
<b>def run(<i>self</i>, <i>request</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
runs this component in the context of the given request. **params are the arguments sent to the component, which become ARGS in the context of the component's runtime environment.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_def scall_method"></a>
<b>def scall_method(<i>self</i>, <i>method_name</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
same as call_method, but returns the component output as a string See also m.scomp("component:methodname")</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def set_attribute"></a>
<b>def set_attribute(<i>self</i>, <i>key</i>, <i>value</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_Component_source_id = property()"></a>
<b>source_id = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
unique identifier for the ComponentSource of this component
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_Component_def use_auto_flush"></a>
<b>def use_auto_flush(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if this component defines the "autoflush" flag as True, or if an inherited component defines this flag.
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.component_FileComponent"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class FileComponent(Component)</span>
<div class="sectiontext">
<p>
a component that corresponds to a Myghty template file
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.component_FileComponent_def __init__"></a>
<b>def __init__(<i>self</i>, <i>interpreter</i>, <i>component_source</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_FileComponent_def get_sub_component"></a>
<b>def get_sub_component(<i>self</i>, <i>name</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_FileComponent_def is_file_component"></a>
<b>def is_file_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_FileComponent_def locate_inherited_method"></a>
<b>def locate_inherited_method(<i>self</i>, <i>method_name</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_FileComponent_parent_component = property()"></a>
<b>parent_component = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the parent component of this component, taking into account the component's inherit flag as well as the interpreter's autohandler properties
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_FileComponent_def uses_request_local"></a>
<b>def uses_request_local(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_FileComponent_def uses_thread_local"></a>
<b>def uses_thread_local(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.component_HTTPModuleComponent"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class HTTPModuleComponent(ModuleComponent)</span>
<div class="sectiontext">
<p>
A ModuleComponent that contains methods specific to a generic HTTP request.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.component_HTTPModuleComponent_def do_get"></a>
<b>def do_get(<i>self</i>, <i>m</i>, <i>r</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_HTTPModuleComponent_def do_post"></a>
<b>def do_post(<i>self</i>, <i>m</i>, <i>r</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_HTTPModuleComponent_def do_run_component"></a>
<b>def do_run_component(<i>self</i>, <i>m</i>, <i>r</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.component_ModuleComponent"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ModuleComponent(Component)</span>
<div class="sectiontext">
<p>
A component that is a regular Python class inside of a plain Python module.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def __init__"></a>
<b>def __init__(<i>self</i>, <i>interp</i>, <i>component_source</i>, <i>owner=None</i>, <i>do_init=True</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def component_init"></a>
<b>def component_init(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def do_component_init"></a>
<b>def do_component_init(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def do_run_component"></a>
<b>def do_run_component(<i>self</i>, <i>m</i>, <i>ARGS</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def is_module_component"></a>
<b>def is_module_component(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_ModuleComponent_def locate_inherited_method"></a>
<b>def locate_inherited_method(<i>self</i>, <i>method_name</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_ModuleComponent_name = property()"></a>
<b>name = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_ModuleComponent_owner = property()"></a>
<b>owner = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.component_SubComponent"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class SubComponent(Component)</span>
<div class="sectiontext">
<p>
a component that corresponds to a <%def> or <%method> tag inside a file-based component.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.component_SubComponent_def __init__"></a>
<b>def __init__(<i>self</i>, <i>name</i>, <i>owner</i>, <i>is_method</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_SubComponent_def call_method"></a>
<b>def call_method(<i>self</i>, <i>*args</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_SubComponent_def get_sub_component"></a>
<b>def get_sub_component(<i>self</i>, <i>name</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_SubComponent_id = property()"></a>
<b>id = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
:
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_SubComponent_def locate_inherited_method"></a>
<b>def locate_inherited_method(<i>self</i>, <i>method_name</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_SubComponent_name = property()"></a>
<b>name = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_SubComponent_owner = property()"></a>
<b>owner = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.component_SubComponent_parent_component = property()"></a>
<b>parent_component = property()</b></td>
</td><td></td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.component_SubComponent_def scall_method"></a>
<b>def scall_method(<i>self</i>, <i>*args</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<A name="docstrings_myghty.interp"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.interp</span>
<div class="sectiontext">
<p>
The interp package and its primary class, Interpreter, represents the runtime environment for Myghty components. It serves as a "home base" for configuration information and request construction, and also assists the Request object in locating components. The Interpreter maintains a pool of component objects and handles, at a high level, their compilation and filesystem representation.
</p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.interp_Interpreter"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Interpreter</span>
<div class="sectiontext">
<p>
Represents an environment in which to create requests, compile and execute components.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def __init__"></a>
<b>def __init__(<i>self</i>, <i>attributes=None</i>, <i>data_dir=None</i>, <i>compiler=None</i>, <i>resolver=None</i>, <i>request=None</i>, <i>code_cache_size=16777216</i>, <i>use_auto_handlers=True</i>, <i>use_object_files=True</i>, <i>debug_file=BufferDecorator, enclosing <open file '<stderr>', mode 'w' at 0x403810d0>.</i>, <i>debug_threads=False</i>, <i>debug_elements=[]</i>, <i>escapes={}</i>, <i>global_args=None</i>, <i>auto_handler_name='autohandler'</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
constructs a new Interpreter object. All Myghty configuration parameters are sent to this method as keyword parameters. Those parameters that are used directly by this Interpreter are consumed. Remaining arguments are sent off to other constructed objects, which include a Compiler, a Resolver, and a Request prototype object.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def component_exists"></a>
<b>def component_exists(<i>self</i>, <i>path</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if the given path can be resolved to a ComponentSource instance,
i.e. if a component can be loaded for this path.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def debug"></a>
<b>def debug(<i>self</i>, <i>message</i>, <i>type=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
writes a debug message to the debug file. the optional type string refers to a "debug_element" type,
i.e. 'resolution', 'cache', etc. which will only write a message if that debug_element was enabled with this Interpreter.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def execute"></a>
<b>def execute(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
executes the given component with the given request construction arguments.
The component can be a string path which will be resolved, or a Component object.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def get_attribute"></a>
<b>def get_attribute(<i>self</i>, <i>key</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
gets an attribute from this Interpreter. deprecated, use the "attributes"
member directly instead.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def get_attributes"></a>
<b>def get_attributes(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns the attributes dictionary for this Interpreter. deprecated, use the "attributes" member directly instead.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def get_compiled_component"></a>
<b>def get_compiled_component(<i>self</i>, <i>csource</i>, <i>always_recompile=False</i>, <i>recompile_newer=True</i>, <i>use_file=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
used by load_component to deliver a new Component object from a ComponentSource.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def get_component_object_files"></a>
<b>def get_component_object_files(<i>self</i>, <i>component_source</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns a tuple containing the full paths to the .py, .pyc, and .pyo files corresponding to the given FileComponentSource object.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def load"></a>
<b>def load(<i>self</i>, <i>path</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
resolves and loads the component specified by the given path. **params is a set of keyword arguments passed to the resolution system.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def load_component"></a>
<b>def load_component(<i>self</i>, <i>csource</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
loads the component corresponding to the given ComponentSource object. This can be any subclass of ComponentSource. If the component was already loaded and exists within this Interpreter's code cache, returns the existing Component. If the Component has been modified at its source, it will re-load or re-compile the Component as needed.
If this Component has not been loaded, it will import or compile the Component as needed.
This operation is also synchronized against other threads. On systems that support file-locking it is synchronized against other processes as well.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def load_module_component"></a>
<b>def load_module_component(<i>self</i>, <i>raise_error=True</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
resolves and loads a module component specified within the given keyword parameters. The keyword parameters are passed directly to myghty.csource.ModuleComponentSource. The easiest way to use this method is to pass the keyword parameter "arg", which references a string in the form "<modulename>:<callable_or_class>", where <modulename> is a regular Python module to be loaded via __import__, and <callable_or_class> is the dotted path to either a callable object inside the module or a class inside the module which subclasses myghty.component.ModuleComponent.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def make_component"></a>
<b>def make_component(<i>self</i>, <i>source</i>, <i>id=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
creates an in-memory template Component given its source as a string...this can be any Myghty template that would ordinarily be compiled from the filesystem. the optional "id" string parameter is used to identify this component within this Interpreter's code cache. If not given, one will be generated.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def make_request"></a>
<b>def make_request(<i>self</i>, <i>component</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
creates a new request with the given component and request construction arguments.
The request is copied from an existing request instance, overriding its parameters with those given. The returned request is executed by calling its execute() method.
The component can be a string path which will be resolved when the request is executed, or a Component object.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def raise_error"></a>
<b>def raise_error(<i>self</i>, <i>error</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
raises an Interpreter error with the given message string.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.interp_Interpreter_def resolve_component"></a>
<b>def resolve_component(<i>self</i>, <i>path</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
resolves the component specified by the given path. a myghty.resolver.Resolution object is returned containing a myghty.csource.ComponentSource reference.
Raises ComponentNotFound by default if the path cannot be resolved. **params is a set of keyword parameters sent directly to the resolve() method on myghty.resolver.Resolver.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.interp_Interpreter_def set_attribute"></a>
<b>def set_attribute(<i>self</i>, <i>key</i>, <i>value</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
sets an attribute on this Interpreter. deprecated, use the "attributes"
member directly instead.
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<A name="docstrings_myghty.resolver"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.resolver</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.resolver_AdjustedResolveFile"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class AdjustedResolveFile(ResolveFile)</span>
<div class="sectiontext">
<p>
a ResolveFile rule that adds a pre-path-concatenation adjustment step, so the uri can be translated before determining the file path. unlike path_translate, this translated uri is only used to determine a filesystem path, and is not propigated anywhere else.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_AdjustedResolveFile_def __init__"></a>
<b>def __init__(<i>self</i>, <i>adjust</i>, <i>*component_roots</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_Conditional"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Conditional(ResolverRule)</span>
<div class="sectiontext">
<p>
conditionally executes a rule, only executes if the uri matches a certain regexp,
or a passed-in context string matches one of the contexts set up for this rule.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_Conditional_def __init__"></a>
<b>def __init__(<i>self</i>, <i>rule</i>, <i>regexp=None</i>, <i>context=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_Conditional_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>resolver_context=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_Conditional_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_Conditional_def test_condition"></a>
<b>def test_condition(<i>self</i>, <i>uri</i>, <i>resolver_context</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ConditionalGroup"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ConditionalGroup(Conditional)</span>
<div class="sectiontext">
<p>
combines a Conditional and a Group to make a conditionally-executing Group.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ConditionalGroup_def __init__"></a>
<b>def __init__(<i>self</i>, <i>regexp=None</i>, <i>context=None</i>, <i>rules=[]</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_Group"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Group(ResolverRule)</span>
<div class="sectiontext">
<p>
creates a subgroup of resolver strategies.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_Group_def __init__"></a>
<b>def __init__(<i>self</i>, <i>rules=[]</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_Group_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_Group_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_NotFound"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class NotFound(ResolverRule)</span>
<div class="sectiontext">
<p>
returns not found. place at the bottom of Group and Match chains to have them terminate.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_NotFound_def __init__"></a>
<b>def __init__(<i>self</i>, <i>silent=False</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
silent = True indicates that a resulting TopLevelNotFound exception should be 'silent', i.e.
not logged. this is used when a 404 error is being propigated to another application layer.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_NotFound_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_PathTranslate"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class PathTranslate(ResolverRule)</span>
<div class="sectiontext">
<p>
performs path translation rules on the given uri and sends control off to the next rule.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_PathTranslate_def __init__"></a>
<b>def __init__(<i>self</i>, <i>*translations</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_PathTranslate_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_PathTranslate_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>path_translate=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_PathTranslate_def modifies_uri"></a>
<b>def modifies_uri(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolveDhandler"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolveDhandler(ResolverRule)</span>
<div class="sectiontext">
<p>
collects all the resolver rules below it and runs them for the requested uri, and if not found re-runs them again for the "dhandler" filename, pruning off path tokens until the root is reached.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolveDhandler_def __init__"></a>
<b>def __init__(<i>self</i>, <i>dhandler_name='dhandler'</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolveDhandler_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>enable_dhandler=False</i>, <i>declined_components=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolveFile"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolveFile(ResolverRule)</span>
<div class="sectiontext">
<p>
performs file based resolution. looks up files within one or more component roots.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolveFile_def __init__"></a>
<b>def __init__(<i>self</i>, <i>*component_roots</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolveFile_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolveFile_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>component_root=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolveModule"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolveModule(ResolverRule)</span>
<div class="sectiontext">
<p>
resolves a Module Component based on information in a given list of dictionaries,
containing regular expressions for keys which are matched against the URI. The value for each key references either a class, a callable object or function, or a string in the form "<module>:<path.to.callable>".
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolveModule_def __init__"></a>
<b>def __init__(<i>self</i>, <i>*module_components</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolveModule_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>context=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolveModule_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>module_components=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolvePathModule"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolvePathModule(ResolverRule)</span>
<div class="sectiontext">
<p>
resolves a callable object or class instance inside a module, based on a traversal of path tokens corresponding to the module's file location, and then of the object paths defined within the module.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolvePathModule_def __init__"></a>
<b>def __init__(<i>self</i>, <i>*module_roots</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolvePathModule_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>dhandler_path=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolvePathModule_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>module_root=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolveUpwards"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolveUpwards(ResolverRule)</span>
<div class="sectiontext">
<p>
takes the rules below it and applies "search upwards" logic to them, where it iteratively breaks off path tokens behind the filename and searches upwards until the root path is reached.
if require_context is True, then this rule only takes effect if "search_upwards" is sent within the resolution options.
this indicates that the upwards resolve is context-sensitive, and therefore should not be cached based on a URI alone. however, by default it allows its results to be cached since in practice its used strictly for autohandlers, which are always searched upwards.</p>
<p></p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolveUpwards_def __init__"></a>
<b>def __init__(<i>self</i>, <i>require_context=True</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolveUpwards_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>search_upwards=False</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_Resolver"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Resolver(object)</span>
<div class="sectiontext">
<p>
resolves incoming URIs against a list of rules, and returns Resolution objects and/or raises ComponentNotFound exceptions.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_Resolver_def __init__"></a>
<b>def __init__(<i>self</i>, <i>resolver_strategy=None</i>, <i>request_resolver=None</i>, <i>use_static_source=False</i>, <i>source_cache_size=1000</i>, <i>track_resolution_detail=True</i>, <i>debug_file=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_Resolver_def resolve"></a>
<b>def resolve(<i>self</i>, <i>uri</i>, <i>raise_error=True</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_ResolverRule"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ResolverRule(object)</span>
<div class="sectiontext">
<p>
base class for a single rule that attempts to resolve a uri into a Resolution object. acts inside a chain of ResolverRules where when a uri cannot be resolved,
the next rule in the chain is called in a continuation pattern.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolverRule_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
performs resolution or translation on the given path. "remaining" is an Iterator referencing an element in the full list of ResolverRule objects. the method either returns a Resolution object, or passes control to the next ResolverRule in the iterator.
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolverRule_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
called when the resolver first receives the new rule.
objects usually will want to do most of their initialization at this stage.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_ResolverRule_def init_resolver"></a>
<b>def init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_ResolverRule_def modifies_uri"></a>
<b>def modifies_uri(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
returns True if the rule makes a modification to the URI. if so, the URICache rule wont allow this rule to be cached as a single rule, since it becomes ineffective. As part of a cached chain is still OK.
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.resolver_URICache"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class URICache(ResolverRule)</span>
<div class="sectiontext">
<p>
caches the result of either a given nested rule, or the remaining rules in its chain, based on the incoming URI.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_URICache_def __init__"></a>
<b>def __init__(<i>self</i>, <i>source_cache_size=None</i>, <i>rule=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p>rule is a single ResolverRule (or Group) whos results will be cached on a per-uri basis. if rule is None, then the result of remaining rules in the current chain will be cached based on the incoming URI. This rule cannot be a PathTranslation rule or other uri-modifying rule, since the translated uri is not stored.
source_cache_size is the size of the LRUCache to create.
if source_cache_size is None, it will use the Resolver's source cache, sharing it with any other URICaches that also use the Resolver's source cache.
When using the Resolver's source cache, if the Resolver has use_static_source disabled, then caching is disabled in this URICache.</p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.resolver_URICache_def do"></a>
<b>def do(<i>self</i>, <i>uri</i>, <i>remaining</i>, <i>resolution_detail</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.resolver_URICache_def do_init_resolver"></a>
<b>def do_init_resolver(<i>self</i>, <i>resolver</i>, <i>remaining_rules</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<A name="docstrings_myghty.csource"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.csource</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.csource_ComponentSource"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ComponentSource(object)</span>
<div class="sectiontext">
<p>
a time-sensitive descriptor object for a Myghty component.
</p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_ComponentSource_def __init__"></a>
<b>def __init__(<i>self</i>, <i>id</i>, <i>last_modified=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
unique identifier of the component.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_ComponentSource_def can_compile"></a>
<b>def can_compile(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_ComponentSource_def get_component_source"></a>
<b>def get_component_source(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_ComponentSource_def get_component_source_file"></a>
<b>def get_component_source_file(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_ComponentSource_def get_object_code"></a>
<b>def get_object_code(<i>self</i>, <i>compiler</i>, <i>file</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
compiles the source of this component using the given compiler,
sending output to the given file
</p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.csource_FileComponentSource"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class FileComponentSource(ComponentSource)</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.csource_FileComponentSource_def __init__"></a>
<b>def __init__(<i>self</i>, <i>id</i>, <i>path_id</i>, <i>path</i>, <i>file_path</i>, <i>last_modified=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_FileComponentSource_def get_component_source"></a>
<b>def get_component_source(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_FileComponentSource_def get_component_source_file"></a>
<b>def get_component_source_file(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.csource_MemoryComponentSource"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class MemoryComponentSource(ComponentSource)</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_MemoryComponentSource_def __init__"></a>
<b>def __init__(<i>self</i>, <i>source</i>, <i>id=None</i>, <i>last_modified=None</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_MemoryComponentSource_def get_component_source"></a>
<b>def get_component_source(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_MemoryComponentSource_def get_component_source_file"></a>
<b>def get_component_source_file(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.csource_ModuleComponentSource"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ModuleComponentSource(ComponentSource)</span>
<div class="sectiontext">
<p>
represents a loadable module containing either a ModuleComponent class, a function, a class instance which is callable or a method on a class instance.
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.csource_ModuleComponentSource_def __init__"></a>
<b>def __init__(<i>self</i>, <i>arg=None</i>, <i>module=None</i>, <i>objpath=None</i>, <i>name=None</i>, <i>callable_=None</i>, <i>class_=None</i>, <i>last_modified=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_ModuleComponentSource_def can_compile"></a>
<b>def can_compile(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_ModuleComponentSource_def copy"></a>
<b>def copy(<i>self</i>, <i>use_static_source=False</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.csource_ModuleComponentSource_def inspect_target"></a>
<b>def inspect_target(<i>self</i>, <i>arg</i>, <i>objpath</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.csource_ModuleComponentSource_def reload"></a>
<b>def reload(<i>self</i>, <i>module</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.csource_ModuleComponentSourceSingleton"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class ModuleComponentSourceSingleton(type)</span>
<div class="sectiontext">
<p>
a metaclass for ModuleComponentSource which allows its constructor to cache the inspection results of the "arg" constructor parameter.
</p>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<A name="docstrings_myghty.session"></a>
<div class="subsection" style="margin-left:20px;">
<span class="sectionheadertext">Module myghty.session</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
</table>
</div>
<A name="docstrings_myghty.session_MyghtySessionArgs"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class MyghtySessionArgs</span>
<div class="sectiontext">
<p></p>
<p></p>
<table cellspacing="0">
<tr class="dark">
<td>
<A name="docstrings_myghty.session_MyghtySessionArgs_def __init__"></a>
<b>def __init__(<i>self</i>, <i>data_dir=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_MyghtySessionArgs_def clone"></a>
<b>def clone(<i>self</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_MyghtySessionArgs_def get_session"></a>
<b>def get_session(<i>self</i>, <i>request</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.session_Session"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class Session</span>
<div class="sectiontext">
<p>
session object that uses container package for storage
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def __init__"></a>
<b>def __init__(<i>self</i>, <i>request</i>, <i>id=None</i>, <i>invalidate_corrupt=False</i>, <i>use_cookies=True</i>, <i>type=None</i>, <i>data_dir=None</i>, <i>key='myghty_session_id'</i>, <i>timeout=None</i>, <i>cookie_expires=True</i>, <i>secret=None</i>, <i>log_file=None</i>, <i>namespace_class=None</i>, <i>**params</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_created = property()"></a>
<b>created = property()</b></td>
</td><td></td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
_creation_time
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def debug"></a>
<b>def debug(<i>self</i>, <i>message</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_def delete"></a>
<b>def delete(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
deletes the persistent storage for this session, but remains valid.
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def has_key"></a>
<b>def has_key(<i>self</i>, <i>key</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_def invalidate"></a>
<b>def invalidate(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
invalidates this session, creates a new session id, returns to the is_new state
</p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def iteritems"></a>
<b>def iteritems(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_def keys"></a>
<b>def keys(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def load"></a>
<b>def load(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
loads the data from this session from persistent storage
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_def lock"></a>
<b>def lock(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
locks this session against other processes/threads. this is automatic when load/save is called.
***use with caution*** and always with a corresponding 'unlock'
inside a "finally:" block,
as a stray lock typically cannot be unlocked without shutting down the whole application.</p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_Session_def save"></a>
<b>def save(<i>self</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
saves the data for this session to persistent storage
</p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_Session_def unlock"></a>
<b>def unlock(<i>self</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p>
unlocks this session against other processes/threads. this is automatic when load/save is called.</p>
<p>***use with caution*** and always within a "finally:" block,
as a stray lock typically cannot be unlocked without shutting down the whole application.</p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
<A name="docstrings_myghty.session_SignedCookie"></a>
<div class="subsection" style="margin-left:30px;">
<span class="sectionheadertext">Class SignedCookie(BaseCookie)</span>
<div class="sectiontext">
<p>
extends python cookie to give digital signature support
</p>
<table cellspacing="0">
<tr class="light">
<td>
<A name="docstrings_myghty.session_SignedCookie_def __init__"></a>
<b>def __init__(<i>self</i>, <i>secret</i>, <i>input=None</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="dark">
<td>
<A name="docstrings_myghty.session_SignedCookie_def value_decode"></a>
<b>def value_decode(<i>self</i>, <i>val</i>)</b></td>
</td>
</tr>
<tr class="dark">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
<tr class="light">
<td>
<A name="docstrings_myghty.session_SignedCookie_def value_encode"></a>
<b>def value_encode(<i>self</i>, <i>val</i>)</b></td>
</td>
</tr>
<tr class="light">
<td colspan="2"><div style="margin-left:15px;margin-bottom:5px;margin-top:5px">
<p></p>
<p></p>
</div>
</td>
</tr>
</table>
</div>
<a href="#docstrings" class="toclink">back to section top</a>
</div>
</div>
<hr width="400px" align="left" />
</div>
</div>
</div>
</div>
<center>
</center>
</body>
</html>
|