| 1 | | from datetime import datetime |
|---|
| 2 | | from sqlalchemy import * |
|---|
| 3 | | from turbogears.database import metadata, session |
|---|
| 4 | | from turbogears import identity |
|---|
| 5 | | from pagoda.plugins.page import Page |
|---|
| 6 | | from pagoda.models.identity import * |
|---|
| 7 | | from pagoda.plugins.textcontainer import TextContainer |
|---|
| 8 | | from pagoda import workflow |
|---|
| 9 | | |
|---|
| 10 | | def make_site_tree(): |
|---|
| 11 | | # / - Home |
|---|
| 12 | | # /pagoda - Welcome |
|---|
| 13 | | # /tests - Unit tests |
|---|
| 14 | | # /templates - Genshi templates |
|---|
| 15 | | # /eatthesandwich - Eat it |
|---|
| 16 | | |
|---|
| 17 | | metadata.drop_all() |
|---|
| 18 | | metadata.create_all() |
|---|
| 19 | | |
|---|
| 20 | | brian = User(user_name="brian", password="insecure") |
|---|
| 21 | | ian = User(user_name="ian", password="insecure") |
|---|
| 22 | | |
|---|
| 23 | | staff = Group(group_name='pagoda_staff') |
|---|
| 24 | | admin_perm = Permission(permission_name='pagoda_admin') |
|---|
| 25 | | publish_perm = Permission(permission_name='pagoda_publish') |
|---|
| 26 | | editor = Group(group_name='pagoda_editor') |
|---|
| 27 | | staff.permissions.extend([admin_perm]) |
|---|
| 28 | | staff.users.extend([brian, ian]) |
|---|
| 29 | | editor.users.extend([brian]) |
|---|
| 30 | | |
|---|
| 31 | | session.flush() |
|---|
| 32 | | |
|---|
| 33 | | home_page = Page( |
|---|
| 34 | | node_url=None, parent_id=None, content_locale='en_US', |
|---|
| 35 | | node_title="Home", nav_show=True, revision_author_id=brian.user_id, |
|---|
| 36 | | content_type='page', revision_status=workflow.APPROVED |
|---|
| 37 | | ) |
|---|
| 38 | | |
|---|
| 39 | | session.flush() |
|---|
| 40 | | |
|---|
| 41 | | pagoda_page = Page( |
|---|
| 42 | | node_url='pagoda', parent_id=home_page.content_id, content_locale='en_US', |
|---|
| 43 | | node_title="Welcome", nav_show=True, revision_author_id=brian.user_id, |
|---|
| 44 | | content_type='page', revision_status=workflow.APPROVED |
|---|
| 45 | | ) |
|---|
| 46 | | |
|---|
| 47 | | session.flush() |
|---|
| 48 | | |
|---|
| 49 | | tests_page = Page( |
|---|
| 50 | | node_url='tests', parent_id=pagoda_page.content_id, content_locale='en_US', |
|---|
| 51 | | node_title="Unit tests", nav_show=True, revision_author_id=brian.user_id, |
|---|
| 52 | | content_type='page', revision_status=workflow.APPROVED |
|---|
| 53 | | ) |
|---|
| 54 | | |
|---|
| 55 | | templates_page = Page( |
|---|
| 56 | | node_url='templates', parent_id=pagoda_page.content_id, content_locale='en_US', |
|---|
| 57 | | node_title="Genshi templates", nav_show=True, |
|---|
| 58 | | revision_author_id=brian.user_id, content_type='page', |
|---|
| 59 | | revision_status=workflow.PENDING, |
|---|
| 60 | | revision_release_time=datetime(2007, 9, 20) |
|---|
| 61 | | ) |
|---|
| 62 | | |
|---|
| 63 | | ets_page = Page( |
|---|
| 64 | | node_url='eatthesandwich', parent_id=home_page.content_id, |
|---|
| 65 | | content_locale='en_US', node_title="Eat it", nav_show=True, |
|---|
| 66 | | revision_author_id=brian.user_id, content_type='page', |
|---|
| 67 | | revision_status=workflow.APPROVED, |
|---|
| 68 | | revision_release_time=datetime(2008, 1, 1) |
|---|
| 69 | | ) |
|---|
| 70 | | |
|---|
| 71 | | session.flush() |
|---|
| 72 | | |
|---|
| 73 | | pagoda_intro_text = TextContainer( |
|---|
| 74 | | container_name='intro', |
|---|
| 75 | | document_id=pagoda_page.content_id, |
|---|
| 76 | | content_locale=pagoda_page.content_locale, |
|---|
| 77 | | revision_author_id=ian.user_id, |
|---|
| 78 | | text_type='html', |
|---|
| 79 | | text=""" |
|---|
| 80 | | <p><strong>Welcome!</strong> Please enjoy our Pagoda softwares.</p> |
|---|
| 81 | | """ |
|---|
| 82 | | ) |
|---|
| 83 | | |
|---|
| 84 | | pagoda_body_text = TextContainer( |
|---|
| 85 | | container_name='body', |
|---|
| 86 | | document_id=pagoda_page.content_id, |
|---|
| 87 | | content_locale=pagoda_page.content_locale, |
|---|
| 88 | | revision_author_id=ian.user_id, |
|---|
| 89 | | text_type='html', |
|---|
| 90 | | text=""" |
|---|
| 91 | | <p>Pagoda is not ready yet. <Please check back in two weeks, |
|---|
| 92 | | when it is <em>done</em>.</\p> |
|---|
| 93 | | """ |
|---|
| 94 | | ) |
|---|
| 95 | | |
|---|
| 96 | | session.flush() |
|---|
| 97 | | |
|---|
| 98 | | pagoda_intro_revised = TextContainer( |
|---|
| 99 | | container_name='intro', |
|---|
| 100 | | document_id=pagoda_page.content_id, |
|---|
| 101 | | content_locale=pagoda_page.content_locale, |
|---|
| 102 | | revision_author_id=ian.user_id, |
|---|
| 103 | | text_type='html', |
|---|
| 104 | | text=""" |
|---|
| 105 | | <p>We made several typos. Please ignore the old revision.</p> |
|---|
| 106 | | """ |
|---|
| 107 | | ) |
|---|
| 108 | | |
|---|
| 109 | | session.flush() |
|---|
| 110 | | |
|---|
| 111 | | pagoda_page_revised = Page( |
|---|
| 112 | | content_id=pagoda_page.content_id, |
|---|
| 113 | | node_url='pagoda', parent_id=home_page.content_id, content_locale='en_US', |
|---|
| 114 | | nav_show=True, revision_author_id=brian.user_id, |
|---|
| 115 | | content_type='page', revision_status=workflow.PENDING, |
|---|
| 116 | | node_title="Welcome! (Now typo free.)" |
|---|
| 117 | | ) |
|---|
| 118 | | |
|---|
| 119 | | session.flush() |
|---|
| 120 | | |
|---|
| 121 | | pagoda_body_revised = TextContainer( |
|---|
| 122 | | container_name='body', |
|---|
| 123 | | document_id=pagoda_page.content_id, |
|---|
| 124 | | content_locale=pagoda_page.content_locale, |
|---|
| 125 | | revision_author_id=brian.user_id, |
|---|
| 126 | | text_type='html', |
|---|
| 127 | | text=""" |
|---|
| 128 | | <p>We made several typos. Please ignore the old revision!</p> |
|---|
| 129 | | """ |
|---|
| 130 | | ) |
|---|
| 131 | | |
|---|
| 132 | | session.flush() |
|---|
| | 1 | # from datetime import datetime |
|---|
| | 2 | # from sqlalchemy import * |
|---|
| | 3 | # from turbogears.database import metadata, session |
|---|
| | 4 | # from turbogears import identity |
|---|
| | 5 | # from pagoda.plugins.page import Page |
|---|
| | 6 | # from pagoda.models.identity import * |
|---|
| | 7 | # from pagoda.plugins.textcontainer import TextContainer |
|---|
| | 8 | # from pagoda import workflow |
|---|
| | 9 | # |
|---|
| | 10 | # def make_site_tree(): |
|---|
| | 11 | # # / - Home |
|---|
| | 12 | # # /pagoda - Welcome |
|---|
| | 13 | # # /tests - Unit tests |
|---|
| | 14 | # # /templates - Genshi templates |
|---|
| | 15 | # # /eatthesandwich - Eat it |
|---|
| | 16 | # |
|---|
| | 17 | # metadata.drop_all() |
|---|
| | 18 | # metadata.create_all() |
|---|
| | 19 | # |
|---|
| | 20 | # brian = User(user_name="brian", password="insecure") |
|---|
| | 21 | # ian = User(user_name="ian", password="insecure") |
|---|
| | 22 | # |
|---|
| | 23 | # staff = Group(group_name='pagoda_staff') |
|---|
| | 24 | # admin_perm = Permission(permission_name='pagoda_admin') |
|---|
| | 25 | # publish_perm = Permission(permission_name='pagoda_publish') |
|---|
| | 26 | # editor = Group(group_name='pagoda_editor') |
|---|
| | 27 | # staff.permissions.extend([admin_perm]) |
|---|
| | 28 | # staff.users.extend([brian, ian]) |
|---|
| | 29 | # editor.users.extend([brian]) |
|---|
| | 30 | # |
|---|
| | 31 | # session.flush() |
|---|
| | 32 | # |
|---|
| | 33 | # home_page = Page( |
|---|
| | 34 | # node_url=None, parent_id=None, content_locale='en_US', |
|---|
| | 35 | # node_title="Home", nav_show=True, revision_author_id=brian.user_id, |
|---|
| | 36 | # content_type='page', revision_status=workflow.APPROVED |
|---|
| | 37 | # ) |
|---|
| | 38 | # |
|---|
| | 39 | # session.flush() |
|---|
| | 40 | # |
|---|
| | 41 | # pagoda_page = Page( |
|---|
| | 42 | # node_url='pagoda', parent_id=home_page.content_id, content_locale='en_US', |
|---|
| | 43 | # node_title="Welcome", nav_show=True, revision_author_id=brian.user_id, |
|---|
| | 44 | # content_type='page', revision_status=workflow.APPROVED |
|---|
| | 45 | # ) |
|---|
| | 46 | # |
|---|
| | 47 | # session.flush() |
|---|
| | 48 | # |
|---|
| | 49 | # tests_page = Page( |
|---|
| | 50 | # node_url='tests', parent_id=pagoda_page.content_id, content_locale='en_US', |
|---|
| | 51 | # node_title="Unit tests", nav_show=True, revision_author_id=brian.user_id, |
|---|
| | 52 | # content_type='page', revision_status=workflow.APPROVED |
|---|
| | 53 | # ) |
|---|
| | 54 | # |
|---|
| | 55 | # templates_page = Page( |
|---|
| | 56 | # node_url='templates', parent_id=pagoda_page.content_id, content_locale='en_US', |
|---|
| | 57 | # node_title="Genshi templates", nav_show=True, |
|---|
| | 58 | # revision_author_id=brian.user_id, content_type='page', |
|---|
| | 59 | # revision_status=workflow.PENDING, |
|---|
| | 60 | # revision_release_time=datetime(2007, 9, 20) |
|---|
| | 61 | # ) |
|---|
| | 62 | # |
|---|
| | 63 | # ets_page = Page( |
|---|
| | 64 | # node_url='eatthesandwich', parent_id=home_page.content_id, |
|---|
| | 65 | # content_locale='en_US', node_title="Eat it", nav_show=True, |
|---|
| | 66 | # revision_author_id=brian.user_id, content_type='page', |
|---|
| | 67 | # revision_status=workflow.APPROVED, |
|---|
| | 68 | # revision_release_time=datetime(2008, 1, 1) |
|---|
| | 69 | # ) |
|---|
| | 70 | # |
|---|
| | 71 | # session.flush() |
|---|
| | 72 | # |
|---|
| | 73 | # pagoda_intro_text = TextContainer( |
|---|
| | 74 | # container_name='intro', |
|---|
| | 75 | # document_id=pagoda_page.content_id, |
|---|
| | 76 | # content_locale=pagoda_page.content_locale, |
|---|
| | 77 | # revision_author_id=ian.user_id, |
|---|
| | 78 | # text_type='html', |
|---|
| | 79 | # text=""" |
|---|
| | 80 | # <p><strong>Welcome!</strong> Please enjoy our Pagoda softwares.</p> |
|---|
| | 81 | # """ |
|---|
| | 82 | # ) |
|---|
| | 83 | # |
|---|
| | 84 | # pagoda_body_text = TextContainer( |
|---|
| | 85 | # container_name='body', |
|---|
| | 86 | # document_id=pagoda_page.content_id, |
|---|
| | 87 | # content_locale=pagoda_page.content_locale, |
|---|
| | 88 | # revision_author_id=ian.user_id, |
|---|
| | 89 | # text_type='html', |
|---|
| | 90 | # text=""" |
|---|
| | 91 | # <p>Pagoda is not ready yet. <Please check back in two weeks, |
|---|
| | 92 | # when it is <em>done</em>.</\p> |
|---|
| | 93 | # """ |
|---|
| | 94 | # ) |
|---|
| | 95 | # |
|---|
| | 96 | # session.flush() |
|---|
| | 97 | # |
|---|
| | 98 | # pagoda_intro_revised = TextContainer( |
|---|
| | 99 | # container_name='intro', |
|---|
| | 100 | # document_id=pagoda_page.content_id, |
|---|
| | 101 | # content_locale=pagoda_page.content_locale, |
|---|
| | 102 | # revision_author_id=ian.user_id, |
|---|
| | 103 | # text_type='html', |
|---|
| | 104 | # text=""" |
|---|
| | 105 | # <p>We made several typos. Please ignore the old revision.</p> |
|---|
| | 106 | # """ |
|---|
| | 107 | # ) |
|---|
| | 108 | # |
|---|
| | 109 | # session.flush() |
|---|
| | 110 | # |
|---|
| | 111 | # pagoda_page_revised = Page( |
|---|
| | 112 | # content_id=pagoda_page.content_id, |
|---|
| | 113 | # node_url='pagoda', parent_id=home_page.content_id, content_locale='en_US', |
|---|
| | 114 | # nav_show=True, revision_author_id=brian.user_id, |
|---|
| | 115 | # content_type='page', revision_status=workflow.PENDING, |
|---|
| | 116 | # node_title="Welcome! (Now typo free.)" |
|---|
| | 117 | # ) |
|---|
| | 118 | # |
|---|
| | 119 | # session.flush() |
|---|
| | 120 | # |
|---|
| | 121 | # pagoda_body_revised = TextContainer( |
|---|
| | 122 | # container_name='body', |
|---|
| | 123 | # document_id=pagoda_page.content_id, |
|---|
| | 124 | # content_locale=pagoda_page.content_locale, |
|---|
| | 125 | # revision_author_id=brian.user_id, |
|---|
| | 126 | # text_type='html', |
|---|
| | 127 | # text=""" |
|---|
| | 128 | # <p>We made several typos. Please ignore the old revision!</p> |
|---|
| | 129 | # """ |
|---|
| | 130 | # ) |
|---|
| | 131 | # |
|---|
| | 132 | # session.flush() |
|---|