Changeset 4575
- Timestamp:
- 05/13/08 10:36:37 (2 months ago)
- Files:
-
- trunk/docs/2.0/BasicMoves.rst (modified) (8 diffs)
- trunk/docs/2.0/Contributing.rst (modified) (1 diff)
- trunk/docs/2.0/Deployment.rst (modified) (2 diffs)
- trunk/docs/2.0/DownloadInstall.rst (modified) (8 diffs)
- trunk/docs/2.0/Profile.rst (modified) (3 diffs)
- trunk/docs/2.0/QuickStart.rst (modified) (5 diffs)
- trunk/docs/2.0/RoughDocs/BootStrap.rst (modified) (3 diffs)
- trunk/docs/2.0/RoutesIntegration.rst (modified) (4 diffs)
- trunk/docs/2.0/SimpleWidgetForm.rst (modified) (2 diffs)
- trunk/docs/2.0/ToolBox.rst (modified) (1 diff)
- trunk/docs/2.0/ToscaWidgets/Using.rst (modified) (1 diff)
- trunk/docs/2.0/Wiki20/JSONMochiKit.rst (modified) (3 diffs)
- trunk/INSTALL.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docs/2.0/BasicMoves.rst
r4556 r4575 1 2 3 4 1 5 TurboGears 2 at a glance 2 6 =========================== 3 7 4 :Status: Work in progres s8 :Status: Work in progres 5 9 6 TurboGears 2, like TurboGears 1 and many other modern web frameworks, uses a 7 pattern called "Model View Controller", or "MVC" pattern. Basically the MVC 8 pattern is an attempt to separate the code which handles what the user sees 9 (the view) from the code that responds to user actions (the controller) and 10 code that changes the state of data (the model). 10 TurboGears 2, like TurboGears 1 and many other modern web frameworks, uses a pattern called "Model View Controller", or "MVC" pattern. Basically the MVC pattern is an attempt to separate the code which handles what the user sees (the view) from the code that responds to user actions (the controller) and code that changes the state of data (the model). 11 11 12 The goal of the MVC pattern is to help you create more flexible software, 13 and since web-applications tend to have more user-interface changes than 14 anything else, it's particularly designed so that you can change the `view` 15 code without necessarily having to change anything else. 12 The goal of the MVC pattern is to help you create more flexible software, and since web-applications tend to have more user-interface changes than anything else, it's particularly designed so that you can change the `view` code without necessarily having to change anything else. 16 13 17 You have to follow the tutorial `quickstart a project <QuickStart>`_ and serve 18 the project first. If you want to be consistent with the code seen here, call 19 your quickstarted project *helloworld*. If not, you'll just need to update 20 the imports in the code, because you'll have a different module name. 21 22 Then we can play around a little bit with TurboGears 2 and see how it works. 14 You have to follow the tutorial `quickstart a project <QuickStart>`_ and serve the project first. 15 Then we could exam some basic moves the you could do with TurboGears 2. 23 16 24 17 … … 26 19 ------------------------------- 27 20 28 Let's take advantage of that fact and make update our view with a Hello World 29 headline. 21 Let's take advantage of that fact and make update our view with a Hello World headline. 30 22 31 To keep the tutorial small and simple, we make a assumption that you already 32 have some knowledge about html tags. 23 To keep the tutorial small and simple, we make a assumption that you already have some knowledge about html tags. 33 24 34 Edit helloworld/templates/index.html, add a <h1> tag at the top of the body 35 like this: 36 37 .. code-block:: html 25 Edit helloworld/templates/index.html, add a <h1> tag like this:: 38 26 39 27 ... 40 28 <body> 41 <h1>Hello World</h1> 42 ... 29 <h1>Hello World</h1> 43 30 </body> 44 31 ... 45 32 46 You can now point your browser at http://localhost:8080 to see the change. 47 You should see "Hello, world!" text in h1 size. 33 Of course you should add <h1> tag somewhere in the body of the template, to make the template as a valid HTML file. 48 34 49 .. note :: Beware to keep the declare description at the top of template file, they will be used in the default template engine (genshi):: 35 You can now point your browser at http://localhost:8080 to see the change. You should see "Hello, world!" text in h1 size. 50 36 51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">52 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" xmlns:xi="http://www.w3.org/2001/XInclude">53 37 54 38 Hello World using static file 55 39 -------------------------------- 56 40 57 Open a new file, edit the content as a simple html file: 41 Open a new file, edit the content as a simple html file:: 58 42 59 .. code-block:: html 60 61 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" xmlns:xi="http://www.w3.org/2001/XInclude"> 62 <body> 63 <h1>Hello World</h1> 64 </body> 43 <html> 44 <body> 45 <h1>Hello World</h1> 46 </body> 65 47 </html> 66 48 67 and save it to helloworld/public/hello.html. You can then just browse to 68 http://localhost:8080/hello.html and see the page you made. In general 69 TG2 users are advised to put static html, css, and javascript files in 70 the public/static directories provided by the quickstart project. This 71 allows you to later set up a front end server (such as apache, or nginx) to 72 serve up those files directly, without requiring any work from your TurboGears 73 app. 49 and save it to helloworld/public/hello.html. 50 51 Browse http://localhost:8080/hello.html and see the page. 74 52 75 53 76 Hello World using just thecontroller77 ------------------------------- ------54 Hello World using controller 55 ------------------------------- 78 56 79 The controller defines how the server responds to user actions. In the case 80 of a web framework this almost always means HTTP requests of some kind ( 81 either directly initiated by the user/browser, or as fired off by javascript 82 as part of an Ajax app). 57 The controller defines how the server responds to user actions. In the case of a web framework this almost always means HTTP requests of some kind (either directly initiated, or fired of by javascript as part of an Ajax app). 83 58 84 TurboGears 2 uses an *Object Transversal* system to determine what controller 85 method will be called for a particular URL. Basically you have RootController, 86 with @exposed objects which define your URL hierarchy. This means that the 87 index method of your RootController is called when you go to /index (or even 88 just /). 89 We can tell our controller to respond at a new URL by defining a new method. 59 TurboGears 2 uses an `Object Publishing` system to determine what controller method will be called for a particular URL. Basically you have RootController, with @exposed objects which define your URL hierarchy. This means that the index method of your RootController is called when you go to /index (or even just /). We can tell our controller to respond at a new URL by defining a new method. 90 60 91 In this case we will add a new method called hello, which just returns a 92 string, which will be returned to the browser directly, without being 93 rendered through a template. 61 In this case we will add a new method called hello, which just returns a string. TG2 allows us to bypass the template process and return a string directly to the http response, which will be returned to the browser directly. 94 62 95 Edit controller/root.py: 63 Edit controller/root.py:: 96 64 97 .. code-block:: python 98 99 from helloworld.lib.base import BaseController 65 from my-project-name.lib.base import BaseController 100 66 from tg import expose 101 67 … … 108 74 return "Hello World from the controller" 109 75 110 111 76 Browse http://localhost:8080/hello to see the change. 112 77 … … 115 80 ----------------------------------------------- 116 81 117 So far we're getting somewhere, we've been returning plaintext for every 118 incoming request. But you might have noticed how the default welcome page work. 82 So far we're getting somewhere, we've been returning plaintext for every incoming request. But you might have noticed how the default welcome page work. 119 83 120 We can edit index template, use controllers to define new url's. But let's 121 take it one step further and create yet another new URL, plug plug real 122 templates into the controllers, and this time rather than returning a string, 123 we'll return a dictionary: 124 125 .. code-block:: python 84 We can edit index template, use controllers to define new url's. But let's take it one step further and create yet another new URL, plug plug real templates into the controllers, and this time rather than returning a string, we'll return a dictionary:: 126 85 127 86 from helloworld.lib.base import BaseController … … 137 96 138 97 139 TurboGears sees that the controller returned a dict, and that there's an 140 template name defined in the @expose decorator, and renders that template, 141 turning the elements of the dictionary into local variables in the template's 142 namespace. 98 TurboGears sees that the controller returned a dict, and that there's an template name defined in the @expose decorator, and renders that template, turning the elements of the dictionary into local variables in the template's namespace. 143 99 144 For each page on your site, you could give each of them the corresponding 145 template in your controllers. You could specifying the template argument 146 with``@expose`` decorator. 100 For each page on your site, you could give each of them the corresponding template in your controllers. You could specifying the template argument with``@expose`` decorator. 147 101 148 That means that we've now got a 'hello' variable in our Genshi template which 149 we can use, and we attach the template 'helloworld.templates.index' to 150 'new_hello' method. So let's edit helloworld/template/index.html to replace 151 the h1 tag we added earlier with: 152 153 .. code-block:: html 102 That means that we've now got a 'hello' variable in our template which we can use, and we attach the template 'helloworld.templates.index' to 'new_hello' method. So let's edit helloworld/template/index.html to replace the h1 tag we 103 added earlier with:: 154 104 155 105 <h1 py:replace="hello">hello</h1> … … 157 107 Browse http://localhost:8080 to see the change. 158 108 159 Hello from another controller 160 _______________________________________ 109 TurboGears 2 uses the Genshi templating system by deault for controlling dynamic content in your markup. 110 Template arguments are used to pass variables and other dynamic content to the template. 161 111 162 Perhaps we don't want hello world to happen from the root of our site, 163 and perhaps we want to make a lot of modifications to the template 164 that renders our view. In that case, let's create and publish 165 a new controller method, with a new template. 112 To create more skeletons for your templates, just copy the default index.html template that was generated when your project was created. 166 113 167 For now let's just create a new skeleton for our template, by copying168 the default index.html template that was generated when our project169 was created.170 114 171 Let's call the new template hello.html, and put it in the templates 172 directory with index.html. 173 174 Of course, not every template has dynamic content and therefore 175 may not need arguments passed in by the controller. In that case, 176 we can just return an empty dictionary, like this: 177 178 .. code-block:: python 115 Not every template has dynamic content and therefore may not need arguments. In that case, just return an empty dictionary:: 179 116 180 117 @expose(template="helloworld.templates.index") 181 def hello(self):118 def index(self): 182 119 return dict() 183 184 If you browse to http://localhost:8080/hello you'll see the result:185 186 http://localhost:8080187 188 .. image:: ../_static/hello-oops.jpg189 120 190 121 Oops, we made a mistake! We're trying to use variables in index.html … … 193 124 TG2 gives you when you get a python exception in your code. 194 125 195 This gives you an opportunity to explore the full stack trace interactively. 196 If you click on the little + icon, you can see what local variables are set 197 at that frame in the call stack, and you can even use the >>> prompt to type 198 in some python code to test what's happening at that level. 126 TODO: Insert screenshot here. 127 128 This gives you an opportunity to explore the full stack trace interactively. If you click on the little + icon, you can see what local variables are set at that frame in the call stack, and you can even use the >>> prompt to type in some python code to test what's happening at that level. 199 129 200 In this case, we can see that there are some issues with an undefined hello 201 variable. Which we just added in the last step. 202 203 That's easy enough to fix let's just return that variable: 204 205 .. code-block:: python 206 207 @expose(template="helloworld.templates.index") 208 def hello(self): 209 return dict(hello='hello') 130 In this case, we can see that there are some issues with.... 210 131 211 132 212 133 Hello World using flash 213 --------------------------- 134 -------------------------------- 214 135 215 The master template we've defined provides yet another way to get a message to 216 the next template that's rendered. It automatically looks for a "flash" message 217 and displays it for you. 218 219 This is particularly useful if you don't know which page will be rendered next 220 or you just want to let the user know that some action they performed was 221 successful. 222 223 It's easy enought to use the flash feature. Just edit controller/root.py and 224 change the existing 'flash' statement to:: 136 Edit controller/root.py. Change the 'flash' statement to:: 225 137 226 138 flash("Hello World") … … 228 140 Browse http://localhost:8080 to see the change. 229 141 230 Well, that's Hello World. Hopefully we've given you a quick introduction to231 the TG2 environment, and helped you to understand the MVC archetecture a bit.232 142 233 If you have any questions feel free to stop by the IRC channel (#turbogears234 on freenode) or ask questions on the mailing list (urbogears@googlegroups.com).235 143 236 Feel free to play around a bit, and then feel free to look into the Wiki 20237 tutorial which should help you take your TurboGears skills to the next level.238 trunk/docs/2.0/Contributing.rst
r4396 r4575 1 ##This is an official page. Only editors and admins can change it. 2 3 4 1 5 Contributing to TurboGears 2 6 ========================== 7 8 :status: Official 9 10 .. contents:: 11 :depth: 2 3 12 4 13 If you want to help out, we want to help you help out! The goal of this trunk/docs/2.0/Deployment.rst
r4396 r4575 12 12 13 13 paster serve production.ini 14 15 Of course that assumes you already have a producton.ini.16 17 If you don't you can create one with a simple command::18 19 $ paster make-config wiki production.ini20 21 You can find out how to control what is produced by the 'paster make-config' command by reading Packaging and Deployment.22 14 23 15 But it's also likely that you may want to automatically restart your TG2 app if the server reboots, or you may want to set it up as a windows service. Unfortunately these thing can be very operating system specific, but fortunately they aren't TG2 specific. … … 64 56 65 57 * http://docs.turbogears.org/1.0/Deployment 66 * Packaging and Deployment http://wiki.pylonshq.com/display/pylonsdocs/Packaging+and+Deployment67 * Running Pylons apps with Webservers http://wiki.pylonshq.com/display/pylonsdocs/Running+Pylons+apps+with+Webservers68 * custom error page http://wiki.pylonshq.com/display/pylonsdocs/Interactive+Application+Debuggi69 58 70 59 trunk/docs/2.0/DownloadInstall.rst
r4568 r4575 1 How to install TurboGears 2 1 2 3 How to install TurboGears 2 2 4 ============================= 3 5 … … 5 7 6 8 We do expect to have a technology preview release sometime soon, and that should provide a clear picture of the TurboGears 2 stack, and a slightly more stable API. However, if you want API stability and good documentation, you may want to consider building your application on TurboGears 1 and porting it to TG2 after it is officially released. 9 10 Prerequisites: 11 ----------------------- 12 * gcc 13 * python 14 * appropriate python development package (python*-devel python*-dev) 7 15 8 16 Installing Pylons: … … 33 41 To tell setuptools to use the version you are editing in the Pylons directory:: 34 42 35 $ cd Pylons 43 $ cd Pylons 36 44 $ python setup.py develop 37 45 … … 51 59 52 60 $ cd .. 53 $ svn co http://svn.turbogears.org/projects/tg.devtools/trunk tgdev 54 $ svn co http://svn.turbogears.org/trunk tg2 61 $ svn co http://svn.turbogears.org/projects/tg.devtools/trunk tgdev 62 $ svn co http://svn.turbogears.org/trunk tg2 55 63 $ svn co http://svn.turbogears.org/projects/tgrepozewho/trunk tgrepozewho 56 57 And then install Paver which manages TG2's build::58 59 easy_install Paver60 64 61 65 tg2 package is TurboGears 2 core. Others are paster command plugins to create default template, admin interface, and migrations. … … 65 69 Install tgrepozewho:: 66 70 67 $ cd tgrepozewho 71 $ cd tgrepozewho 68 72 $ python setup.py develop 69 73 70 74 Install TurboGears 2 server:: 71 75 72 $ cd .. 73 $ cd tg2 74 $ p averdevelop76 $ cd .. 77 $ cd tg2 78 $ python setup.py develop 75 79 76 80 Install TurboGears 2 developer tools:: 77 81 78 $ cd .. 79 $ cd tgdev 82 $ cd .. 83 $ cd tgdev 80 84 $ python setup.py develop 81 85 82 86 Then you have installed TurboGears 2. 83 87 84 .. note:: if you have installed old dependency packages, you could remove them from ``{python_path}/site-packages/easy_install.pth`` 88 .. note:: if you have installed old dependency packages, you could remove them from:: 89 90 {python_path}/site-packages/easy_install.pth 91 85 92 86 93 Validate the installation: … … 95 102 Paster has replaced the old tg-admin command, and most of the tg-admin commands have now been reimplemented as paster commands. For example, "tg-admin quickstart" command has changed to "paster quickstart" command, and "tg-admin info" command has changed to "paster tginfo" command. 96 103 97 Be sure to check out our `What's new in TurboGears 2.0 < 2.0/RoughDocs/WhatsNew>`_ page to get a picture of what's changed in TurboGears2 so far.104 Be sure to check out our `What's new in TurboGears 2.0 <RoughDocs/WhatsNew>`_ page to get a picture of what's changed in TurboGears2 so far. 98 105 99 106 Troubleshooting … … 105 112 106 113 . $ sudo easy_install -U -f http://toscawidgets.org/download/wo_speedups/ RuleDispatch 107 108 114 If you get the following error when starting a project with ``paster serve``:: 109 115 110 116 . AttributeError: 'WSGIRequest' object has no attribute 'accept_language' 111 112 117 update your Pylons checkout with ``hg update`` and try again. 113 118 … … 146 151 $ cd RuleDispatch-0.5a0.dev-r2306 147 152 $ python setup.py develop 148 153 154 If you get this error about webhelpers, you need the latest version from mercurial:: 155 156 $ hg clone https://www.knowledgetap.com/hg/webhelpers 157 $ cd webhelpers 158 $ python setup.py develop trunk/docs/2.0/Profile.rst
r4396 r4575 1 ## Please see the page "DocHelp" for guidelines on contributing TurboGears documentation! 2 3 4 1 5 Profiling your app 2 6 ================== 3 7 4 8 :Status: Work in progress 9 10 .. contents:: Table of Contents 11 :depth: 2 12 5 13 6 14 TurboGears does not come with a built-in profiler, but an easy to use WSGI application profiler is just an easy_install away! … … 22 30 --------------------------- 23 31 24 Just fire up a browser or functional test-runner like twill, or ab (apache bench).The repoze.profile middleware will profile everything above it in the WSGI stack.32 Just fire up a browser (or functional test-runner like twill, ab (apache bench), or whatever). The repoze.profile middleware will profile everything above it in the WSGI stack. 25 33 26 34 … … 28 36 --------------------------- 29 37 30 There's a built in web based view of your profile data available if you browse to??? 38 There's a built in web based view of your profile data available.... 39 40 31 41 32 42 Reference: trunk/docs/2.0/QuickStart.rst
r4562 r4575 1 2 3 1 4 Quickstarting a TurboGears 2 project 2 5 ==================================== … … 4 7 :Status: Work in progres 5 8 9 .. contents:: Table of Contents 10 :depth: 2 6 11 7 Once you've got TurboGears 2 installed, you probably want to try it out. To8 make setting up a new project very quick, TurboGears 2 extends the 'paster'9 command line tool to provide a suite of tools for working with TurboGears 210 projects. A few will be touched upon in this tutorial, check the 'paster --help'11 command for a full listing.12 12 13 The first paster tool you'll need is 'quickstart', which initializes a 14 TurboGears 2 project. 13 Now that you've got TurboGears installed. TurboGears 2 extends the 'paster' command line tool to provide a suite of tools for working with TurboGears 2 projects. A few will be touched upon in this tutorial, check the 'paster --help' command for a full listing. 15 14 16 To use it go to whatever directory you want your project to be in, and type:: 15 The very first tool you'll need is 'paster quickstart', which initializes a TurboGears 2 project. 16 You can go to whatever directory you want and start a new turbogears 2 project by typing:: 17 17 18 18 $ paster quickstart Helloworld 19 19 20 The 'paster quickstart' command will create a basic project directory for you to 21 use to get started on your TurboGears 2 application. You'll be prompted for the 22 name of the project (this is the pretty name that human beings would appreciate), 23 and the name of the package (this is the less-pretty name that Python will like). 24 25 For the identity prompt, answer 'no' (or press 'Enter' key directly), since we'll keep this tutorial fairly simple, but when you need users/passwords in a future project, you'll want to look up the identity management tutorial. 20 So 'paster quickstart' command will create a basic project directory for you to use to get started on your TurboGears 2 application. You'll be prompted for the name of the project (this is the pretty name that human beings would appreciate), and the name of the package (this is the less-pretty name that Python will like). 26 21 27 22 Here's what our choices for this tutorial look like:: … … 29 24 Enter project name: Helloworld 30 25 Enter package name [helloworld]: helloworld 31 Do you need Identity (usernames/passwords) in this project? [no]32 26 ...output... 33 27 34 This will create a new directory which contains a few files in a directory tree, 35 with some code already set up for you. 28 This will create a new directory which contains a few files in a directory tree, with some code already set up for you. 36 29 37 30 Let's go in there and you can take a look around:: … … 39 32 $ cd helloworld 40 33 41 .. note:: you could type following command to check the full quickstart capabilities::42 43 $ paster quickstart --help44 34 45 35 Run the server 46 36 --------------- 47 37 48 At this point your project should be operational. To start your new TurboGears 2 49 app, cd into the new directory ( helloworld ) and issue the second paster 50 command 'paster serve' to serve your new application:: 38 At this point your project should be operational. To start your new TurboGears 2 app, cd into the new directory ( helloworld ) and issue the second paster command 'paster serve' to serve your new application:: 51 39 52 40 $ paster serve development.ini 53 41 54 As soon as that's done. Point your browser at http://localhost:8080/, and 55 you'll see a nice welcome page with the inform(flash) message and current time. 42 As soon as that's done. Point your browser at http://localhost:8080/, and you'll see a nice welcome page with the inform(flash) message and current time. 56 43 57 .. note:: 44 If you're exploring TurboGears 2 after using TurboGears 1, you may notice that the old config file `dev.cfg` file is now `development.ini`. 45 And by default the 'paster serve' is not in auto-reload mode. 58 46 59 If you're exploring TurboGears 2 after using TurboGears 1, you may notice that 60 the old config file `dev.cfg` file is now `development.ini`. 61 62 Reload the server automatically 63 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 65 Also note that by default 'paster serve' is *not* in auto-reload mode. 66 67 If you want your application to auto-reload whenever you change a 68 source code file as was the default in a TurboGears 1's dev.fg, just add 69 a `--reload` option. So, to get reloading you'd just type this instead:: 47 If you also want your application to auto-reload whenever you change a source code file as was the default in a TurboGears 1's dev.fg, just add a `--reload` option. So, to get reloading you'd just type this instead:: 70 48 71 49 $ paster serve --reload development.ini … … 73 51 Then you could access http://localhost:8080 to view the running TurboGears app. 74 52 75 .. note:: you could type following command to check the full quickstart capabilities:: 53 If you take a look at the code that quickstart created, you'll see that there isn't much involved in getting up and running. 76 54 77 $ paster serve --help 55 In particular, you'll want to check out the files directly involved in displaying this welcome page: 78 56 79 Glancing the Source 80 -------------------- 57 * development.ini : The system configuration is laid on development.ini for development configuration 58 * helloworld/controllers/root.py is responsible to generate the welcome page. 59 * helloworld/templates/index.html is the template you view on the welcome screen. It's an standard XHTML with some simple namespaced attributes. You can even preview it directly by open it in your browser! Very designer-friendly. 60 * helloworld/public/ is the place to hold static files, such as pictures, javascript, or css files. 81 61 82 If you take a look at the code that quickstart created, you'll see that 83 there isn't much involved in getting up and running. 84 85 In particular, you'll want to check out the files directly involved in 86 displaying this welcome page: 87 88 * development.ini : The system configuration is laid on development.ini 89 for development configuration 90 * helloworld/controllers/root.py : The python file is responsible to generate the welcome page. 91 * helloworld/templates/index.html : The html template is the template you 92 view on the welcome screen. It's an standard XHTML with some simple 93 namespaced attributes. 94 You can even preview it directly by open it in your browser! Very 95 designer-friendly. 96 * helloworld/public/ : The place to hold static files, such as pictures, 97 javascript, or css files. 98 99 Change the server port 100 ~~~~~~~~~~~~~~~~~~~~~~~ 101 102 You could edit development.ini to change the default server port used by the 103 built-in web server:: 62 You could edit development.ini to change the default server port used by the built-in web server:: 104 63 105 64 [server:main] trunk/docs/2.0/RoughDocs/BootStrap.rst
r4562 r4575 56 56 -------------- 57 57 58 .. note:: the crud command should only work **inside** a project directory59 60 58 You could use paster command to create a customizable interface to Create, Read, Update, Delete records 61 59 (CRUD) based on model :: … … 72 70 $ paster crud -i id Movie MovieController 73 71 74 The command Create several files for you:72 The command Create several files 75 73 76 * controllers/moviecontroller.py 77 * controllers/movieform.py 78 * templates/moviecontroller/list.html 79 * templates/moviecontroller/show.html 80 * templates/moviecontroller/new_form.html 81 * templates/moviecontroller/edit_form.html 82 * templates/moviecontroller/master.html 74 * controllers/MovieController.py 75 * controllers/MovieForm.py 76 * templates/MovieController/list.html 77 * templates/MovieController/show.html 78 * templates/MovieController/form.html 83 79 84 80 Edit controllers/root.py:: … … 112 108 >>> from toscawidgets.widgets import forms 113 109 >>> dir(forms) 114 115 or runs paster tginfo command to browse all available widgets::116 117 $ paster tginfo118 110 119 111 112 trunk/docs/2.0/RoutesIntegration.rst
r4396 r4575 6 6 :Status: Work in progress 7 7 8 .. contents:: Table of Contents 9 :depth: 2 8 10 9 TurboGears2 does URL dispatch with a combination of TG1 style object dispatch, 10 and built in Routes integration. By default you don't need to think about 11 Routes at all, because the framework sets up a default route to your 12 RootController, which sees that the action is route, and does object dispatch 13 in the same way that TurboGears 1 did. 11 TurboGears2 does URL dispatch with a combination of TG1 style object dispatch, and built in Routes integration. By default you don't 12 need to think about Routes at all, because the framework sets up a default route to your RootController, which sees that the action is route, and does object dispatch in the same way that TurboGears 1 did. 14 13 15 But if you want to create special routes that overide Object Dispatch, you can 16 easily do that, just by providing your own function to setup the routes map. 17 TurboGears has a defaults module, which provides a make_default_route_map 18 function like this :: 14 But if you want to create special routes that overide Object Dispatch, you can easily do that, just by providing your own function to setup the routes map. TurboGears has a setup module, which provides a make_default_route_map function like this :: 19 15 20 16 from pylons import config … … 26 22 always_scan=config['debug']) 27 23 28 ## Replace the next line with your overides. Overides should generally 29 ## comebefore the default route defined below24 ## Replace the next line with your overides. Overides should generally come 25 ## before the default route defined below 30 26 # map.connect('overide/url/here', controller='mycontrller', action='send_stuff') 31 27 … … 35 31 return map 36 32 37 There's a single map.connect() call which sets up all urls (via the * wildcard) 38 assigns them to the URL param, and sends them to the RootController in the 39 root.py file in your project's controllers folder. The default environment.py 40 file in your config directory takes this and assigns it to make_map, which is 41 passed in as a configuration element to the RoutesMiddleware setup in 42 middleware.py.:: 33 There's a single map.connect() call which sets up all urls (via the * wildcard) assigns them to the URL param, and sends them to the RootController in the root.py file in your project's controllers folder. The default environment.py file in your config directory takes this and assigns it to make_map, which is passed in as a configuration element to the RoutesMiddleware setup in middleware.py.:: 43 34 44 35 # This setups up a set of default route that enables a standard … … 48 39 make_map = setup.make_default_route_map 49 40 50 To define your own custom routes, all you need to do is to replace this with 51 your own make_map implementation. If you want you can set up object dispatch 52 from places other than root.py, or even use routes to define all of your URLs. 53 If you are going to do object dispatch, make sure the controller that you 54 dispatch too inherits from TGController, since that's the controller that 55 knows how to do internal dispatch. 41 To define your own custom routes, all you need to do is to replace this with your own make_map implementation. If you want you can set up object dispatch from places other than root.py, or even use routes to define all of your URLs. If you are going to do object dispatch, make sure the controller that you dispatch too inherits from TGController, since that's the controller that knows how to do internal dispatch. 56 42 57 43 For more information about how to write routes, you might want to read: trunk/docs/2.0/SimpleWidgetForm.rst
r4370 r4575 1 ## This is a contributed page. You must be logged in to change it. 2 #acl EditorGroup:read,write Known:read,write All:read 3 1 4 2 5 … … 8 11 .. contents:: Table of Contents 9 12 :depth: 2 13 10 14 11 15 This tutorial introduces you to the widget form system by building a simple trunk/docs/2.0/ToolBox.rst
r4396 r4575 4 4 ========== 5 5 6 :Status: Work in progress 6 :Status: Work in progres 7 8 .. contents:: Table of Contents 9 :depth: 2 7 10 8 11 Goal 9 12 -------- 10 13 11 A platform to share "gadgets" designed to aid the development of various TurboGears projects.14 A platform to share gadgets which helps the development. 12 15 13 The toolbox uses an extensible plugin system, so that TG develoers can easily release their own ToolBox enabled gadgets on pypi. 16 Developer could release their own gadgets on pypi. 17 The gadgets will auto-plugged in TurboGears 2 toolbox through setuptools. 14 18 15 If a few simple steps are taken to register gadgets appropriately, as soon as a gadget is easy_installed it will be automatically plugged in TurboGears 2 toolbox via it's setuptools entry point.19 ToolBox itself is a TurboGears 2 Application. Developers could use the same skill as develop TurboGears 2 application to develop a toolbox Gadget. 16 20 17 The Toolbox and Toolbox gadgets are themselves TurboGears 2 Applications. So, anybody who can write a TG2 application, can with a little extra work create toolbox gadgets.18 21 19 22 Terminology 20 23 ------------ 21 24 22 * Gadget: A TG2 application designed to work within toolbox. Some of them may also be designed to be embedded inside end-user applications.25 * Gadget: The application work within toolbox. Some of them may allow you to embed in your application. 23 26 24 27 Features trunk/docs/2.0/ToscaWidgets/Using.rst
r4396 r4575 1 2 1 3 2 4 Using Existing Widgets 3 5 ====================== 6 4 7 5 8 Finding Existing Widgets trunk/docs/2.0/Wiki20/JSONMochiKit.rst
r4374 r4575 39 39 ---------------------- 40 40 41 For the client side of this tutorial, we'll be using MochiKit. 41 For the client side of this tutorial, we'll be using MochiKit, the official 42 javascript framework of TurboGears. The two are only loosely coupled, as 43 opposed to prototype/Rails, but we find MochiKit to provide a very elegant 44 Python-inspired API while avoiding monkeypatches on the JavaScript datatypes. 42 45 43 46 To keep this from turning into a javascript tutorial (it's pretty long as-is … … 46 49 the pagelist and include it right in the page you're viewing. 47 50 48 The first thing we need to do is have MochiKit included in all of our pages. 49 This can be done by editing the ``master.html`` file or by having TurboGears 50 add it as a widget. 51 52 The first thing you'll need to do is download and install the tw.mochikit 53 package:: 54 55 easy_install tw.mochikit 56 57 TODO: Add the toscawidget stuff here. 51 The first thing we need to do is have MochiKit included in all of our pages. This can be done by editing the ``master.kid`` file or by having TurboGears add it as a widget. We'll use the latter technique here. 52 53 Open the ``wiki20/config/app.cfg``. This file controls environment-independent settings like identity and output encoding. Search through the file for the ``tg.include_widgets`` setting, uncomment it, and modify it like so:: 54 55 tg.include_widgets = ['turbogears.mochikit'] 56 57 As the name indicates, we actually are using TurboGears' widget infrastructure 58 to do the inclusion. Widgets are an advanced feature and are out of scope for 59 this tutorial, but they're essentially self-contained bundles of HTML+behavior 60 code that make building forms a snap. One of the things they can do is include 61 javascript in a page and the ``turbogears.mochikit`` takes advantage of this to 62 provide a javascript library. The `cogbin`_ has other javascript libraries 63 packed up as widgets that can be used the same way. 64 65 .. _cogbin: http://www.turbogears.org/cogbin/ 66 67 After making this configuration change, **restart the server.** The auto-reload functionality only detects changes to python files. 68 58 69 59 70 Prep the page 60 71 ------------- 61 72 62 Now that we have MochiKit, we're ready to modify our template. We'll practice good style by progressively enhancing our pagelist link in ``master. html``:73 Now that we have MochiKit, we're ready to modify our template. We'll practice good style by progressively enhancing our pagelist link in ``master.kid``: 63 74 64 75 .. parsed-literal:: … … 76 87 they have JavaScript enabled or not. 77 88 89 78 90 The main event 79 91 -------------- 80 92 81 In the interest of expediency (and because we're substituting URLs with gensh),93 In the interest of expediency (and because we're substituting URLs with Kid), 82 94 we'll add the handler to a ``<script>`` tag in the head rather than in its own 83 95 file. trunk/INSTALL.txt
r4370 r4575 48 48 49 49 $ hg clone https://www.knowledgetap.com/hg/pylons-dev pylons 50 $ hg clone https:// https://www.knowledgetap.com/hg/webhelpers/ webhelpers50 $ hg clone https://www.knowledgetap.com/hg/webhelpers/ webhelpers 51 51 $ svn co http://svn.turbogears.org/trunk tg2 52 52 … … 69 69 $ svn update 70 70 $ python setup.py develop 71 72 To update the Pylons and webhelpers sources: 73 74 $ cd ../webhelpers 75 $ hg pull; hg update 76 $ cd ../pylons 77 $ hg pull; hg update 71 78 72 79