- Timestamp:
- 13 Nov 2014, 16:54:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/browser/breadcrumbs.txt
r11952 r11954 9 9 =============================== 10 10 11 We create a institutionto check the breadcrumb functionality.12 13 >>> from waeup.ikoba.app import Institution11 We create a company to check the breadcrumb functionality. 12 13 >>> from waeup.ikoba.app import Company 14 14 >>> root = getRootFolder() 15 >>> root['app'] = Institution()15 >>> root['app'] = Company() 16 16 >>> app = root['app'] 17 17 … … 25 25 >>> blist1 = getBreadcrumbList(app, 'index') 26 26 >>> blist1 27 [<waeup.ikoba.browser.breadcrumbs. InstitutionBreadcrumb object at 0x...>]27 [<waeup.ikoba.browser.breadcrumbs.CompanyBreadcrumb object at 0x...>] 28 28 29 29 A slightly more extensive list for the datacenter: … … 32 32 >>> from pprint import pprint 33 33 >>> pprint(blist2) 34 [<waeup.ikoba.browser.breadcrumbs. InstitutionBreadcrumb object at 0x...>,34 [<waeup.ikoba.browser.breadcrumbs.CompanyBreadcrumb object at 0x...>, 35 35 <waeup.ikoba.browser.breadcrumbs.AdministrationBreadcrumb object at 0x...>, 36 36 <waeup.ikoba.browser.breadcrumbs.DataCenterBreadcrumb object at 0x...>] 37 37 38 We get a breadcrumb for institution, administration area and data38 We get a breadcrumb for company, administration area and data 39 39 center in that order. 40 40 … … 47 47 48 48 >>> pprint([(x.context, x.viewname) for x in blist2]) 49 [(<waeup.ikoba.app. Institutionobject at 0x...>, 'index'),50 (<waeup.ikoba.app. Institutionobject at 0x...>, 'administration'),49 [(<waeup.ikoba.app.Company object at 0x...>, 'index'), 50 (<waeup.ikoba.app.Company object at 0x...>, 'administration'), 51 51 (<waeup.ikoba.datacenter.DataCenter object at 0x...>, 'index')] 52 52 53 53 The administration area breadcrumb might be a surprise, as there is no 54 54 equivalent object in the ZODB. In fact the administration area is only 55 a certain view (the 'administration' view) on the institutionobject.55 a certain view (the 'administration' view) on the company object. 56 56 57 57 We will show below, how you can define breadcrumbs this way. … … 62 62 63 63 This way we can make sure, that there are different breadcrumb lists 64 generated for instance for the administration view of Institution64 generated for instance for the administration view of Company 65 65 instances and the index view. While the first should look something 66 66 like:: … … 118 118 119 119 >>> pprint(mybccontainer.getList()) 120 [<...breadcrumbs. InstitutionBreadcrumb object at 0x...>,120 [<...breadcrumbs.CompanyBreadcrumb object at 0x...>, 121 121 <...breadcrumbs.AdministrationBreadcrumb object at 0x...>, 122 122 <...breadcrumbs.UsersContainerBreadcrumb object at 0x...>] … … 128 128 129 129 Now we can get breadcrumbs for contexts and view names. For example a 130 breadcrumb for the 'index' view of our Institutionobject:130 breadcrumb for the 'index' view of our Company object: 131 131 132 132 >>> from zope.component import getAdapter … … 134 134 >>> b1 = getAdapter(app, IBreadcrumb, 'index') 135 135 >>> b1 136 <waeup.ikoba.browser.breadcrumbs. InstitutionBreadcrumb object at 0x...>136 <waeup.ikoba.browser.breadcrumbs.CompanyBreadcrumb object at 0x...> 137 137 138 138 Breadcrumb objects provide a title: … … 168 168 169 169 >>> b2.parent 170 (<waeup.ikoba.app. Institutionobject at 0x...>, 'administration')171 172 This result denotes a new context object (the Institutioninstance we170 (<waeup.ikoba.app.Company object at 0x...>, 'administration') 171 172 This result denotes a new context object (the Company instance we 173 173 created above) and a view name ('administration'). 174 174 … … 188 188 As you can see, we get an AdministrationBreadcrumb, although the 189 189 context object, for which the breadcrumb was created is also the 190 Institutioninstance as above:190 Company instance as above: 191 191 192 192 >>> b3.context is b1.context … … 197 197 >>> context, viewname = b3.parent 198 198 >>> context, viewname 199 (<waeup.ikoba.app. Institutionobject at 0x...>, 'index')199 (<waeup.ikoba.app.Company object at 0x...>, 'index') 200 200 201 201 We create last breadcrumb:
Note: See TracChangeset for help on using the changeset viewer.