Changeset 4831

Show
Ignore:
Timestamp:
06/28/08 16:17:40 (6 months ago)
Author:
brunojm
Message:

change files to first part of the tutorial

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docs/project_code/Wiki-20/wiki20/controllers/root.py

    r4806 r4831  
    33from tg import expose, flash 
    44from pylons.i18n import ugettext as _ 
    5 import tg 
    6 from tg import redirect, validate 
    7 from wiki20.model import DBSession, metadata 
     5#from tg import redirect, validate 
     6#from wiki20.model import DBSession, metadata 
    87#from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic 
    98#from dbsprockets.saprovider import SAProvider 
    10 from wiki20.model.page import Page 
    11 import re 
    12 from docutils.core import publish_parts 
    13 from sqlalchemy.exceptions import InvalidRequestError 
    14  
    15 wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)") 
    169 
    1710class RootController(BaseController): 
    1811    #admin = DBMechanic(SAProvider(metadata), '/admin') 
    1912 
    20     @expose('wiki20.templates.page') 
    21     def default(self, pagename="FrontPage"): 
    22         try: 
    23             page = DBSession.query(Page).filter_by(pagename=pagename).one() 
    24         except InvalidRequestError: 
    25             raise redirect("notfound", pagename=pagename) 
    26         content = publish_parts(page.data, writer_name="html")["html_body"] 
    27         root = tg.url('/') 
    28         content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content) 
    29         return dict(content=content, wikipage=page) 
    30  
    31     @expose('wiki20.templates.edit') 
    32     def edit(self, pagename): 
    33         page = DBSession.query(Page).filter_by(pagename=pagename).one() 
    34         return dict(wikipage=page) 
     13    @expose('wiki20.templates.index') 
     14    def index(self): 
     15        return dict(page='index') 
    3516 
    3617    @expose('wiki20.templates.about') 
    3718    def about(self): 
    3819        return dict() 
    39  
    40     @expose() 
    41     def save(self, pagename, data, submit): 
    42         page = DBSession.query(Page).filter_by(pagename=pagename).one() 
    43         page.data = data 
    44         DBSession.commit() # Tells database to commit changes permanently 
    45         redirect("/" + pagename) 
    46  
    47     @expose('wiki20.templates.edit') 
    48     def notfound(self, pagename): 
    49         page = Page(pagename=pagename, data="") 
    50         DBSession.save(page) 
    51         DBSession.commit() 
    52         return dict(wikipage=page) 
    53  
    54     @expose('wiki20.templates.pagelist') 
    55     def pagelist(self): 
    56         pages = [page.pagename for page in DBSession.query(Page)] 
    57         return dict(pages=pages) 
    58  
  • trunk/docs/project_code/Wiki-20/wiki20/model/__init__.py

    r4806 r4831  
    4040 
    4141# Import your model modules here.  
     42##{ModelModules} 
    4243from wiki20.model.page import Page, pages_table 
    43  
     44## 
  • trunk/docs/project_code/Wiki-20/wiki20/templates/edit.html

    r4806 r4831  
    99  <xi:include href="footer.html" /> 
    1010  <xi:include href="master.html" /> 
    11  
     11<!-- ##{Head} --> 
    1212<head> 
    1313  <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> 
    1414  <title>Editing: ${wikipage.pagename}</title> 
    1515</head> 
    16  
     16<!-- ## --> 
    1717<body> 
    1818 
     
    2222You can return to the <a href="/">FrontPage</a>. 
    2323    </div> 
    24  
     24<!-- ##{Form}--> 
    2525    <div> 
    2626      <form action="/save" method="post"> 
     
    3131    </div> 
    3232</div> 
    33  
     33<!-- ##--> 
    3434</body> 
    3535</html> 
  • trunk/docs/project_code/Wiki-20/wiki20/templates/page.html

    r4806 r4831  
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
    2                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    3 <html xmlns="http://www.w3.org/1999/xhtml" 
    4       xmlns:py="http://genshi.edgewall.org/" 
    5       xmlns:xi="http://www.w3.org/2001/XInclude"> 
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     2  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     3<html 
     4    xmlns="http://www.w3.org/1999/xhtml" 
     5    xmlns:py="http://genshi.edgewall.org/" 
     6    xmlns:xi="http://www.w3.org/2001/XInclude"> 
    67 
    7   <xi:include href="header.html" /> 
    8   <xi:include href="sidebars.html" /> 
    9   <xi:include href="footer.html" /> 
    10   <xi:include href="master.html" /> 
     8 
     9<xi:include href="header.html" /> 
     10<xi:include href="footer.html" /> 
     11<xi:include href="master.html" /> 
    1112 
    1213<head> 
    13   <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> 
    14   <title>${wikipage.pagename} - The TurboGears 2 Wiki</title> 
     14    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/> 
     15    <title>${wikipage.pagename} - The TurboGears 2 Wiki</title> 
    1516</head> 
    1617 
     
    1819 
    1920<div class="main_content"> 
    20     <div style="float:right; width: 10em;"> Viewing 
    21         <span py:replace="wikipage.pagename">Page Name Goes Here</span> <br/> 
     21<div style="float:right; width: 10em;"> Viewing 
     22<!-- ##{PageName} --> 
     23<span py:replace="wikipage.pagename">Page Name Goes Here</span> 
     24<!-- ## --> 
     25<br/> 
    2226You can return to the <a href="/">FrontPage</a>. 
    23     </div> 
    24  
    25     <div py:replace="XML(content)">Formatted content goes here.</div> 
    26     <a href="/edit/${wikipage.pagename}">Edit this page</a
    27     <a href="/pagelist">View the page list</a> 
     27</div> 
     28<!-- ##{PageContent} --> 
     29<div py:replace="wikipage.data">Page text goes here.</div> 
     30<!-- ## --
     31<a href="/edit/${wikipage.pagename}">Edit this page</a> 
    2832</div> 
    2933