Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
Plone BootcampBest Practices for Plone Development
Joel Burton
May 24, 2010
CONTENTS
1 Introduction 11.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Rights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Welcome to Class! 32.1 Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.4 Stereograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Using Plone: Content 93.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3 Contents Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Using Plone: Metadata 154.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3 Searching/RSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.4 Content Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5 Using Plone: Users & Roles 215.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2 Security Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.3 Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.4 Sharing & Local Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 Content Types 276.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.2 Content Type Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
i
7 Collections 317.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.2 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8 Content Rules 358.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378.4 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
9 Building Forms 399.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399.2 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419.3 Extending PloneFormGen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10 Managing Portlets 4310.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4310.2 Adding Portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
11 Installing Add-On Products 4711.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4711.2 Product Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4811.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
12 Building a Site 5512.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5512.2 Structuring Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5512.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13 Content Types 5713.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5713.2 Content Type Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5913.3 Content API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6013.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6113.5 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
14 Basic Archetypes 6514.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6514.2 Field Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6714.3 Field Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6814.4 Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6814.5 ArgoUML Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6914.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
15 Paster 7115.1 What Is Paster? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7115.2 Using Paster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7115.3 Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
ii
16 Picking a Workflow 7316.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7316.2 New Workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7316.3 Workflow & Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7716.4 Workflow Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7716.5 The Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7916.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
17 Security 8117.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8117.2 Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8117.3 Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8417.4 Debugging Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8617.5 Plone PAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8617.6 API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8817.7 Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8917.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8917.9 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
18 Workflow 9118.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9118.2 Monkeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9118.3 States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9118.4 Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9418.5 Mapping to Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9618.6 Additional Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9718.7 Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9718.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9718.9 Advanced Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9718.10 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
19 Generic Setup 10119.1 Generic Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
20 Skinning Plone 10520.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10520.2 Skin Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10520.3 Two Skinning Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10720.4 Zope-3 Style Skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10720.5 CMF-Style Skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10820.6 CMF or Zope 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10920.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11020.8 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
21 Basic Page Templates 11321.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11321.2 TAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11421.3 TALES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
iii
21.4 Creating ZPTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11721.5 TALES II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11821.6 PT and Archetypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11921.7 Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12121.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12221.9 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
22 Theming Overview 12522.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12522.2 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12622.3 Viewlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12622.4 Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12722.5 Navigation Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12922.6 Base Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12922.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13122.8 CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13122.9 Customizing CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13422.10 Adding to Our Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13522.11 Content and Kupu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13622.12 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13622.13 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
23 Deployment Considerations 13923.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13923.2 Zope Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13923.3 Simple Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14023.4 HTTP Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14123.5 Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14323.6 Multiple Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14523.7 Serious Deployments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14823.8 Speed Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14923.9 Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
24 The Road Ahead 15324.1 Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15324.2 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15324.3 Your Road . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15924.4 Thanks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
25 Functional Testing 16325.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16325.2 Selenium . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16325.3 Running Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16525.4 Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16625.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16725.6 Advanced Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16725.7 Exercise Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
iv
26 Add-On Products 16926.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16926.2 The Short List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17026.3 Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17026.4 Content Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17126.5 Archetypes Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17526.6 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17626.7 Portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17626.8 Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17726.9 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18026.10 Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18126.11 Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18126.12 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
27 Intro to Buildout 18527.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18527.2 Buildout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18527.3 Buildout File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18627.4 Using Buildout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18927.5 Buildout Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19027.6 Buildout Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19127.7 Migrating Buildout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19227.8 Useful Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19327.9 Road Ahead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
28 Software Licenses 20128.1 General Public License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20128.2 Zope Public License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20428.3 BSD License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
29 Copyright and License Information 207
30 Glossary 209
Index 211
v
vi
CHAPTER
ONE
INTRODUCTION
This training covers Plone 3.2. It moves in a “top-down” approach, teaching first the high-level concepts ofPlone:
• navigating the Plone UI in a browser
• editing and adding content
• changing workflow
and so on, moving then to such tasks as:
• customization
• HTML page design and CSS
• scripting
and in the last 5 or 6 chapters, covers topics such as:
• application development
• relational database integration
and other related things.
Plone is a fast moving target, so it’s possible that some information here has been superceded by changes inthe product. If so, please email me and I’ll correct this. In the meantime, you can visit the Plone Project sitefor information about new releases of Plone.
1.1 Prerequisites
This training assumes you have a good working knowledge of:
• HTML
• web application development ideas
– forms
– cookies
• CSS
1
Plone Bootcamp, Best Practices for Plone Development
If not, you may need to read up on these topics first.
In addition, this training assumes you have a good working knowledge of Python, the language Plone iswritten in and is extended in. If not, you can learn Python relatively quickly. A good resource is Dive IntoPython (available online) or O’Reilly and Associates’ Learning Python.
1.2 Rights
While Plone is free software (covered under the GPL), this manual for the training is not. It may not bereproduced in any manner, nor re-published or altered, without written permission of the author.
Copyright copy 2003-2009 Joel Burton.
1.3 About the Author
Joel Burton is an independent Zope and Plone developer and knowledge management consultant based outof San Francisco, California.
He is an active member of the Plone community, serving on the Plone Team (the core group who manage thedevelopment of the project and community). He has served as the Chair of the Board of Plone’s nonprofitfoundation, the Plone Foundation, and is a member in good standing of the Foundation. In 2004, Joel washonored with the Plone Persistent Cookie Award, the highest honor given for service to the Plone community.
2 Chapter 1. Introduction
CHAPTER
TWO
WELCOME TO CLASS!
2.1 Class
2.1.1 Our Situation
• “Straightforward department site”
– Content edited by staff and grad students
2.1.2 Projects
• We have several department projects
– Each project is a folder of documents
* HTML, PDFs, Excel, etc.
– Need to manage who can edit these
2.1.3 Symposia
• Department-level events
– Like an event
– Managed by different people
– Should be listed in one area
2.1.4 Press Center
• Center for press releases and clips
– No built-in type of content for this
– But we can find one online!
3
Plone Bootcamp, Best Practices for Plone Development
2.1.5 Faculty Books
• Showing off faculty books
– No built-in type of content for this
– Need to control how this looks
2.1.6 Grad Student Interest
• Need a form for gathering grad student interest
– Want to keep this information and email it
– Want to manage the fields that appear, how it looks, etc.
2.1.7 Portlets
• Want portlets (“info boxes”) for department information
– Contact information
– For grad students: upcoming symposia
2.1.8 Workflow & Control
• Want a simple, lightweight control for who can edit
– We trust each other (mostly!)
2.1.9 Look-and-Feel
• Have a straightforward 3-column theme
– Want to implement in CSS into Plone
2.1.10 Deployment
• Going to deploy on Linux
– Want to learn default options for caching
2.1.11 How You Can Help
• Please silence your cell phones
• If you know the answer, let me know!
– ... if you’re lost, tell me that, too
4 Chapter 2. Welcome to Class!
Plone Bootcamp, Best Practices for Plone Development
2.2 Setup
2.2.1 Windows under Buildout
• Installs at c:\pse2010
• “Buildout” is c:\pse2010
• URL: http://localhost:8085/Plone
The default port number is 8080. It has been changed in the class setup to 8085.
• Startup:
– bin\instance fg
• regenerate buildout:
– bin\buildout
Starting in “fg” (foreground) mode offers several advantages: you know when Plone has really startedup successfully, you get immediate feedback on any errors that prevent complete startup, and you getall error messages/information messages written out to the console window.
This is the same thing as using the script runzope.bat in the $INSTANCE_HOME/bin directoryin non-buildout Windows (which was the standard prior to Plone 3.1).
2.2.2 OSX under Buildout
• Installs at /Application/Plone
• “Buildout” is /Applications/Plone/pse2010
The more traditional name for the buildout directory is zinstance. It it likely to be this in non-classPlone sites you work on.
• URL: http://localhost:8085/Plone
The default port number is 8080. It has been changed in the class setup to 8085.
• Startup:
– bin/instance fg
• Regenerate buildout:
– bin/buildout
Starting in “fg” (foreground) mode offers several advantages: you know when Plone has really startedup successfully, you get immediate feedback on any errors that prevent complete startup, and you getall error messages/information messages written out to the console window.
This is the same thing as using the script runzope in the $INSTANCE_HOME/bin directory innon-buildout OSX (which was the standard before Plone 3.1).
2.2. Setup 5
Plone Bootcamp, Best Practices for Plone Development
2.2.3 Linux under Buildout
• Installs at ~/Plone
It is also possible to do a “root” installation, where it is installed at /opt/Plone. This setup ispreferred on server, as the Zope process can run as a system user, not as the normal user.
• “Buildout” is ~/Plone/pse2010
The more traditional name for the buildout directory is zinstance. It it likely to be this in non-classPlone sites you work on.
• URL: http://localhost:8085/Plone
The default port number is 8080. It has been changed in the class setup to 8085.
• Startup:
– bin/instance fg
• Regenerate buildout:
– bin/buildout
Starting in “fg” (foreground) mode offers several advantages: you know when Plone has really startedup successfully, you get immediate feedback on any errors that prevent complete startup, and you getall error messages/information messages written out to the console window.
This is the same thing as using the script runzope in the $INSTANCE_HOME/bin directory innon-buildout Linux (which was the standard before Plone 3.1).
2.3 Logging In
2.3.1 Multiple Login Sessions
• Can’t be logged in & out with one browser
– Can use multiple browsers
– Can use different hostnames
* http://localhost:8085... for admin manager
* http://127.0.0.1:8085... for anonymous
2.3.2 Multiple Sessions By IP
http://127.0.0.1 Admin user (“meta-manager”). Used for managing application server above Plone.
http://127.0.0.2 Your user. A content manager.
http://127.0.0.3 Ordinary user.
http://127.0.0.4 Anonymous user.
6 Chapter 2. Welcome to Class!
Plone Bootcamp, Best Practices for Plone Development
This may require some setup on OSX, where the 127.0.0.x domain isn’t entirely mapped to the localhost;only 127.0.0.1 is.
2.4 Stereograms
2.4.1 Stereograms
• I feel comfortable ...
• ... managing content in Plone
• ... building a simple Plone site
• ... crafting CSS
• ... writing simple Python code
2.4. Stereograms 7
Plone Bootcamp, Best Practices for Plone Development
8 Chapter 2. Welcome to Class!
CHAPTER
THREE
USING PLONE: CONTENT
3.1 Introduction
3.1.1 So, You Want To ...?
• Build a “projects” section
3.1.2 Overview
• Adding content
• Kupu and styles
• Workflow basics
3.1.3 Short Names
• Short name (also called id) is like the filename
– Must be unique within parent folder
• URL for object comes from short names:
http://site/folder-id/folder-id/content-id
• Don’t rename existing content casually
– Since this may cause links to break!
The product RedirectionTool can help with this.
3.1.4 Actions Menu
• Delete
• Cut
9
Plone Bootcamp, Best Practices for Plone Development
• Copy
• Paste
– (only after cut/copy)
• Rename
I often find it useful to hide “cut”, “paste”, and “rename” from beginning users–they can confuse them. Intheir place, I add a single item, “duplicate”, which does a copy and immediate paste.
3.1.5 Kupu
• Kupu, our WYSIWYG HTML editor
The name comes from the Maori word for “word”. Obscure, huh?
• Plone-specific links, image-inclusion
• Warns about form abandonment
• Filters HTML for style consistency
• Alternate WYSIWYG editors available FCKEditor.Plone and Products.TinyMCE are alternate edi-tors; both have add-on Plone products to use. Both of these are strategically different from kupu, inthat they allow you to make direct visual changes to your content, rather than forcing users to usepre-defined CSS classes.
TinyMCE, in particular, is an excellent replacement for Kupu for organizations with a high number ofWYSIWYG HTML editors. It includes nice features like “clean up HTML from Word”, etc.
3.1.6 Kupu Styles
• No color buttons
– By design
There are color buttons (and other appearance things); they’re just disabled from view by default.See the “toolbar” section of the Kupu Visual Editor preferences in Site Setup to view or enablethese.
• Don’t put appearance in content!
– Instead, capture meaning
– Can add more items to this menu
3.1.7 HTML Mode
• Can enter HTML directly
– Cleanup WYSIWYG stuff
10 Chapter 3. Using Plone: Content
Plone Bootcamp, Best Practices for Plone Development
– Add CSS classes
It’s possible to “blacklist” some CSS classes, so they can’t be used in Kupu. This setting is inthe HTML Filtering configlet in Site Setup.
– Add (limited) CSS style=’...’
What can be entered here is controlled by a white list on the HTML Filtering configlet in sitesetup.
• Security filtering is still in effect
3.1.8 Security Filtering
• Nasty: remove elements entirely
– applet, embed, object
– script
• Stripped keep content, remove tag
– form, textarea, etc.
This can be changed by editing the HTML Filtering configlet in Site Setup.
Warning: Be careful!There are good reasons we disable users being able to add JavaScript, <embed>, <object>, etc.Be sure you understand the security ramifications of re-enabling these before doing so. If you do notcompletely trust you content editors, you may be opening significant security holes.
3.1.9 Adding Images
• Add things already in Plone
• Upload new images via kupu
– Go to folder in image drawer, then “upload...”
– Convenient
• Add directly using “Add...” menu
– Allows you to control size, rotation, description
• Result is exactly the same
3.1.10 Related Content
• Relate any arbitrary content together
• Relationship is unidirectional
3.1. Introduction 11
Plone Bootcamp, Best Practices for Plone Development
• Custom content types can have meaningful relationship
– eg, “book was written by...”
• Related items show on view screens
• Can be searched
3.1.11 Linking to Assets
• Internal link
– Easy, can browse or search Plone assets
• External link
– Any URL (local or on Internet)
• “Related items”
– Security-aware
– Change title with item
– Works even when object is moved
3.1.12 Content Types
• Event
• File: Any binary file (PDF, etc.)
• Folder
• Image: GIF, PNG, JPG
• Link: A “resource” (just title + URL)
• News Item
• Page: Catch-all for HTML pages
There’s also a content type, Large Plone Folder. This is like a folder that is optimized for holding hundredsor thousands of things.
In exchange for the more efficient storage of these things, items in Large Plone Folders are not orderable.
3.2 Workflow
3.2.1 Standard Plone Workflow
• Simple Publication Workflow:
12 Chapter 3. Using Plone: Content
Plone Bootcamp, Best Practices for Plone Development
private *
pendingsubmit
publishedpublish
reject
retract
publish
retract
reject
• Owners retract, reviewers reject
3.2.2 Workflow Overview
initial state * new statetransition
• State
– Status of content item at a particular point
In general, content undergoes only one workflow, and therefore, has one status.
While the CMF allows content to have multiple workflows associated with it, the UI for handling thisis not developed in Plone. This feature should be quite uncommon, in any event.
• Transition
– Moves from one state to another (generally)
3.2.3 Workflow: Changing States
• Change workflow using workflow menu
• Change via transitions; never direct to state
This event applies in the API: portal_workflow.doActionFor(), covered later, is the APIcall for transitioning content, and is given the transition, not the desired state.
3.2. Workflow 13
Plone Bootcamp, Best Practices for Plone Development
• “Advanced” options
– Enter of effective/expiration dates
– Add comments for transition
If you really like this feature, check out collective.wfcomment, which prompts users for a com-ment when they use the quick transition drop-down change.
– Recurse into folders
Effective and Expiration date are the same regardless of whether entered here or under metadata.
3.3 Contents Tab
3.3.1 Contents Tab
• Perform batch operations on folder
• Reorder items in folder
• Operate on folder
– Edit, sharing, actions, etc
3.4 Exercises
3.4.1 Exercises
1. Create a sample project. Put an overview page into it, and a news item about the project.
2. Publish your project and the content inside of this. How can you do this in one action?
3. Create a place where all the projects could live, and move your project inside of it.
14 Chapter 3. Using Plone: Content
CHAPTER
FOUR
USING PLONE: METADATA
4.1 Introduction
4.1.1 So, You Want To ...?
• Categorize your content
• Give or show credit to contributors
• Create syndicated feeds
• Help editors choose the right types to add
4.1.2 Overview
• Metadata
• Searching/RSS
• Content appearance settings
• Restricting what can be added
4.2 Metadata
4.2.1 Metadata: Categories
• In Plone 2, called “Keywords”
• Central organizing index
• Can control who can edit new keywords
This is set in Roles To Add New Keywords, in Site Setup→ Site Settings
Allowed most users to add new keywords will usually result in a highly polluted keyword space.
15
Plone Bootcamp, Best Practices for Plone Development
• PloneKeywordManager allows cleanup of keyword space
This add-on product allows you to merge similar keywords. For example, you may have “Databases”,“databases”, and “data bases” as three keywords in the Plone Subject vocabulary. PloneKeywordMan-ager will allow you to condense these to any one of these, and will change all content to reflect thissingle choice.
4.2.2 Metadata: Creators
• Creators
– Username (or full names if not users) of “creators”
* People with central responsibility for document
* Not related to security!
– First one appears in byline
4.2.3 Metadata: Credit
• Contributors
– Username (or full names if not users) of contributors
– Appears in byline
4.3 Searching/RSS
4.3.1 Searching Overview
• Uses “catalog”; always up-to-date
Unless scalability measures are taken, such as QueueCatalog covered later. Note that, since 2.1uses the catalog so widely in generating navigation, breadcrumbs, etc., use of QueueCatalog or othercatalog-index-delaying techniques must be evaluated very carefully.
• Respects workflow state
Nothing is shown in catalog the user wouldn’t have permission to actually view the object.
• Advanced search form
– Search by many catalog fields
• Search URL is question, not answer
– Can share with others
– Will change over time
16 Chapter 4. Using Plone: Metadata
Plone Bootcamp, Best Practices for Plone Development
4.3.2 Searching RSS
• Any search result provides RSS feed
RSS is syndication standard used widely for sites to share lists and news items via an XML protocol.
For any search results, Plone generates an “RSS” button that links to an RSS feed of these results.
This RSS link does not have to be used just in the context of interactive searching; the link can becopied and given to RSS consumers, and becomes an easy way to generate arbitrary RSS feeds.
Plone has features for generating RSS feeds from any folder (covered later), and for consuming/usingRSS feeds, covered later.
• RSS feed link is question, not answer
• Might have to embed user auth info in URL
– http://admin:admin@site/rss_search/...
– RSS standard has no auth mechanism itself
• sage is a nice, in-Firefox reader
You can use whatever RSS reader you want, of course.
RSS is especially useful for content administrators: you can create feeds to help you monitor common“problem areas”: that one user who always puts things in the wrong place, or content that was lastmodified over a year ago (perhaps it’s stale?), etc.
4.4 Content Features
4.4.1 Discussion
• Allow comments
– In Plone 2, called “Allow Discussion”
– Can be set for the content type and inherited, or set on the content
– Consider discussion on document vs. in forums
Plone can allow discussion on individual content items, as shown here, or it has products toallow discussion in traditional bulletin board-style forums.
Which you choose is part of the planning for the structure of your site, and depends on howpeople will expect to find such conversation, and whether the discussions are meant more tocontribute toward a community, or more to lend value to each item of content.
A popular, traditional-style discussion board for Plone is Ploneboard.
A replacement, more powerful commenting system use can use in the same way as Plone’s coresystem is Plone Comments.
4.4. Content Features 17
Plone Bootcamp, Best Practices for Plone Development
4.4.2 Exclude from Navigation
• Hide this content from navigation
– Sitemap, too
• Integrators can hide entire types
– eg, hide all Images
This can be controlled by the Site Setup Navigation and Search configlets.
• @PYGZred[Not] related to security!
4.4.3 Table of Contents
• New in Plone 3
• When enabled, shows “table of contents” at top
– Each heading/subheading appears
4.4.4 Next/Previous Navigation
• Setting on normal folders
• Adds next and previous buttons to navigation content:
< Previous: Chapter 1 Next: Chapter 2 >
• Use for chapters in book, etc
4.4.5 What Can Be Added?
• Depends on
– Role / permission mapping
– Type of folder
– Workflow state of folder
– Ad-hoc Restrictions on that folder
4.4.6 Restricting Addables Per Folder
• Can have “addable” and “preferred”
• Select at bottom of Add... menu
• Non-preferred are found by “More” option
– Good to put less-common things here
18 Chapter 4. Using Plone: Metadata
Plone Bootcamp, Best Practices for Plone Development
4.5 Exercises
4.5.1 Exercises
1. Restrict your top-level folder for “Projects” to holding only projects folders.
2. Make an RSS feed to find your project folders.
4.5. Exercises 19
Plone Bootcamp, Best Practices for Plone Development
20 Chapter 4. Using Plone: Metadata
CHAPTER
FIVE
USING PLONE: USERS & ROLES
5.1 Introduction
5.1.1 So, You Want To ...?
• Allow certain users to view/edit projects
• Share content with certain users
• Manage users permissions easily
5.1.2 Overview
• Security concepts
• Adding and managing users
• Sharing
5.2 Security Overview
5.2.1 Permissions
• Permissions: “keys”
– A single capability
* “Can I put my feet on the furniture?”
· Permission: “Put feet on furniture”
• Conceptually connecting users to a permission:
21
Plone Bootcamp, Best Practices for Plone Development
Users Permissions
Jane Add portal content
Modify portal content
ViewJoel
It’s not possible with Zope/Plone secu-rity to directly connect a user to a permission. While it might seem like a good idea to make this kind ofdirect, simple connection, given the number of users and permissions a site will manage, it would quicklybecome impossible to manage.
5.2.2 Roles
• Roles: “hats”
– A bundle of permissions
* “Dinner Guest”, “Editor”, etc
– Not usually checked directly
* Keys checked instead!
– You can have lots of hats at once
• Users get permissions from a role:
22 Chapter 5. Using Plone: Users & Roles
Plone Bootcamp, Best Practices for Plone Development
Users Roles Permissions
Jane Editor
Member
Joel
Add portal content
Modify portal content
View
5.2.3 Groups
• Groups
– A bundle of people
– Can assign roles to a group, and group members get
– Useful for sites with many users
* May be conceptual overkill for smaller sites
• Giving users roles directly, and through a group:
Users Groups Roles Permissions
Jane Finance Editor
Member
Joel
Add portal content
Modify portal content
View
5.2. Security Overview 23
Plone Bootcamp, Best Practices for Plone Development
• Jane’s connection to Editor lasts as long as her group membership
5.3 Users
5.3.1 Adding and Managing Users
• Manage through Site Setup
– Add, delete, edit users
– Add, delete, edit groups
– Add users to group (via group form)
* or, can add groups to user through user form
– Assign “intrinsic roles” to user/group
5.3.2 Intrinsic Roles
• Intrinsic role: Role added to a user/group directly
– Is always present
– Cannot be taken away
Of course, you can go back to Site Setup and remove this assignment, but it cannot be takenaway from them locally in the site.
– Becomes “part of their DNA”
5.4 Sharing & Local Roles
5.4.1 Local Roles
• Can assign a local role via Sharing tab
– User/group has this role only in that section of site
– Very commonly used
* Allow someone else to edit “this stuff”
* Allow group members to see “these private docs”
5.4.2 Roles to Share
• Can view (Reader)
– Can view (even when private/pending)
24 Chapter 5. Using Plone: Users & Roles
Plone Bootcamp, Best Practices for Plone Development
• Can edit (Editor)
– Can edit (but not delete, etc)
– Implies viewing
• Can add (Contributor)
– Can add new content below here
– Does not imply viewing or editing
• Can review (Reviewer)
– Can publish/reject
– Does not imply viewing or editing
* Can edit while pending (“clean up”)
Note: Custom-defined roles and sharing
New roles do not appear on the sharing tab in Plone 3 (unlike earlier versions of Plone). Adding themrequires either editing the Plone source tree, or making new ZCML and code in your product. This iscontrolled in lib/python/plone/app/workflow; see the commented-out code in localroles.py andconfigure.zcml for examples of adding the “missing” roles of Owner, Manager, and Member.
The plonebootcamps.lesson.security product provides an example of adding a role via code.
As “Editor” doesn’t normally allow deletion or sharing, you can’t make someone a true “collaborator”without sharing the Owner role. You can do this via the ZMI, or by showing the Owner role on the sharingtab.
5.4.3 Local Role Pattern
/projects → Share with COO/new-office → Share with PM
/goals/plans/salaries
/2007.xls → Share to collaborate
• Sharing folder shares everything within
– Including subitems
5.4.4 Local Role Blacklisting
/projects/new-office → Shared with Marcus
/goals/plans
5.4. Sharing & Local Roles 25
Plone Bootcamp, Best Practices for Plone Development
/salaries → Should be more secret/2007.xls
• Can turn off “inherit permissions” for salaries
– Marcus doesn’t get role here
* Only his “intrinsic” role of Member
/projects/new-office → Shared with Marcus
/goals/plans/salaries → Inheritance turned off/2007.xls/2006.xls/policies → Can share this to give back
26 Chapter 5. Using Plone: Users & Roles
CHAPTER
SIX
CONTENT TYPES
6.1 Introduction
6.1.1 So, You Want To ...?
• Add new types of content
• Understand Plone’s Python API for content
6.1.2 Cloning Content Types
ATNewsItem.pyPython code
News ItemPlone Registration
Press ReleasePlone Registration
• Re-use type with new semantic meaning
– News Item also is Press Release
– File is also Product Data Sheet
6.1.3 Benefits of Separate Types
• Different appearance
• Different workflow
• Different addable locations
27
Plone Bootcamp, Best Practices for Plone Development
• Different meaning
– Future differentiation
6.2 Content Type Properties
6.2.1 Content Type Properties
• id
– Used in code/API as portal_type
• Title
– What actually appears in the UI
– Used in code/API as Type()
– Allows you to give “local name” to built-in/add-on types
– Doesn’t have to be unique
• Description
– Appears on “Add...” more form, folder factories, etc.
• Icon
– String name of icon
– Must be in skins
– 16x16, any image format
• Product meta type, Product factory method
– To associate with on-disk product
– Don’t change!
• Initial view name
– Not used by Plone
• Allow discussion
– Is this discussable by default?
• Implicitly addable
– Addable to any folder that doesn’t restrict
• Filter content types
– Only allow certain types in this folder
• Allow content types
– Which content types are allowed?
28 Chapter 6. Content Types
Plone Bootcamp, Best Practices for Plone Development
– Check “Filter content types” to restrict to these
• These two only for new, “dynamic view” types
• Default View Method
– ID of skin used for http://site/object
– In static types, this goes to first action
• Available View Methods
– IDs of skins for display menu
6.3 Exercises
6.3.1 Exercises
1. Make a “symposium” content type, based on Events.
6.3. Exercises 29
Plone Bootcamp, Best Practices for Plone Development
30 Chapter 6. Content Types
CHAPTER
SEVEN
COLLECTIONS
7.1 Introduction
7.1.1 So, You Want To ...?
• Create “reports” of your content
• Customize listings in folders
• Help your users find their content
7.1.2 Overview
• Purpose of collections
• Common criteria
• Sorting
• Changing the display
• Collections tips
7.2 Collections
7.2.1 Collections
• Acts like a folder, but really a canned query
• Options for selecting content to include
– And how to sort and display
These were a new name and features in 2.1; previously, Plone had a more limited version called “topics”.
• news and events tabs are collections
31
Plone Bootcamp, Best Practices for Plone Development
7.2.2 Collection Fields
Creation Date, Modification Date Date item was created or last modified
Creator Username of content creator
Item Type Type of content (News Item, Event, etc.)
Location For searching with part of a site
Categories Keywords of content
Search Text Search all of object (title, body, etc.)
State Workflow state
7.2.3 Sorting
• Sort field on criteria tab
– Can choose any sortable field
* Can’t sort by things like SearchableText
7.2.4 Collection Views
• Can view smart folder different ways
– Standard, summary, tabular
– “Collection” view
* Looks like standard, but can batch
* Or can display as customizable table
Note: Views and Limiting Results
There is some inconsistent behavior for Collection views (as of Plone 3.1).
If you check “limit search results” and enter a number for “number of items”, this has different effects forthe different views:
• standard view: truncates display entirely at that number
• summary view: shows full results, but paginates at that number
• tabular view: shows full results, but paginates at that number
• thumbnail view: truncates display entirely at that number
• collection view: shows full results, but paginates at that number
This should probably be considered a bug, but is a useful one, since you can switch from standard view tocollection view to get the same general appearance, but different behavior.
32 Chapter 7. Collections
Plone Bootcamp, Best Practices for Plone Development
7.2.5 Other Fields
• New content types can have new fields
– Books might have “ISBN” field
• These can be added as criteria or display option
To do this, that field would be added to the index and/or metadata of the catalog and then added toCollection in Site Setup.
7.2.6 Collection Tips
• Categories and Location are extremely useful
• Create folder of template collections
– Users copy and modify them
• Collection as the default item in folder
– Get a “custom listing” for the folder
In Plone 3, the “news” and “events” top-level folders are implemented with this very useful pattern.
• You can make new template, if you need to!
7.3 Exercises
7.3.1 Exercises
1. Make a collection that finds all the symposia across the site and lists.
2. Change the display to sort the symposia by date, and show the title, date, and keywords for thesymposia.
7.3. Exercises 33
Plone Bootcamp, Best Practices for Plone Development
34 Chapter 7. Collections
CHAPTER
EIGHT
CONTENT RULES
8.1 Overview
8.1.1 So, You Want To ...?
• Notify people when content is edited
• Track submissions of new content
• Log deletion of content
• ... and much more
8.1.2 Overview
• Powerful, flexible system for performing actions when something happens
– Sending mail on publish
– Moving content on submission
– Logging all edits
8.1.3 Adding a Rule
• Title
• Description
There is a small bug in GenericSetup that makes a content rule without a description unable to beexported. The rule still works fine, but it makes it harder to make snapshots or export the configurationof the site.
Until this bug is fixed, you should consider the description field to be required.
• Event (will clarify with conditions)
• Enabled
– Simple place to turn off w/o hunting down
35
Plone Bootcamp, Best Practices for Plone Development
• Stop Further Rules
– If this happens, don’t look further
8.1.4 Conditions
• Content Type
• File Extension
• Workflow State / Transition
• User group or role
• Can have several; all must be true
8.1.5 Actions
• Log to file
• Notify (web status message)
– Useful for user help
• Copy/Move/Delete
• Transition
• Send Mail
8.2 Limitations
8.2.1 Limitations
• All conditions must apply
– No arbitrary scripted conditions
• Email sending is limited in variable replacements
– collective.contentrules.mail
8.2.2 Useful Add-Ons
• collective.contentrules.mail
– Much more featureful mail sending
• collective.contentrules.parentchild
– Adds condition for presence of children in states
* eg, must be 2+ published images to publish gallery
36 Chapter 8. Content Rules
Plone Bootcamp, Best Practices for Plone Development
• collective.contentrules.webservices
– Provides actions to twitter, send to eventful, and sent to upcoming.org
8.2.3 Road Ahead
• Look at add-on conditions / actions
– Send to Twitter, Eventful, etc
• Learn to dump rules to disk using GenericSetup
• Learn how to write condition / actions
– Requires some Python programming
8.3 Exercises
8.3.1 Exercises
1. Add a content rule to help keep track of executable files added to the example folder. Whenever a*.exe file is added there, an email should be sent to “[email protected]“.
8.4 Exercise Answers
1. Add a content rule to help keep track of executable files added to the example folder. Whenever a*.exe file is added there, an email should be sent to “[email protected]“.
• Add a content rule
– type = for objects added
– condition = where file extension = “exe”
– action = email
– make it active in examples folder
8.3. Exercises 37
Plone Bootcamp, Best Practices for Plone Development
38 Chapter 8. Content Rules
CHAPTER
NINE
BUILDING FORMS
9.1 Overview
9.1.1 So, You Want To... ?
• Build a “grad student” interest form
– Email interest to program manager
– Keep data
9.1.2 PloneFormGen
• Add-on product for Plone
– Extremely stable, well-supported
• Users can build simple web forms TTW
– Or you can build complex ones
– And they can maintain them
9.1.3 Form Folder
• Acts like a normal folder
– Fields get added to it
– And moved up/down
– And can use workflow (don’t by default)
9.1.4 Fields
• String, Text, Rich Text (HTML)
• Whole Numbers, Decimal Numbers
39
Plone Bootcamp, Best Practices for Plone Development
• Dates/Times
• Images, Files
• Selects, Multiselects, Checkboxes
• ... and more
9.1.5 Mailer Adapter
• Sends email after validation
• Can control subjects, addresses, bodies
• One created by default
– But needs an recipient address
9.1.6 Save Data Adapter
• Saves data in ZODB
– Can be downloaded in CSV format
9.1.7 Thanks Page
• Provides “thanks” message
– Or “no data” message
– And lists received fields
9.1.8 Fieldsets
• Can nest fields inside of fieldsets
– Act like folders
9.1.9 Page
• Can add ordinary Plone pages inside
– To reference inside of forms
– Do use workflow–be sure to publish!
40 Chapter 9. Building Forms
Plone Bootcamp, Best Practices for Plone Development
9.2 Customization
9.2.1 Custom Script Adapter
• Can write own PythonScript to handle data
– Write into relational database
– Send via web service
• Other mailer/save-data adapters can happen, too
– Editing form folder lets you choose which
9.2.2 Overriding Field Values
• Can provide “TALES expressions” for choices
– Required?
– Default value?
– Options (in selections)
– Validation
9.2.3 TALES Expressions
• Same as used in Page Templates:
context/getInStock
string: ${user/fullname}, ${user/email}
python: context.validatePrice(...)
9.2.4 Form Overrides
• Form has overrides, too
– Use completely-custom action
– Special setup (to get default values, etc)
– Overall validation
* Useful for birth < death problems
9.2. Customization 41
Plone Bootcamp, Best Practices for Plone Development
9.3 Extending PloneFormGen
9.3.1 Additional Fields
• Captcha fields
• Credit card numbers
9.3.2 Also Good For ...
• Creating real Plone content
– Anonymous content creation
– “Non-technical” editable add forms
– Custom Script Adapter calls invokeFactory()
* Use “proxy role” so script can do what user can’t
9.3.3 Reducing Complexity
• Site Setup configlet
– Control permissions
* Non-managers have far fewer options
– Default email addresses & send addresses
* Can lock down so can’t be changed
9.3.4 Can Write Own Adapters
• Save into database
• Inject into web service
• Existing adapters for PayPal
42 Chapter 9. Building Forms
CHAPTER
TEN
MANAGING PORTLETS
10.1 Overview
10.1.1 So, You Want To ...?
• Add portlets to your site
• Hide portlets in particular sections
10.1.2 Overview
• Adding portlets
• Types of portlets
• User dashboards
10.2 Adding Portlets
10.2.1 Type-Specific Portlets
• Can manage using Site Setup Types
– eg, mission statement portlet appears only on press releases
10.2.2 Group-Specific Portlets
• Can manage using User/Group admin in Control Panel
– eg, policies portlet appears only for members of Staff
43
Plone Bootcamp, Best Practices for Plone Development
10.2.3 Placeful Portlets
• Can add portlets to root of site
– Manage portlets link at the root
• Can add deeper in site
– Portlets appear there and everywhere below
10.2.4 Blocking Portlets
• Allows different behavior in different places
– Block: Don’t show what would normally appear
– Do Not Block: Show as if nothing were blocked
– Use Parent Settings: Do as folder above me
10.2.5 Portlet Types
• Static Text
– For simple text messages
• Collection
– Tie to a collection
– Shows items collection returns
• Classic
– Plone 2.5 portlets work fine
Really, this is useful for any “skin object” portlet. If you can make a simple page template (stored inthe custom folder, in an on-disk skins/ folder, or in Zope3-style views), you can make a portlet. Theseare great for building straightforward new portlets without the overhead of learning the full portletAPI.
• RSS
– Can show any RSS feed
* Useful for showing search results
* Or feed from other site
• Navigation
– Can add more than one!
44 Chapter 10. Managing Portlets
Plone Bootcamp, Best Practices for Plone Development
10.2.6 Useful Add-On Portlets
• plone.portlet.static
– Part of 3.1, “Static Text Portlet”
• plone.portlet.collection
– Part of 3.1, “Collection Portlet”
• plone.portlet.tal
– Add TAL (page template) as portlet
– For lightweight programming
• FeedMixer
– Replacement RSS sender, much improved
10.2. Adding Portlets 45
Plone Bootcamp, Best Practices for Plone Development
46 Chapter 10. Managing Portlets
CHAPTER
ELEVEN
INSTALLING ADD-ON PRODUCTS
11.1 Introduction
11.1.1 So, You Want To ...?
• Add products to your site
• Manage dependencies in one place
• Learn about eggs and classic products
11.1.2 Overview
• Plone configuration
• Installing products
47
Plone Bootcamp, Best Practices for Plone Development
11.2 Product Installation
11.2.1 Multiple Sites and Products
ZopeServer
Add OnProducts
Plone Site 1 Bookstore
Plone Site 2 Blog
• Bookstore is installed on server and configured for site 1 and site 2
• Blog is installed on server and configured for site 2
11.2.2 Installing Products
• Two steps:
1. Get code working in Zope app server
2. Configure which Plone sites will use
11.2.3 What is a Product?
• Just a folder!
– Containing Python, HTML templates, CSS
product
48 Chapter 11. Installing Add-On Products
Plone Bootcamp, Best Practices for Plone Development
11.2.4 What is an Egg?
• Egg = zipped product with metadata
– Modern Plone products are usually released as eggs
* Zipped as file, stored on our servers
egg
dependency info
product metadata
product
11.2.5 Installing Eggs
• Tell buildout you want to install this product
• Regenerate your buildout
11.2.6 Buildout
• Single configuration file for all server setup
– Products to use
– Ports to run Zope on
– Many other configuration settings
• buildout.cfg
• Buildout directory: Location of your setup on server
– c:\pse2010 or /Applications/Plone/pse2010
• Buildout config file: Config file your edit
– buildout.cfg in directory
• Buildout command: Command to regenerate setup
– bin/buildout | bin/buildout | bin\buildout
11.2. Product Installation 49
Plone Bootcamp, Best Practices for Plone Development
11.2.7 [buildout] eggs
[buildout]
eggs =...Products.CSSManager
• Add eggs to install, one per line
– Keep indenting like the lines above it!
11.2.8 Running Buildout
• Stop Zope first!
– Site Setup Maintenance
* Or Control-C in console window
• Run Buildout
– Windows: bin\buildout
– Linux: bin/buildout
– OSX: bin/buildout
11.2.9 After Copying / Buildout
• Restart Zope
– Windows: bin\instance fg
– Linux: bin/instance fg
– OSX: bin/instance fg
• Confirm product is available to Zope
– Root of Zope in ZMI > Control Panel > Products
To check that the product is available to Zope, visit http://yoursite/Control_Panel/Products/manageand look for the icon next to the new product’s name. If it’s a broken icon, click on it and see anyerror messages.
If the product is not listed, Zope either didn’t restart, or the product is not installed in the right direc-tory.
Note that egg products may not list themselves here. It is difficult to be able to tell easily if these eggsinstalled correctly.
50 Chapter 11. Installing Add-On Products
Plone Bootcamp, Best Practices for Plone Development
11.2.10 Configuring Plone to Use
• Site Setup Add-on Products
– Install Log will explain what happened
11.2.11 ZCML “Slugs”
• Most products are that easy to install and configure!
– Some require a tiny bit more
* Those with names not starting with “Products.”
– Have to list in buildout file more than once
– Products.SomeProduct = fine as is
– something.else = need this step
11.2.12 [instance] zcml
[buildout]
eggs =...plone.reload
zcml =...plone.reload
• A product like plone.reload needs to be in both places, eggs and zcml
11.2.13 Your Own Development?
• You can keep the egg on your computer
– They’re normally stored on other servers
• The directory src/ is often where you put it
But you can keep your eggs in any directory you want; you’ll just have to change the develop=location, below, to the real location.
11.2.14 [instance] develop
11.2. Product Installation 51
Plone Bootcamp, Best Practices for Plone Development
[buildout]
develop =...src/Products.MyBookstore
• This assumes you moved Products.MyBookstore egg folder to src/ directory
If you’re developing a product that doesn’t have a name starting with Products, you’ll need to list in thezcml= section, too.
11.2.15 Classic Products
• Some older products aren’t released as eggs
– Just the raw inner product folder
• You can install these with buildout, too
– But you have to tell us where the product is
– You’ll have to install any depedencies yourself
11.2.16 [productdistros]
[productdistros]
urls =...http://foo.com/products/blog-1.0.ziphttp://bar.com/stuff/nifty-2.0.zip
• Will download and install blog and nifty classic products
11.2.17 Installing Overview
• All eggs are listed in eggs=
– Doesn’t start with “Products.”? List in zcml=, too
– Developing it yourself? Store it in src/ and list in develop=
• Classic products are listed in productdistros url= section
52 Chapter 11. Installing Add-On Products
Plone Bootcamp, Best Practices for Plone Development
11.2.18 Installation Flowchart
Isproduct an
egg?Add egg name to eggs=
yes
Add URL to productdistros
no
Doesname
start with'Products.'
?
Stopserver
Add egg name to zcml=no
Are youdeveloping this
yourself?
yes
Move your egg to 'src/' directoryAdd path (src/eggname) to develop=
yes
no
Run buildoutcommand
Startserver
Configure site touse with Site Setup
11.2.19 Buildout Example
[buildout]
eggs =Products.Glowormplone.reloadProducts.MyBookstoremy.product.blog
zcml =plone.reloadmy.product.blog
develop =src/Products.MyBookstoresrc/my.product.blog
[productdistros]
urls =
11.2. Product Installation 53
Plone Bootcamp, Best Practices for Plone Development
http://foo.com/products/classicproduct.zip
11.2.20 Debugging Product Installation
1. Does product appear in the Zope product list?
http://site/Control_Panel/Products/manage_main
If so, we know the Python code for the product is registered with the application server.
If not, you probably either didn’t get the product into your server, or haven’t successfully restarted theserver.
Also, check the instance.log, in case there are messages in there about errors that prevented yourproduct from even installing itself.
2. Are there errors in that listing?
If so, read the traceback and fix the problem.
3. Does it appear in Plone “Add Product” list?
Not all products should appear in the Plone “Add Product” list; pure Zope (non-Plone) products(like FSDump or DocFinderTab) have no Plone-specific skins to register, and, as such, don’t requireconfiguration via Plone.
If it should appear in “Add Product”, the Plone installer for it might be broken, or have unmet depen-dencies. For older products, you can debug this by doing the following:
Add an ExternalMethod like:
Name testInstall
Module ProductName.Install
Method install
Then test adding this installer, and fix any errors returned. This install method is essentially what the“Add Product” tries to run.
11.3 Exercises
11.3.1 Exercises
1. Install the product PressRoom to your server. It’s a classic product at Plone.org.
54 Chapter 11. Installing Add-On Products
CHAPTER
TWELVE
BUILDING A SITE
12.1 Introduction
12.1.1 Introduction
• How to structure site
• Site building overview
12.2 Structuring Site
12.2.1 How to Structure Site
• One flat folder:
http://site.org/all-content
– Provides little context for editors
– Don’t get any free navigation, UI
– Sharing hierarchically is pointless
• Member’s folder:
http://site.org/Members/joel/project-a
– “My Documents” feeling
– Bad URLs
* What happens when ownership moves?
· Wrong location or broken URL
– Useful for community sites
• Folder of like content:
55
Plone Bootcamp, Best Practices for Plone Development
http://site.org/events/party
– Requires users to have permissions here
– Useful when one person/department manages items of that type
• By project / authority:
http://college.edu/chemistry
http://college.edu/biology
– Location should follow security
– Generally, the most useful
– Type-specific folders within:
http://college.edu/chemistry/events/party
12.2.2 Building a Plone Site
• What types of content?
• What kind of security/workflow?
• How should content look?
• How should site look?
• Deployment considerations
12.3 Exercises
12.3.1 Exercises
1. Make a list of the types of content you want to store on your site. Which are included in standardPlone?
2. Make a drawing of how you’d like to organize your site, to best suit your content managers, sitevisitors, and security concerns.
56 Chapter 12. Building a Site
CHAPTER
THIRTEEN
CONTENT TYPES
13.1 Introduction
13.1.1 So, You Want To ...?
• Add new types of content
• Understand Plone’s Python API for content
13.1.2 Overview
• Contentish & folderish
• Content type properties
• Building content types by cloning
• Content API
13.1.3 Contentish
• Addable through Plone UI
– Added through Plone: content
– Added through ZMI: tool or skin object
• Workflow-able
• Searchable
• Skinnable
13.1.4 Thinking Cap
Content or skin?
• images
57
Plone Bootcamp, Best Practices for Plone Development
• Flash
• CSS
13.1.5 Folderish
• Can contain items
• Uses Plone folder UI
• Examples:
– Project
– Person (contains resume, pictures, etc.)
13.1.6 Cloning Content Types
ATNewsItem.pyPython code
News ItemPlone Registration
Press ReleasePlone Registration
• Re-use type with new semantic meaning
– News Item also is Press Release
– File is also Product Data Sheet
13.1.7 Benefits of Separate Types
• Different appearance
• Different workflow
• Different addable locations
• Different meaning
– Future differentiation
58 Chapter 13. Content Types
Plone Bootcamp, Best Practices for Plone Development
13.1.8 Archetypes
• Powerful system for creating content
• Similar to specifying field types in database
• Creates views, edit forms, validators
• Significantly more flexible in the future
13.2 Content Type Properties
13.2.1 Content Type Properties
• id
– Used in code/API as portal_type
• Title
– What actually appears in the UI
– Used in code/API as Type()
– Allows you to give “local name” to built-in/add-on types
– Doesn’t have to be unique
• Description
– Appears on “Add...” more form, folder factories, etc.
• Icon
– String name of icon
– Must be in skins
– 16x16, any image format
• Product meta type, Product factory method
– To associate with on-disk product
– Don’t change!
• Initial view name
– Not used by Plone
• Allow discussion
– Is this discussable by default?
• Implicitly addable
– Addable to any folder that doesn’t restrict
13.2. Content Type Properties 59
Plone Bootcamp, Best Practices for Plone Development
• Filter content types
– Only allow certain types in this folder
• Allow content types
– Which content types are allowed?
– Check “Filter content types” to restrict to these
• These two only for new, “dynamic view” types
• Default View Method
– ID of skin used for http://site/object
– In static types, this goes to first action
• Available View Methods
– IDs of skins for display menu
13.3 Content API
13.3.1 Basic Object API
getId()ID of object
portal_typeID of content type
Type()Title of content type (ID if title is blank)
13.3.2 getFolderContents
getFolderContents([contentFilter, batch, b_size, full_objects])Returns “brains” for content items in folder
Parameters
• contentFilter – Dictionary of catalog filter
• batch (True or False) – Batch results (defaults to False)
• b_size (integer) – Batch size
• full_objects (True or False) – Return full objects instead of brains
Return type List of brains
• Fast but not real objects (uses catalog)
– Useful for listings, etc.
60 Chapter 13. Content Types
Plone Bootcamp, Best Practices for Plone Development
• Can pass full_objects=True
– Slower, but real objects
• Can pass dictionary to restrict results:
getFolderContents({ ’portal_type’: ’News Item’,
’Subject’ : ’Site Design’ } )
13.3.3 Metadata API
Title()
Description()
Subject()“Keywords” on metadata form
Creators()Return list of all creators
Creator()Return first item in Creators() list
Contributors()In list form
CreationDate()
ModificationDate()
isEffective(date)Is object effective/not expired for date
13.4 Exercises
13.4.1 Exercises
1. Which of these would be “contentish”?
• book
• page listing recently-added books
• photo of your board chair
• template for viewing press releases
• calendar showing events this month
• sitemap
(Some of them may be either, depending on your needs)
13.4. Exercises 61
Plone Bootcamp, Best Practices for Plone Development
2. Create a feature for your site for product data sheets.
• Data sheets are just HTML pages (not PDFs, etc)
• There will be many (500+) data sheets
• They will be kept in one folder which, ultimately, might look different than normal folder
• Sheets cannot go anywhere else in site
• Only data sheets go in the folder
Create new types, DataSheet and DataSheetFolder, and make this work.
3. Which view is the best choice for the default view for the data sheet folders? Change it to that.
13.5 Exercise Answers
1. Which of these would be “contentish”?
• book
• page listing recently-added books
• photo of your board chair
• template for viewing press releases
• calendar showing events this month
• sitemap
(Some of them may be either, depending on your needs)
• book - yes
• photo of your board chair - yes
2. Create a feature for your site for product data sheets.
• Data sheets are just HTML pages (not PDFs, etc)
• There will be many (500+) data sheets
• They will be kept in one folder which, ultimately, might look different than normal folder
• Sheets cannot go anywhere else in site
• Only data sheets go in the folder
Create new types, DataSheet and DataSheetFolder, and make this work.
• Copy and paste the Page and Large Plone Folder types to DataSheet and DataSheetCenter,respectively.
• Make data sheets not implicitly addable.
• Make data sheets addable to the new folder, and filter to just this.
• Make the new folder implicitly addable.
62 Chapter 13. Content Types
Plone Bootcamp, Best Practices for Plone Development
3. Which view is the best choice for the default view for the data sheet folders? Change it to that.
• the tabular view
13.5. Exercise Answers 63
Plone Bootcamp, Best Practices for Plone Development
64 Chapter 13. Content Types
CHAPTER
FOURTEEN
BASIC ARCHETYPES
14.1 Introduction
14.1.1 So, You Want To ...?
• Design custom content types quickly & easily
• Decide which fields are required and have defaults
• Change the appearance of fields on forms
14.1.2 Overview
• Building content types in UML
• Understanding field types
• Field parameters
• Widget parameters
14.1.3 ArgoUML
• Open source UML program
• Written in Java
– Works on any operating system
14.1.4 Starting ArgoUML
• In class:
– Windows: bin\argouml
– Linux: bin/argouml
– OSX: bin/argouml
65
Plone Bootcamp, Best Practices for Plone Development
14.1.5 Packages
• Everything inside model becomes product
• Packages subdivide elements
• Content types should go in “content” package
– Not required
– But conventional and organized
14.1.6 A Simple Content Type
content
Movie
director : stringreleased : daterating : int
Title of class (capitalized)
Fields (lowercased)Written as 'fieldname : type'
Methods
14.1.7 Building with Web Service
• http://uml.joelburton.com
– Easy to use
– Fewer options for advanced users
– Can view results, or receive as archive for installation
14.1.8 Building with Command Line
• Local version of web-based converter:
– Format is archgenweb model [classic|egg] (defaults to egg)
66 Chapter 14. Basic Archetypes
Plone Bootcamp, Best Practices for Plone Development
– Windows: python\python.exe bin\archgenweb model.zargo
– Linux: bin/archgenweb model.zargo
– OSX: bin/archgenweb model.zargo
• Can also use the underlying ArchGenXML converter
– Provides more options; see --help for list
* Most are very esoteric
– Windows: python\python.exe bin\archgenxml model.zargo
– Linux: bin/archgenxml model.zargo
– OSX: bin/archgenxml model.zargo
If you do build using ArchGenXML directly, there’s one option that you’ll definitely want to choose, –detailed-creation-permissions=yes. This makes a new named permission for every class in your model. Ifthis isn’t chosen, then you share one permission for all your content-types-adding, which makes it difficultto control separately.
As of June, 2008, this became the default for the command-line converter.
If you use the web-based converter, this has always been the default.
ArchGenXML itself cannot build eggs; you’ll have to use the web based converter or the archgenwebwrapper to do this.
14.2 Field Types
14.2.1 Field Types: Textual
string
•Strings (single paragraph, plain text)
text
•Paragraphs
richtext
•HTML or other formats
14.2.2 Field Types: Numbers
int
•Integer (non-fractional) numbers
float
•Floating-point numbers
14.2. Field Types 67
Plone Bootcamp, Best Practices for Plone Development
There’s also a fixedpoint field type for fixed-precision math. This is similar to “decimal” or “numeric”types in most relational databases.
14.2.3 Field Types: Files/Images
file
•Any “opaque” file format
image
There is a tempting-sounding field type, photo. This should not be used. Instead, image should be used.
14.2.4 Field Types: Additional
boolean
•Yes/No
dateThe date type is used for dates, times, and dates and times (often called datetimes or timestamps).
lines
•Text box treated as list of items
14.3 Field Attributes
14.3.1 Common Field Attributes
required = True or False (default false)
default = Default value
searchable = True or False
•Can be searched for using Plone search box
•Becomes SearchableText
Technically, this means is this field’s value being output as part of SearchableText(), aconcept covered in the chapter on the Catalog.
14.4 Widgets
14.4.1 Widget Choices
widget:label = Label on form
•Defaults to name of field
68 Chapter 14. Basic Archetypes
Plone Bootcamp, Best Practices for Plone Development
widget:description = Description on form
14.5 ArgoUML Tips
14.5.1 ArgoUML Tips
• Will get errors for empty tagged values or tagged value with empty value
• Delete things from model, not just diagram
• Keep incremental copies of model
• Restart occasionally
• Upgrade!
14.6 Exercises
14.6.1 Exercises
1. Design a content type, Book, having fields for:
• book title
• publisher
• book price
• publication date
• author name
Draw this in the UML editor and make good choices for the attributes (like required,searchable, etc)
14.5. ArgoUML Tips 69
Plone Bootcamp, Best Practices for Plone Development
70 Chapter 14. Basic Archetypes
CHAPTER
FIFTEEN
PASTER
15.1 What Is Paster?
15.1.1 Paster Intro
• Tool to create skeleton projects
– Buildouts
– Archetypes products
– Theme Products
– More
15.2 Using Paster
15.2.1 Using Paster
• Web-based: http://paster.joelburton.com
• Command-line: bin/paster
• Result is the same
15.2.2 Creating Archetype Product
• For Archetype-based product:
$ bin/paster create -t archetype
Enter project name: Products.sampleEnter title: Sample ATEnter namespace_package: ProductsEnter package: sampleEnter zope2product: True Important!
71
Plone Bootcamp, Best Practices for Plone Development
...Enter zip_safe: False
15.2.3 Local Commands
• When inside package, other commands are available:
$ bin/paster addcontent -l
Available templates:atschema: A handy AT schema builder → Add fieldcontenttype: A content type skeleton → Add content typeportlet: A Plone 3 portletview: A browser view skeleton
15.2.4 Creating an Archetype
• Go into your AT-based product:
$ bin/paster addcontent contenttype
Enter contenttype_name: ExampleTypeEnter contenttype_description: Description...Enter folderish: False or TrueEnter global_allow: True or FalseEnter allow_discussion: False or True
15.3 Road Ahead
15.3.1 Running On Your Computer
• You need ZopeSkel
• Included by bootcamp buildout
– Windows: bin\paster
– Linux: bin/paster
– OSX: bin/paster
• Or, can install with easy_install:
– Linux: easy_install ZopeSkel
72 Chapter 15. Paster
CHAPTER
SIXTEEN
PICKING A WORKFLOW
16.1 Overview
16.1.1 Overview
• Plone’s built-in workflow
• Designing your workflow
16.2 New Workflows
16.2.1 Simple Publication Workflow
private *
pendingsubmit
publishedpublish
reject
retract
publish
retract
reject
• Retract: owner/editor makes private to re-edit
• Reject: reviewer makes private by not approving
– In Plone 3, this is labeled as “Send Back”, but the transitions real name is still “Reject”
73
Plone Bootcamp, Best Practices for Plone Development
• Things start out as private
• Owner can edit things when published
16.2.2 One State Workflow
published *
• Single, published state
– More useful than “no workflow”
* We can control security
* Things looking for “published” will find
Note: One State Workflow versus No Workflow
A content type can, instead, be registered to not use workflow at all (in standard Plone 3, files and imagesdo not use workflow). In this case, the content object acquires the permission settings of the parent folder(an image is as visible as the folder it is inside). This is useful for things like images, where you may notconsider them to “have” workflow, and where they should always just snap to their enclosing folder.
One state workflows are more useful in cases where the object is “always approved”–without considerationto where it is.
Another distinction is that portlets/collections that look for items in the state of published will not findworkflow-less items (such as images and files).
74 Chapter 16. Picking a Workflow
Plone Bootcamp, Best Practices for Plone Development
16.2.3 Community Workflow
private visible *showhide
pending
submit
published
publish
reject
retractpublish
retract
reject
• Almost same as Plone 2 “Plone Workflow”
– Immediately visible in public draft
– Owner cannot edit while published
* Must retract to edit and then re-submit
• Possibly useful for community sites
– Not usually useful for corporate/nonprofit/educational
16.2.4 Intranet/Extranet Workflow
private draft *hideshow
internal
publish internally
pending
submit
reject
retract
external
publish externally
reject
retract
publish externally
reject
16.2. New Workflows 75
Plone Bootcamp, Best Practices for Plone Development
• “Externally visible” is all that anon can see
• Must retract to edit
• Initial state is internally-viewable
• Essentially: community workflow + internal-only stuff
– Not particularly common case
16.2.5 Folder-Specific Workflows
• Special workflow designed for folders
– Does not mean content “snaps to” or respects folder state
* That’s decided by the workflow of the content
• Most people find confusing
16.2.6 Community Folder Workflow
private
draft *show
publishedpublish
hide
published
reject
reject
• Same as 2.5 “Folder Workflow”
• As useless as ever :)
16.2.7 Intranet/Extranet Folder Workflow
private * draftshow internally
hide
• For folders in Intranet workflow
76 Chapter 16. Picking a Workflow
Plone Bootcamp, Best Practices for Plone Development
– Just private and internal states
• Often better: use Intranet/Extranet Workflow
16.3 Workflow & Content
16.3.1 Files & Images
• Files & Images don’t ship with assigned workflow
This was introduced in Plone 3; in previous versions of Plone, where a public draft/community-styleworkflow was the default workflow, files and images used this default workflow.
– Fixes common case of forgetting to publish
* Leading to “broken” links/images
• Can easily assign to a workflow
– Using the Site Setup Types configlet
16.3.2 Default Pages
• Default page workflow is different from folder workflow
– Constant confusion
• Plone 3 tries to keep in sync
– When default page undergoes workflow, same transition attempted on folder
* Name must match
– Transitioning folder does not transition page
Note: Jettisoning default pages
This is one of many reasons why I find default pages to be quite confusing for users–they constantly have toremember the workflow state of the default page versus the folder; the have to keep track of which they’reediting, which they’re viewing, etc.
Typically, for most sites, you don’t need the real distinction of having any arbitrary piece of content becomethe default page. Instead, you just want “a folder with a rich body field”. In my “Building a HumaneCMS with Plone” conference presentation, I talk about my successes with a “section” content type that doesexactly this.
16.4 Workflow Design
16.4.1 Problems with Workflow
• Joel’s Immutable Law of Reviewer Attention Span:
16.3. Workflow & Content 77
Plone Bootcamp, Best Practices for Plone Development
A =12n
where *n* is number of items to review, and *A* is resultant attention
1 item = 50%, 2 items = 25%, 6 items = <2%
• “Workflow” can’t guarantee quality
• Address the core issues
– Simpler CMS
– Fewer possible mistakes
– More visibility for editors
16.4.2 A Trusting Workflow
• Things start as private
– People expect that
• People can self-publish
• Most important: can ask for help when they need it
– And reviewers know they’re wanted
private *
pendingrequest help
publishedpublish
hidepublish
hide
16.4.3 Useful Supporting Features
Content Rules Can email people on new content, new publication.
Add... restrictions Can reduce number of potential mistakes
Styles in Kupu Can make editing content simpler to get right
Collections Can help find “lost” content (unreviewed, private)
Versions Can revert to older version
Staging Can test of edits safely then commit
Archetypes Can design structured types for fewer editor problems
78 Chapter 16. Picking a Workflow
Plone Bootcamp, Best Practices for Plone Development
16.5 The Road Ahead
16.5.1 The Road Ahead
• Learn about Placeful Workflow, an add-on product for different mappings of type → workflow in asection of site
16.6 Exercises
16.6.1 Exercises
1. What should your workflow for standard web content look like? How can you balance quality controlversus reality? On pen and paper, sketch out a diagram of your workflow.
2. What features of Plone can you use to help guarantee quality work or otherwise support your work-flow?
16.5. The Road Ahead 79
Plone Bootcamp, Best Practices for Plone Development
80 Chapter 16. Picking a Workflow
CHAPTER
SEVENTEEN
SECURITY
17.1 Introduction
17.1.1 So You Want To ...?
• Control who can perform which actions
• Manage security on multiple Plone sites
• Store users in LDAP or relational databases
• Change password for admin user
17.1.2 Overview
• Permissions
• Roles
• Groups
• Users
• Membership
• APIs
17.2 Permissions
17.2.1 Security Overview
• Overview of security
81
Plone Bootcamp, Best Practices for Plone Development
Users Groups Roles Permissions
Jane Finance Editor
Member
Joel
Add portal content
Modify portal content
View
17.2.2 Permissions
• Ability to do something
– Checked by declaration
– Or explicitly
• eg Add portal content
• Can see list of “security” tab of portal
– Only need to learn a few
17.2.3 Detail on Permissions
• Not defined anywhere central
– Permission is just a string
– Spell it correctly! (case counts)
• What does a particular permission do?
– Not documented well
– grep for it in source code
17.2.4 Perms: View Content
Access contents informationCan access anything about object (get title, see in folder listing, etc.)
82 Chapter 17. Security
Plone Bootcamp, Best Practices for Plone Development
ViewCan use normal view skin to view object
Can IGet From DB?
Access contentsinformation
CanI View?
View
yes
Access deniedno
Ok to viewyes
no
17.2.5 Perms: Adding Content
Add portal contentAble to add content (req’d to add anything)
ATContentTypes: Add [TYPE]Able to add built-in content TYPE
YourProduct: Add [YOURTYPE]Able to add a type of a new product
Add portal topicsAble to add Smart Folder
For historical reasons, adding a smart folder is controlled by this non-standard-sounding permissionname.
You’ll also want to grant all ATContentTypes: Topic: items, which are the individual criteria types.
17.2.6 Perms: Modifying Content
Modify portal contentCan user modify other portal content
17.2.7 Perms: Content Management
Copy or MoveCopy or move content around, either in ZMI or Plone UI
Delete objectsDelete content, either in ZMI or Plone UI
17.2. Permissions 83
Plone Bootcamp, Best Practices for Plone Development
17.2.8 Perms: Reviewing
Request reviewCan the user request this document for a review? (submit transition in normal workflow)
Review portal contentCan the user approve this document (publish transition in normal workflow)
17.2.9 Perms: Discussion
Reply to itemCan add a reply on an object. Object must allow discussion.
17.2.10 Permissions: Managing Users
Add portal memberRequired to join site
Manage usersManage users (add/edit)
To control who can edit users, change passwords, etc., use
17.2.11 Creating a New Permission
• Just write it!
– Easiest: use in Archetypes
* read_permission or write_permission
• Be careful not to do so accidentally!
– eg, typo in permission name
17.3 Roles
17.3.1 Roles
• Grouping of permissions
• eg “Editor”
– Includes adding, editing, deleting content
• User can have than one role at a time
84 Chapter 17. Security
Plone Bootcamp, Best Practices for Plone Development
17.3.2 Built-in roles
• Content Management
EditorCan edit
ContributorCan add things here
ReaderCan view (even when private)
• Site Roles
ReviewerCan publish
MemberSite member (everyone has)
• Technical Roles:
OwnerCreator of this object
ManagerZMI access, site setup, etc.
• Auto roles:
AuthenticatedAnyone logged in
Anonymous
17.3.3 Local Roles / Sharing
• Giving a role to user/group for this object
– And all child objects
• Uses
– Reviewer for section of site
– Share ownership of object
• “Sharing” tab of Plone UI
• “local roles” link in “Security” tab of ZMI
17.3. Roles 85
Plone Bootcamp, Best Practices for Plone Development
17.4 Debugging Security
17.4.1 Debugging Security
• Comment out Unauthorized in Site Setup Errors:
#Unauthorized
• Change verbose-security to on in buildout.cfg
– Dramatically improved error messages
17.5 Plone PAS
17.5.1 Plone PAS
• “Pluggable Authentication System”
– Allows replacement of any part of security system
– ie, can write new role-checking-system or user-storage
• In Plone 2.5+
17.5.2 PAS Concepts
• Challenge: “who are you?”
• Credentials: “Joel; here’s something to prove it...”
• Authentication: “Yes, you are”
• Group assignment: “You’re part of ...”
• Role assignment: “You act like...”
• Enumeration: listing of users
• User adding/Editing of users
86 Chapter 17. Security
Plone Bootcamp, Best Practices for Plone Development
Challenge
Credentials
Authentication
GroupAssignment
RoleAssignment
Login Form
Username/Passwordfrom form
Sessionfrom
cookie
ZODB(standardsource)
ZODB(standardsource)
SQLDatabase
ZODB(standardsource)
LDAP
• Each step can have multiple activated plugins
17.5.3 PAS Plugins
• Examples
– Users/groups/roles from SQL: SQLPASPlugin
– LDAP: PAS LDAP Docs
– Role for in-network people: AutoRole
– Can’t login twice at same time: NoDuplicateLogin
• Many others: Authentication Add-Ons
17.5.4 “Admin” User
• Created during installation
• Stored in root of Zope
– Above Plone
– Manager of all sites
– Somewhat magical
– Don’t recommend for day-to-day content management
17.5.5 Changing Admin Password
• Root of Zope, acl_users
• Find user in Users
17.5. Plone PAS 87
Plone Bootcamp, Best Practices for Plone Development
17.6 API
17.6.1 Permissions API
checkPermission([permissionName, object])Checks if object has permission permissionName.
Parameters
• permissionName – String name of permission
• object – Object to check
• In a Plone Template, globally defined as checkPermission()
• Checking “Modify portal content” for context is globally defined as is_editable.
17.6.2 User API: Page Templates
user“Unwrapped” user object
memberUser “wrapped” with memberdata fields (eg, email)
•Example:
<i tal:content="member/email">[member address]</i>
17.6.3 User API: Scripts / Clouseau
getAuthenticatedMember()
•Example:
user=context.portal_membership.getAuthenticatedMember()
17.6.4 Member API
• All found on member object
getUserName()
Returns Userid (“joel”), not fullname
[property]
•ie, member.email
•Properties defined in portal_memberdata Properties
88 Chapter 17. Security
Plone Bootcamp, Best Practices for Plone Development
17.6.5 Membership API
getAuthenticatedMember()Current member; same as member in Plone ZPTs
listMembers()
listMemberIds()
getMemberById(id)
Parameter id – ID of member to find
• portal_membership is defined as mtool in Plone templates
17.6.6 Groups API
getGroupsByUserId(userid)
Returns list of the groups the user belongs to
Call this on the portal_groups object.
Warning: Not the Best Way!In many cases, It’s usually better to check if the user has a permission, rather than checking if the user isin a group.This allows you to be more flexible about groups in the future, and not hard-code in groups/abilitieslogic. That’s exactly what permissions are for.
17.7 Road Ahead
17.7.1 Road Ahead
• Learn how to add roles
– And get them to appear on “sharing” tab
• Investigate PAS plugin products
• Learn to write a PAS plugin
17.8 Exercises
17.8.1 Exercises
1. Normally, anyone who can contribute content somewhere can add a news item. Change it so that onlymanagers can add news items.
17.7. Road Ahead 89
Plone Bootcamp, Best Practices for Plone Development
17.9 Exercise Answers
1. Normally, anyone who can contribute content somewhere can add a news item. Change it so that onlymanagers can add news items.
• In the Security tab of your portal, find the lines for ATContentTypes: Add News Item. Change itso that it doesn’t acquire, and is set only for managers.
90 Chapter 17. Security
CHAPTER
EIGHTEEN
WORKFLOW
18.1 Introduction
18.1.1 So, You Want To ...?
• Custom Plone’s workflows
• Design your own workflow
• Control additional permissions with workflow
18.1.2 Overview
• The team of monkeys
• Understanding states and transitions
• Mapping types to workflow
18.2 Monkeys
18.2.1 Monkeys With Clipboards
• Workflow isn’t magic; it’s monkeys
– They just check & uncheck things on the security tab when the state changes
– The security tab always “tells the truth”
18.3 States
18.3.1 Standard Plone Workflow
• Simple Publication Workflow:
91
Plone Bootcamp, Best Practices for Plone Development
private *
pendingsubmit
publishedpublish
reject
retract
publish
retract
reject
18.3.2 New Workflows
• Copy an existing workflow; don’t start from scratch
– Don’t modify built-in workflows
* Copy and customize it, instead
* Some products/people assume normal built-in workflows
18.3.3 Self Approval Workflow
We want a workflow where...
• Staff have easy collaboration initially
• Creators can publish own work without approval
• Creators can continue to update published work
• If any staff finds page with problem, they can hide it
private * publishedpublish
hide
• Private: Any site member can see, but not the public
• Published: Owners/editors/managers can edit
92 Chapter 18. Workflow
Plone Bootcamp, Best Practices for Plone Development
• Any owner/manager/reviewer can publish
• Any site member can hide
18.3.4 States
• Status of content at a particular point
In general, content undergoes only one workflow, and therefore, has one status.
While the CMF allows content to have multiple workflows associated with it, the UI for handling thisis not developed in Plone. This feature should be quite uncommon, in any event.
• State controls several critical security settings
– Access information about, View, and Edit
– For example: content can be viewed when published but not edited.
• State also used in application-dependent ways
– Content may appear different
18.3.5 Adding a State
• id (best not to change)
Several places in Plone are hard-wired or semi-hard-wired to look for things with the state name“published”, and, in your own code, you may begin to looking for things with your own state names.
• Title
• Description
– Not used by Plone UI
• Possible Transitions
– Which transition can happen from here?
– Transition guards still in effect
18.3.6 State Permission Grid
• “Monkey work order”
– Check to give that role that permission when content in state
• Permissions are inherited from folder above
18.3. States 93
Plone Bootcamp, Best Practices for Plone Development
– Unless Acquire permission settings? box is unchecked
– Easiest to uncheck until you need it
18.3.7 State Permissions
Access contents information Get object at all
Modify portal content Edit this item
View View item with skin
• Grant/revoke Access contents information and View in tandem
18.3.8 Self Approval Workflow States
• Private
– View = Member
– Modify portal content = Member
• Published
– View = Anonymous + Authenticated (everyone)
– Modify portal content = Owner + Manager + Editor
Also, Acquire... should be unchecked for these permissions.
Our workflow requirements didn’t address the question of who can add new content, so we’ll leave that withthe current settings. If this workflow were being used for folderish types of content (like Folders), we’d haveto address this issue and make the appropriate choices for Add portal content.
18.4 Transitions
18.4.1 Transitions
• Can be guarded by a permission, role, or expression
– Only allowed transitions are shown
• Scripts can be run before or after transition
– eg: move, rename, or send email
– Much of this can now be done with Content Rules.
• Transitions can (but don’t have to) move content between states
– “comment-only” transitions are useful
94 Chapter 18. Workflow
Plone Bootcamp, Best Practices for Plone Development
This is a “null” transition that does not change the state of the content. It’s useful for addingcomments about the content while not moving the state. Plone does not have such a transitionby default, but it’s easy to add one, and is covered later.
18.4.2 Adding a Transition
• Id (best not to change)
• Title
• Description
– Not used by Plone UI
• Destination State
– Where does transition go to?
– “(remain in state)” useful
• Trigger Type
– Initiated by user action
* Most common
* User chooses from transition drop down
– Automatic
* Tries to make happen after any other transition
• Scripts
– Called before/after transition
– Before scripts can cancel transition
• Guards
– Permission (“;” separate for one-of-many)
– Roles (“;” separate for one-of-many)
* Manager, Reviewer, etc.
– Expression
* TALES expression
• Display in Action Box
– What appears in Plone drop-down menu
– Name
– URL
18.4. Transitions 95
Plone Bootcamp, Best Practices for Plone Development
* Must contain URL like in standard workflows
An interesting advanced idea: the URL doesn’t have to be the normal one. This is the URLthat the UI takes you to when you choose this transition. It could go to a form that gathersinformation (like the workflow comment) and then submits to the standard script, whichactually performs the transition.
– Category
* Normally “workflow”
18.4.3 Self Approval Transitions
• publish
– Guard: Permission = Modify portal content or Role = Member
* (Depending on how you want to think about it)
• retract
– Guard: Role = Member
18.4.4 Reviewing Workflow
• DCWorkflowGraph
– Graphs workflow; handy for noticing problems
A product in the Collective that shows graph of the current workflow. In particular, the graphs in thesematerials were generated from the workflow graphs from DCWorkflowGraph (with a bit of tweaking).
– Requires installation of Open Source utility
It requires GraphViz, which has binary packages for Windows, Linux, and OSX, and is an easyinstall.
18.5 Mapping to Types
18.5.1 Mapping Workflow to Types
• In Plone 2, could only be done on portal_workflow “Workflows” tab
• In Plone 3, better to use Site Setup Types configlet
– Easier to understand
– Provides ability to choose mappings of old state to new state for existing content
96 Chapter 18. Workflow
Plone Bootcamp, Best Practices for Plone Development
18.6 Additional Permissions
18.6.1 Adding Controlled Permission
• Permissions tab on workflow controls perms
– Business logic may require adding new ones
* Can’t delete when published (Delete objects)
* Can’t discuss when published (Reply to item)
18.7 Road Ahead
18.7.1 Road Ahead
• Use “groups” feature of workflows
– Injects role for group members in a certain state
• Workflow scripts
• Workflow expressions
18.8 Exercises
18.8.1 Exercises
1. Make a copy of the Simple Publication Workflow to customize it. You don’t want to allow people toimmediately publish from the private state; everything should go to pending first. Implement this.
2. Further modify your new workflow so that, once a piece of content is published, it cannot be edited.To edit it, you’d need to retract it (or stage it), and then edit it. However, managers should be able toedit content that is published.
18.9 Advanced Exercises
18.9.1 Advanced Exercises
3. Further modify your new workflow so it has a “comment-only” transition: a transition that goesnowhere, but is useful for adding comments about the piece of content. Any site member can addworkflow comments.
4. A common idea to make the site easier to manage is to encourage people not to delete con-tent, but “archive” it, using a transition, archive, that moves content into an ultra-private state.
18.6. Additional Permissions 97
Plone Bootcamp, Best Practices for Plone Development
archived
private *restore
archive pending
submit
publishedpublish
archive
reject
retract
publish
archive
retract
reject
How could you solve this?
5. Extend the above exercise so that owners can archive things, but no one but managers can actuallydelete things.
18.10 Exercise Answers
1. Make a copy of the Simple Publication Workflow to customize it. You don’t want to allow people toimmediately publish from the private state; everything should go to pending first. Implement this.
• Clone Simple Publication Workflow
• In States, “Private”, uncheck the transition for “publish”
2. Further modify your new workflow so that, once a piece of content is published, it cannot be edited.To edit it, you’d need to retract it (or stage it), and then edit it. However, managers should be able toedit content that is published.
• In States, “Published”, under the “Permissions” tab:
– Uncheck all roles for Modify portal content except Manager
3. Further modify your new workflow so it has a “comment-only” transition: a transition that goesnowhere, but is useful for adding comments about the piece of content. Any site member can addworkflow comments.
• Add a “comment-only” transition
• Destination is (remain in state)
• Add a guard role of Member (otherwise, anonymous could comment!)
98 Chapter 18. Workflow
Plone Bootcamp, Best Practices for Plone Development
• Don’t forget to add a name for “Display in Action Box”; this is what appears, and to copy andmodify the “URL field from another transition to get that right.
• Make this a possible transition from all states.
4. A common idea to make the site easier to manage is to encourage people not to delete con-tent, but “archive” it, using a transition, archive, that moves content into an ultra-private state.
archived
private *restore
archive pending
submit
publishedpublish
archive
reject
retract
publish
archive
retract
reject
How could you solve this?
• Add Delete objects to the permissions managed by the workflow (under the workflow“Permissions” tab)
• Add the new archived state
– Take away all roles for Add portal content, Modify portal content
– Give only Manager role the ability to View
• Add archive transition
– Guard permission = Delete objects (the people who could delete the object can alsoarchive it)
– Transitions to archived state
– Don’t forget to set formatted name and URL!
• Add restore transition
– Guard role = Manager
– Transitions to private state
– Don’t forget to set formatted name and URL!
• Enable archive transition from all states
18.10. Exercise Answers 99
Plone Bootcamp, Best Practices for Plone Development
• Enable restore transition from archived state
5. Extend the above exercise so that owners can archive things, but no one but managers can actuallydelete things.
• For all states, take Delete objects away from all roles except Manager (and uncheckacquire!)
• Change the guard for archive transition to role = Owner
• Now, you could make a collection that found all archived things that were modified >1 weekago, and a manager could review them and delete them quickly with the hidden folder_contentstab
100 Chapter 18. Workflow
CHAPTER
NINETEEN
GENERIC SETUP
19.1 Generic Setup
19.1.1 Generic Setup
• Used by Plone and products to manage setup
Generic Setup is the tool Plone uses to read configuration off of disk and to apply it to an existing site. It isused by Plone itself to create a new Plone site, and by add-on products to make configuration changes to asite upon installation.
• portal_setup tool in ZMI
19.1.2 Taking a Snapshot
• Takes a moment to run
– Some browsers: never returns
* Just check if it’s there
• Can rename under contents tab
• Can compare to other snapshots
19.1.3 Exporting Steps
• Export tab
– Choose steps to export
* All is similar to snapshot, but stored on disk
* Some is useful if can’t export all or snapshot
Annoyingly, a buggy add-on product may keep you from being able to make a snapshot of yoursite, or from being able to export all steps. As such, someone finds/fixes that bug, you can exportall the steps that aren’t related to the problem (you may have to experiment to find what theyare)
101
Plone Bootcamp, Best Practices for Plone Development
– Returns XML config in zip file
Technically, it’s not a true *.zip file but a “gzipped tarball” (*.tar.gz). Most unzippingprograms, like Window’s WinZip will be able to read it.
19.1.4 Importing GS File
• Can re-import GS XML files
– Applies configuration in these files to site
– Make a *.tar.gz file
* Like Export produces
* With XML files you’ve edited
As you get more advanced, you can also build a product that includes these XML files so that, whenyour product is installed, this configuration happens.
19.1.5 GS and Content
• structure contains some of site content
– But not all! – don’t rely on it
* You can delete structure from snapshots
– GSXML provides a much richer XML export/import for content
19.1.6 Using with Products
• Create policy
– Convention: default in folder profiles
– Register with ZCML
• Code-generators (ArchGenXML and some paster recipes) do for you
19.1.7 Sample Policy
profiles/default/
properties.xmlworkflows.xmlworkflows/
foo_workflow.xml
102 Chapter 19. Generic Setup
Plone Bootcamp, Best Practices for Plone Development
19.1.8 GS and ZCML
<configurexmlns="http://namespaces.zope.org/zope"xmlns:genericsetup=
"http://namespaces.zope.org/genericsetup">
<genericsetup:registerProfilename="default"title="My Cool New Product"description="About my product..."provides="Products.GenericSetup.interfaces.EXTENSION"/>
</configure>
• Typically, that snippet is in profiles.zcml
– Included by main configure.zcml with:
<include file="profiles.zcml" />
• At this point, you have a working profile
– Install your product using Add-on products to test
19.1. Generic Setup 103
Plone Bootcamp, Best Practices for Plone Development
104 Chapter 19. Generic Setup
CHAPTER
TWENTY
SKINNING PLONE
20.1 Overview
20.1.1 So, You Want To ...?
• Change Plone’s footer
• Modify the template used by News Items
• Understand Plone’s two skinning systems
20.1.2 Overview
• Concepts of skinning process
• Zope3-style skins
• CMF-style skins
• Recommendations on where to start
20.2 Skin Tool
20.2.1 Skinning Example
<p tal:content= "context/Title"> [Title] </p>
Page Template
p = context.\ getPrice()return p/12
PythonScript
HTML
i {color: blue; }b {color: red; }
CSSHTML
TitleDescripBodyImage
Content
Skinning Theming
105
Plone Bootcamp, Best Practices for Plone Development
20.2.2 Skinning
• All content objects are smart Python objects
– Know how to display themselves by default
– Can change the skin via URL
/ folder / content / skin
– content is called context
– Default skin name often doesn’t appear
20.2.3 Skin Objects
• Page Template: HTML, XML
Templated HTML to handle presentation.
• Script (Python): Scripts
Python scripts to handle logic.
• Image: Web images (PNG, GIF, JPG)
• File: Flash, CSS
Files that require no special parsing, such as pure (non-templated HTML). Flash .swf files are acommon choice for this.
• DTML Method: other templated stuff (email, etc.)
DTML is a simpler, somewhat-deprecated templating system. It is used now for non-HTML andnon-XML templating: CSS, email, and things like that.
20.2.4 Skin Object Location
• Skin objects can go anywhere in ZODB
– Can go at root of site, but this is messy
– Better: last place in lookup: skinning machinery
* portal_skins
* portal_view_customizations
That is, a skin page like an HTML page can be used in a particular place in the URL–such ashttp://plone/my_folder/my_resume/my_html, which is calling my_html “placefully” on my_resume
It’s useful to put skin objects elsewhere in the ZODB if you want to override behavior. For example, tohave one “feedback_form” for most of the site, and different one in the Account department’s folder, youcan place a different feedback_form in that folder. Anywhere in /Accounting (including descendent folders),you will have access to the accounting feedback_form.
106 Chapter 20. Skinning Plone
Plone Bootcamp, Best Practices for Plone Development
20.3 Two Skinning Systems
20.3.1 Two Skinning Systems
• We want to see this HTML as URL “/hello”
<p>Hello, World!</p>
• Zope 3 is “wired” with on-disk config file:
<browser:pagefor="*"name="hello"template="hello.pt"/>
• Zope 2 “matches by name”:
portal_skins/your_skin_folder/
hello.pt
20.4 Zope-3 Style Skins
20.4.1 “Zope 3” Templates
• Normally stored on disk in a product:
Products.myproduct/browser/
configure.zcmltemplate1.pttemplate2.pt
– Can be customized through-the-web
20.4.2 Customerize
• portal_view_customizations
– Lists all templated-based Zope3 views
Does not list ones that requires class, as these must be customized on disk.
– Can examine to find where they’re stored
* Useful for on-disk developers
20.3. Two Skinning Systems 107
Plone Bootcamp, Best Practices for Plone Development
– Can be very slow to load on Windows
* Open once and keep open as a tab
20.5 CMF-Style Skins
20.5.1 Skin Folders
• Traditional skins in portal_skins
• Provide organization of skins
– Plone’s skins are divided by purpose
– Add-on products create own folders
• Skins can appear in more than one skin folder
• Skin path is order of folders to use
– custom folder is most-preferred normally
20.5.2 Customizing Skins
• Filesystem Directory Views
– Skin folders stored on disk
In Plone 2.1 and earlier, the FSDVs had lock icons. In Plone 2.5, the lock icons have (unfortu-nately) gone away, and you can’t distinguish a FSDV from a normal folder except by clickingon it and seeing what type it is.
• custom is not an FSDV; it’s stored in ZODB
– Items in it can be edited
• Customization copies item from a FSDV to a ZODB-stored folder
– ZODB-stored folders normally would be higher up the skinpath
To follow the examples, customize the logo.jpg from plone_images. This will copy it to custom. Now,replace this logo image with a new image. Since the custom folder is higher in the skinpath, this will replacethe logo for browsers.
Note that this can’t be “customized” twice–since it already exists in the custom folder, it can’t be copied asecond time there. Instead, it should be edited in the custom folder.
20.5.3 Finding in ZMI
• Find tab search objects in database
– Only looks where you use it and deeper
108 Chapter 20. Skinning Plone
Plone Bootcamp, Best Practices for Plone Development
– If you search in portal_skins, shows “most preferred” with @PYGZred[*] star
• Not same as Plone’s “Search”
– That searches content across site
20.6 CMF or Zope 3
20.6.1 Which Are Zope3 Templates
• Portlets
• Viewlets
– Page components
* Search box, logo, footer, etc.
• Most “new” templates
20.6.2 Which are CMF Templates
• Content views
• Classic products
20.6.3 Zope 3 vs CMF: Zope 3
• Can have attached Python class for logic
– a “view class”
• Can by very flexibly wired by type
– Only show up for books, etc
20.6.4 Zope 3 vs CMF: CMF
• Can be created TTW
– Or on disk
• No wiring needed, found by name
• Can be placeful in ZODB
20.6. CMF or Zope 3 109
Plone Bootcamp, Best Practices for Plone Development
20.6.5 No Need to Worry!
• Actual template language is the same
– Can move from one type to the other
Assuming you don’t rely on view classes or aren’t the template for a viewlet, portlet, etc., all of whichmust be Zope3-style.
• Can dump from ZODB to disk at any point
• Start off with CMF
– Can create through web
– Don’t have to learn wiring initially
Note: Advanced Difference
The only difference is that CMF templates have magic access to a function called test, whereas z3templates do not (for dumb reasons having to do with developer snobbery).
You can convert an expression of the format:
python:test(testvar, t-thing, f-thing)
to:
python: testvar and t-thing or f-thing
This has a subtle potential bug, though, should t-thing itself have a False value. A longer, but rigor-ously correct option is:
python: (testvar and [t-thing] or [f-thing])[0]
For an explanation of this, see the Python Cookbook on the lack of “ternary operator” in Python(although Python 2.5 does introduce a ternary operator, this version of Python cannot yet be used withZope/Plone).
20.7 Exercises
20.7.1 Exercises
1. Customize the newsitem_view skins from plone_content. Add a line below the close of the <h1>tag with “FOR IMMEDIATE RELEASE”. Check that your customized version is used instead of thestandard version.
2. Modify the footer by adding a line of text.
3. What are some different ways you can quickly remove a CMF skin customization, like a new logo, orthe colored-background?
110 Chapter 20. Skinning Plone
Plone Bootcamp, Best Practices for Plone Development
20.8 Exercise Answers
1. Customize the newsitem_view skins from plone_content. Add a line below the close of the <h1>tag with “FOR IMMEDIATE RELEASE”. Check that your customized version is used instead of thestandard version.
• Go to plone_content and find newsitem_view
• Customize it, and add line below </h1>
2. Modify the footer by adding a line of text.
• Find footer in portal_view_customizations
• Customize it
• Add a line of text
3. What are some different ways you can quickly remove a CMF skin customization, like a new logo, orthe colored-background?
• delete it from the custom folder
• rename it to something else
• remove custom from the skinpath
• copy and paste original code to custom
• don’t forget undo!
20.8. Exercise Answers 111
Plone Bootcamp, Best Practices for Plone Development
112 Chapter 20. Skinning Plone
CHAPTER
TWENTYONE
BASIC PAGE TEMPLATES
21.1 Introduction
21.1.1 So You Want To ...?
• Change appearance for your content well
• Create custom forms or reports
21.1.2 Overview
• Understanding the syntax
• Replacing content
• Skinning content types
21.1.3 Goals
<h1>[Real Title]</h1><p>By [fname] [lname]</p>
<!-- only if they told us! --><h2>Your Hobbies</h2><ul> <!-- loop once per hobby -->
<li> <a href="[/hobby1]">[Hobby #1]</a> </li><li> <a href="[/hobby1]">[Hobby #1]</a> </li>
</ul>
21.1.4 The Parts
• TAL: “Template Attribute Language”
– Templating XML/HTML using attributes
• TALES: “TAL Expression Syntax”
113
Plone Bootcamp, Best Practices for Plone Development
– Expressing values to use
• METAL: “Macro Expansion for TAL”
– Nesting templates inside each other
21.2 TAL
21.2.1 TAL Syntax
• All TAL occurs in HTML attributes with tal: namespace
<b tal:example="...">
• Passes through untouched by editors
– You can edit templates in Dreamweaver!
• tal:example name is case-insensitive
– Though the value of that attribute may be case-sensitive.
21.2.2 tal-content
• Assuming name is a variable set to “Alice”
• tal:content replaces content of element with expression:
<b class="big" tal:content="name">Gone</b>
returns:
<b class="big">Alice</b>
21.2.3 tal-replace
• Assuming name is a variable set to “Alice”
• tal:replace replaces entire element with expression:
<b tal:replace="name">Gone</b>
returns:
Alice
114 Chapter 21. Basic Page Templates
Plone Bootcamp, Best Practices for Plone Development
21.2.4 Replaced Content
<b tal:content="name">Gone</b>
• “Gone” never appears
– We could leave out
• These produce same results:
<b tal:content="name"></b>
<b tal:content="name" />
The first is legal, but in a WYSIWYG editor, it’s hard to tell that there’s a bold tag at all.
The second is legal XHTML, although unusual for most web editors.
21.2.5 Replace Content Practice
• Good practice:
<b tal:content="name">[User’s name]</b>
I usually put a brief description of what will appear instead of nothing at all. To help template design-ers understand that this is just a placeholder value, I put square brackets around it.
21.2.6 The Span Tag
• What’s wrong with this?
<i tal:replace="name">[User’s name]</i>
• Confuses designers who expect italics!
• span is useful
– The “unbolded bold”
<span tal:replace="name">[Users’ name]</span>
21.2.7 The Div Tag
• Like span but for blocks of text
– The “unparagraph paragraph”
21.2. TAL 115
Plone Bootcamp, Best Practices for Plone Development
21.3 TALES
21.3.1 TALES
• Expression syntaxes
– Paths
– Strings with variable replacement
– Python
21.3.2 Path Syntax
• Path syntax is simplest and default:
– some_variable
– context/Description
– context/my-folder/Description
– context/my-folder/class-starts/Description
21.3.3 Path Syntax
• Need to have first object in our namespace
– set previously as a variable in this ZPT
– a built-in object (such as context)
• Can use spaces and punctuation
– context/logo.jpg/width is legal
21.3.4 Built-in Objects
• context (also called here)
“here” is the older name. Good practice is to move to “context”, as this is both slightly more obvious,and also the same term used for this concept in PythonScripts.
– Current object skin is being called on
• user
– Object of logged-in user (user/getUserName)
• request
116 Chapter 21. Basic Page Templates
Plone Bootcamp, Best Practices for Plone Development
– Request object
This is described comprehensively later. The request object contains everything normally in CGIscript environments, plus form values, cookies, session data, etc.
21.4 Creating ZPTs
21.4.1 Creating a PageTemplate
• Added my_info:
<html><body>
<h1 tal:content="context/Title">[Title]</h1><p>At <span tal:replace="context/absolute_url">[URL]</span></p>
</body></html>
21.4.2 How to Test
• Browse HTML Source
– Shows “unrendered”, as would appear in editor
• Test tab
– Tests in skins folder (easy but weird place)
• Go to piece of content and add to URL
– Tests in particular place
21.4.3 Syntax Errors
• Edit my_info
<html><body>
<h1 tal:content="context/Title"> [Title] </h2><p>At <span tal:replace="context/absolute_url">[URL]</span></p>
</body></html>
• Syntax error: where does h1 end?
21.4. Creating ZPTs 117
Plone Bootcamp, Best Practices for Plone Development
21.4.4 Attribute Error
• Edit my_info
<html><body>
<h1 tal:content="context/Title">[Title]</h1><p>At <span tal:replace="context/absolute_url">[URL]</span></p>
<p>Doesn’t exist: <span tal:replace="context/isbn"></span></p></body></html>
• Raises AttributeError on isbn
• Unless we call it on a book with that field
It’s an attribute error because Python is trying something like context.isbn and failing.
21.5 TALES II
21.5.1 Callables
• In Python, objects have
– attributes (things they know)
– methods (things they do):
class Trainer:name = "" # An attributedef dance(self): # A method
return "Whee!"
21.5.2 Callables II
>>> joel = Trainer()
>>> joel.name = "Joel Burton"
>>> joel.name # attribute"Joel Burton"
>>> joel.dance # method<bound method Trainer.dance of <__main__.Trainer...>>
>>> joel.dance() # calling method"Wheee"
118 Chapter 21. Basic Page Templates
Plone Bootcamp, Best Practices for Plone Development
21.5.3 Path Expressions II
• Final element is called, if callable
– context/dance
* No operation like context/dance()
This auto-calling isn’t always the behavior desired; the nocall operator is explained later.
* Tries both attribute and dictionary lookup:
object.attribute
object[’dictkey’]
21.5.4 Providing Alternatives
• Bar (|) provides alternatives for errors:
context/isbn | context/issueNum
• Error results in next alternative being chosen
– “If you can’t do this, here’s something else to try...”
21.5.5 Safe Fallback
• nothing is similar to “” or None:
context/isbn | context/issueNum | nothing
21.6 PT and Archetypes
21.6.1 Skinning an Archetype
• Can often say context/fieldname:
<p>ISBN:<i tal:content="context/isbn">[isbn#]</i>
</p>
21.6. PT and Archetypes 119
Plone Bootcamp, Best Practices for Plone Development
21.6.2 Free Accessor
• Use “accessor” (“getter”) instead of direct attribute
– myField gets getMyField for free
– Useful abstraction
* In case storage changes
* If you need to change behavior of field
21.6.3 Free Mutators
• To set fields, use “mutator” (“setter”)
– myField gets setMyField for free
• Very bad practice to use attributes directly
– Skips validation
– Skips storage
21.6.4 Clouseau
• Through-the-web debugging and introspection
• Shows schema of content
21.6.5 Play With Your Object!
• Your fields: getField
• Standard metadata:
– Title, Description
– Creators, Contributors
– Subject (keywords/categories)
• All use setField
21.6.6 Clouseau Example
>>> context<ATDocument at /Plone2/front-page>
>>> context.Title()’Welcome to Plone’
120 Chapter 21. Basic Page Templates
Plone Bootcamp, Best Practices for Plone Development
>>> context.Description()’Congratulations! You have successfully installed Plone.’
>>> context.Subject()()
>>> context.setTitle(’Hello’)
21.7 Wrappers
21.7.1 Content Well
• To put into content well:
<html metal:use-macro="context/main_template/macros/master"><div metal:fill-slot="main">
<p>Hello</p>
</div></html>
The metal:use-macro line means “make this page just like the main template”.
The metal:fill-slot line means “fill the slot called main [the main content well] with this informa-tion.”
21.7.2 Best Practice
• There are lots of “other things” that should appear for most content
– Byline
– Comments
– Related content
– CSS styling
• Therefore, you can include code to push out these “viewlets”
– Above and below title
– Above and below content body
– Related items
• Complete example of main well:
21.7. Wrappers 121
Plone Bootcamp, Best Practices for Plone Development
<div tal:replace="structure provider:plone.abovecontenttitle" /><h1 class="documentFirstHeading">Title</h1><div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="documentDescription">Description</p>
<div tal:replace="structure provider:plone.abovecontentbody" />
Content Body
<div metal:use-macro="context/document_relateditems/macros/relatedItems" />
<div tal:replace="structure provider:plone.belowcontentbody" />
21.8 Exercises
21.8.1 Exercises
1. Create a template for showing books. It should show the title and description for the book it’s calledon (the context). The API for getting the title is Title; for the description, it’s Description.
<h1>[Content Title]</h1><p>Description: [This is the description]</p>
What’s a good name for this template?
2. Update the template above so that it also shows the ISBN number, like so:
<p>ISBN: <i>[12345]</i></p>
What’s the right API for getting ISBN?
3. Update the template above so that it is “wrapped” in the normal site template.
21.8.2 Advanced Exercises
4. Update the template so that it includes the “complete” (best practice) set of spots where viewlets couldappear:
21.9 Exercise Answers
1. Create a template for showing books. It should show the title and description for the book it’s calledon (the context). The API for getting the title is Title; for the description, it’s Description.
<h1>[Content Title]</h1><p>Description: [This is the description]</p>
122 Chapter 21. Basic Page Templates
Plone Bootcamp, Best Practices for Plone Development
What’s a good name for this template?
• book_view:
<h1 tal:content="context/Title">[title]</h1><p>Description:
<span tal:replace="context/Description">[descrip]</span></p>
2. Update the template above so that it also shows the ISBN number, like so:
<p>ISBN: <i>[12345]</i></p>
What’s the right API for getting ISBN?
• book_view updated:
<h1 tal:content="context/Title">[title]</h1><p>Description:
<span tal:replace="context/Description">[descrip]</span></p>
<p>ISBN: <i tal:content="context/getIsbn">[isbn]</i></p>
3. Update the template above so that it is “wrapped” in the normal site template.
• book_view updated:
<html metal:use-macro="context/main_template/macros/master">
<div metal:fill-slot="main"><h1 tal:content="context/Title">[title]</h1><p>Description:
<span tal:replace="context/Description">[descrip]</span></p>
<p>ISBN:<i tal:content="context/getIsbn">[isbn]</i></p>
</div></html>
4. Update the template so that it includes the “complete” (best practice) set of spots where viewlets couldappear:
• book_view updated:
<html metal:use-macro="context/main_template/macros/master"><div metal:fill-slot="main">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 class="documentFirstHeading" tal:content="context/Title">Title
</h1>
21.9. Exercise Answers 123
Plone Bootcamp, Best Practices for Plone Development
<div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="documentDescription"tal:content="context/Description">
Description</p>
<p>ISBN:<i tal:content="context/getIsbn">[isbn]</i>
</p>
<div tal:replace="structure provider:plone.abovecontentbody" />
<div metal:use-macro="context/document_relateditems/macros/relatedItems">
show related items if they exist</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</div></html>
124 Chapter 21. Basic Page Templates
CHAPTER
TWENTYTWO
THEMING OVERVIEW
22.1 Introduction
22.1.1 So You Want To ... ?
• Quickly design a lightly-themed site
• Start a more complex theme
22.1.2 Overview
• Moving/hiding “viewlets”
• Editing/hiding “actions”
• Skin folders
• Base Properties
22.1.3 Our Client
• Have given us mockup of page:
http://localhost:8085/samplecorp
• What do you notice about it?
– What’s similar to Plone Default?
– More important, what’s different?
22.1.4 Differences
• Page: white page on background
• Top: new logo, no “accessibility” link, search box moved up
• Overall: different colors, portlet appearance
125
Plone Bootcamp, Best Practices for Plone Development
• Navigation: shows top-level navbox; “home” link, no global tabs
• Other: no colophon, breadcrumbs
22.2 Themes
22.2.1 Themes
• Easy options for site appearance
• Place to change “theme” being used
22.2.2 Paster
$ paster create -t plone3_theme
Enter project name: myorg.themeEnter namespace_package [’plonetheme’]: myorgEnter package [’example’]: themeEnter skinname [’’]: MyThemeEnter skinbase [’Plone Default’]: (Return to accept default)Enter empty_styles [True]: False
• Install new product in fresh Plone site
22.3 Viewlets
22.3.1 Viewlets
• Small, self-contained visual item
– A “snippet of HTML”
– Search box
– Logo
• Portlets are a special kind of viewlet
22.3.2 Re-Arranging Viewlets
• /manage-viewlets
– Re-arrange within manager
– Hide
• Changes persist in ZMI
126 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
– Can be captured by GS snapshot
• Can also use GloWorm
22.3.3 Moving Viewlets for SampleCorp
• Hide global tabs
• Move personal bar to top of portal.top
• Move searchbox above site actions
• Hide colophon
• Hide pathbar (breadcrumbs)
22.4 Actions
22.4.1 Actions
• Links that can appear in a place, such as
– document actions (green tabs): view, edit
– global actions (top tabs): home, news, events
– site actions (top right): contact us, sitemap
22.4.2 Finding an Action
• Look in portal_actions
• Look in the content type actions
• In 2.5: look under “Action Providers” tab of portal_actions
22.4.3 Action Categories
document_actions print this page, email this page
site_actions contact-us, sitemap
object view, edit, properties
portal_tabs home, news, events
user login, logout
There are other categories, such as folder_buttons for buttons appearing in folder_contents, such as Cut,Copy, Paste, etc. These are fairly specialized.
22.4. Actions 127
Plone Bootcamp, Best Practices for Plone Development
You can add your own action categories, and use scripts to show new categories of actions in the appropriateplace.
The API call for this is:
listFilteredActionsFor(object)
Parameter object – Object to check for actions on
Return type List of actions
22.4.4 Editing an Action
• Name: Text as it appear in interface
• Id: Id for referring to action
This should be kept stable and not changed.
• Action: TALES expression for URL
TALES expressions are explained later. The simplest kind of TALES expression would just be some-thing like string:hello, meaning it resolves to the simple string “hello”.
So, for example, to have an action that produces a link to the home page of Yahoo!, usestring:http://www.yahoo.com.
• Condition: TALES expression required
These are covered later, but an example might be to check and see if the content has a certain condition.For example, for Event items with organizer names, there might be an action to look up that personin a phone book. Since that action should only appear for content with names, this could be guardedwith an action like context/person_name.
• Permission: permission required
What permission is needed to see this action?
Permissions are covered completely later.
• Visible: shown or hidden
Rather than deleting actions, it’s much better to hide them by unchecking this.
22.4.5 Actions Changes for SampleCorp
• Hide accessibility
• Move login from user to site actions
128 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
22.5 Navigation Portlet
22.5.1 Navigation Portlet
• Centralized settings in Site Setup Navigation
– Types to search, etc
• Per-portlet settings
– Where to start
– How deep to go
22.5.2 Portlet Changes for SampleCorp
• Show top (“Home”)
• Set start level to 0
– Since we’ve hidden global tabs
22.6 Base Properties
22.6.1 CSS Manager
• Sheet of common properties in CSS
– Make simple changes in Plone’s appearance
• Highly recommend for everyone!
22.6.2 CSS Development Mode
• CSS is normally cached and merged
– Faster for deployment
– Confusing when developing
• Turn on “Debug/Development mode” in ZMI/portal_css or CSSManager
– Turn back off before deployment
22.6.3 Base Properties for SampleCorp
22.5. Navigation Portlet 129
Plone Bootcamp, Best Practices for Plone Development
Site Logo (logo) = newlogo.jpg
Default text color (fontColor) = #333 [dark grey]
Unvisited link color (linkColor) = #7b955a[dark green]
Default border color (globalBorderColor) = #99b182[medium green]
Secondary background color (globalBackgroundColor) = #cde2a7[light green]
Even row background color (evenRowBackgroundColor) = transparent
22.6.4 Base Properties
• Location of properties:
/portal_skins/plone_style/base_properties
– Documented in ploneCustom.css
22.6.5 Useful Properties
• logoName: ID for sitewide logo
• fontFamily: font used for normal text
• fontColor: color used for normal text
• headingFontFamily: font for headings
• textTransform: lowercases buttons/tab
– none disables
22.6.6 Theme Properties
• backgroundColor: page background color
• globalBorderColor: “blue tabs” color
• globalBackgroundColor: selected tab/headers
• globalFontColor: normal text
• evenRowBackgroundColor: even rows/cells
130 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
22.7 Exercises
22.7.1 Exercise
1. The client wants to change the link labeled “Log out” to “Sign out”. Make this change.
2. Currently, the navigation shows content of all types. How could you change it to just showing Foldersand Large Folders (so that it became a folderish navigation tool, showing nested folders, but nevershowing the actual news items/pages/images/etc)?
22.7.2 At-Home Exercises
3. Take time to play with GloWorm and CSSManager. Get a sense of what things you can change withGloWorm. See what kind of theming changes are possible with CSSManager, and what things requiremore in-depth changes.
22.8 CSS
22.8.1 Turning Off CSS
• Decide which pieces are unlike Plone
– And turn them off in portal_css
22.8.2 Plone CSS
• “Branding”: Styles you disable/really change:
base.css basic elements of page
public.css general “Plone branding”; public look
portlets.css portlet appearance
navtree.css navigation portlet
• “Feeling”: You might disable, but won’t change:
generated.css icons for portal types
member.css styles for logged-in only (workflow colors)
• Might tweak/override parts for your theme:
columns.css CSS for column arrangement
presentation.css full-screen presentation mode
print.css printable page
mobile.css cell phone pages
22.7. Exercises 131
Plone Bootcamp, Best Practices for Plone Development
• “Content management”: probably leave alone:
authoring.css content management
kupu.css Required for kupu product
• Technical CSS:
deprecated.css outdated CSS from 2.0-2.5
RTL.css right-to-left language support
textSmall.css, textLarge.css dynamic font sizing
IEFixes, NS4 fixes for IE and Netscape 4
• Original empty, you’ll fill:
ploneCustom.css your customizations
22.8.3 Turning Off for SampleCorp
• Turn off:
– portlets.css
• We might have considered navtree.css
22.8.4 Learning CSS
• Head First HTML and CSS
– Excellent book for learning & for experts!
– You’ll finally understand float and position: relative
22.8.5 Web Developer Extensions
• Firefox Web Developer Extensions
– Amazing tool for web designers
132 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
– Dozens of time-saving features
* We’ll look at just a few
• Similar tools for IE, but not as nifty
22.8.6 Measure
• WebDeveloper Info→ View Element Info
• On breadcrumb bar:
div #portal-breadcrumbs What you are on,element & IDs/classes
Attributes ...Position ...Other ...
Ancestors What you are in, from tophtmlbody .section-front-pagediv #visual-portal-wrapperdiv #portal-top
Children What is in youspan #breadcrumbs-you-are-herea
22.8.7 Try It Out
• Do this work in a new window (not tab)
• WebDeveloper CSS→ Edit CSS
– Play on ploneCustom.css tab
* That’s where you’ll really put change
– Don’t click links – you can lose changes!
22.8.8 Sample CSS
• Fix body color:
body {background-color: #cde2a7;
}
• Create white page on background:
22.8. CSS 133
Plone Bootcamp, Best Practices for Plone Development
#visual-portal-wrapper {width: 940px;margin: 30px auto 10px auto;background-color: white;
}
22.8.9 Sample CSS: Top I
• Fix top height and add border below:
#portal-top {border-bottom: solid 5px #99b182;height: 110px;
}
• Put personal tools on top, at right, only as wide as it needs to be:
#portal-personaltools {border: none;float: right;display: inline;
}
#portal-siteactions {clear: both;
}
22.9 Customizing CSS
22.9.1 Saving CSS Changes
• Customize ploneCustom.css
– Simplest and best for most people
– Can store in custom folder or in on-disk skin folder
22.9.2 Common CSS Tricks
• Sections have class on body tags:
body.section-chemistrybody.section-biology
– Comes from short name of top-level folder
• Different look for homepage:
134 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
body.section-front-page
• Change appearance of some tabs/fields:
#portaltab-news#archetypes-fieldname-description
• Different look for logged-in
– See member.css in portal_css
22.10 Adding to Our Product
22.10.1 Profile
• Use portal_setup→ Export
– Replace our profiles/default/viewlets.xml with dumped
– Trim down actions.xml and add to profile
22.10.2 Portlets
• Trim portlets.xml to our “assignments” :
<?xml version="1.0"?><portlets><assignment name="navigation" category="context" key="/"
manager="plone.leftcolumn" type="portlets.Navigation"><property name="topLevel">0</property><property name="currentFolderOnly">False</property><property name="name"/><property name="includeTop">True</property><property name="bottomLevel">0</property><property name="root"/>
</assignment></portlets>
22.10.3 Skins
• Copy custom folder from export to skins/ folders
• For some: to our Archetypes’ skins/ folders
22.10. Adding to Our Product 135
Plone Bootcamp, Best Practices for Plone Development
22.11 Content and Kupu
22.11.1 Kupu Style Menus
• Helps content editor re-use CSS classes
– Drop-down choice for block menus
* Format is title|tag|className
* Tag will often be p or div
We could add, for instance, Quiet|p|discreet for a paragraph tag to enclose the text with thediscreet CSS class on it. This is a CSS class used by Plone for the small, quiet, gray text used inbylines, etc.
You can add a tagged value to a richtext field on an Archetype so that new items are added to the kupustyle menu for that field.
The tagged value is widget:parastyles, and it should contain:
python:[(’tag|class’, ’Name’), (’tag|class’, ’Name’)...]
This will generate a field like this:
TextField(’fieldName’,widget=RichWidget( parastyles=[(’tag|class’,’Name’),
(’tag|class’,’Name’)] ),),
– Similar choice for table styles
22.12 Exercises
22.12.1 Exercises
4. The built-in Plone content types all show the metadata description field on the view skins. Find theCSS selector that would allow you to change the appearance of this. Make these descriptions be inred.
22.12.2 Advanced Exercises
5. Add a new CSS class for “background material” in content. This could be a paragraph, and should bedisplayed in dark grey text, with a border around it. Add this class to the classes that kupu will allowusers to select from.
6. The “review” portlet uses alternate color striping. Change this so that the even stripes use a differentbackground color–just the even stripes, and just for this portlet.
136 Chapter 22. Theming Overview
Plone Bootcamp, Best Practices for Plone Development
22.13 Exercise Answers
1. The client wants to change the link labeled “Log out” to “Sign out”. Make this change.
• In the ZMI, go to portal_actions
• In the “user” actions, find “logout”
• Change the title to “Sign out”
2. Currently, the navigation shows content of all types. How could you change it to just showing Foldersand Large Folders (so that it became a folderish navigation tool, showing nested folders, but nevershowing the actual news items/pages/images/etc)?
• Go to Navigation
• Uncheck all content types except “Folder” and “Large Folder”
4. The built-in Plone content types all show the metadata description field on the view skins. Find theCSS selector that would allow you to change the appearance of this. Make these descriptions be inred.
• Add CSS:
.documentDescription { background-color: red; }
5. Add a new CSS class for “background material” in content. This could be a paragraph, and should bedisplayed in dark grey text, with a border around it. Add this class to the classes that kupu will allowusers to select from.
• Add to ploneCustom.css:
.bkgndMaterial { color: #555;border: solid 1px #555; }
• Add to Kupu control panel:
Background Material | p | bkgndMaterial
6. The “review” portlet uses alternate color striping. Change this so that the even stripes use a differentbackground color–just the even stripes, and just for this portlet.
• Find the right class:
.portletWorkflowReview .even { background-color: blue; }
22.13. Exercise Answers 137
Plone Bootcamp, Best Practices for Plone Development
138 Chapter 22. Theming Overview
CHAPTER
TWENTYTHREE
DEPLOYMENT CONSIDERATIONS
23.1 Introduction
23.1.1 So, You Want To ... ?
• Set up Plone server in a best-practice way
• Understand the critical role of proxy servers
• Make Plone go faster
• Back up your database
23.1.2 Overview
• Installation of Zope/Plone
• Proxy servers
• Performance and Caches
• ZEO setup
23.2 Zope Installation
23.2.1 General Installation
• Works great on Linux, Windows, OSX
– Linux is most popular, though
– No real differences inside of Zope
139
Plone Bootcamp, Best Practices for Plone Development
23.2.2 Linux Setup
• RPMs and Debian PKGs not recommended
– Great quality!
* But not widely used by experts
• Source install (“Universal Installer”)
– Easy and most common
23.2.3 Zope Startup
• Linux and OSX: bin/instance fg
– “Foreground”: useful for development, testing
– Debug mode (slightly slower; output to console)
• Linux and OSX: bin/instance start
– “Background”: writes to event log in log
• Linux and OSX: bin/instance debug
– Debugging shell, similar to Clouseau
23.3 Simple Setup
23.3.1 Simple Setup
Internet Zope
• Suitable for development or very small sites
• Susceptible to the “grandmother problem”
23.3.2 Grandmother Problem
• A server can only stream as fast as receiver can accept
– So grandmom can tie up Zope for 5 mins downloading a movie
140 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
– 4 grandmothers can tie up your server entirely
• Solutions:
– More Zopes
– Proxy something in front of Zope
23.4 HTTP Proxy
23.4.1 Proxy Setup
Internet Proxy Zope
• Proxy requests to Zope
– Possibly: cache HTTP
– Possibly: round-robin among Zope servers
– Possibly: log requests
– Possibly: serve non-Zope content
23.4.2 Proxy Servers
• Apache: Easy, popular (proxy + decent caching)
• Squid: Most powerful for caching
• Varnish: New, simpler than Squid
• Pound: Simple proxy/load balancer (no cache)
• Enfold Proxy: Proxy for Windows IIS
23.4.3 Apache Buildout
• Can install Apache yourself
• Or buildout can do for you:
23.4. HTTP Proxy 141
Plone Bootcamp, Best Practices for Plone Development
[apachebuild]recipe = plone.recipe.apache:buildurl = http://apache.multidist.com/httpd/httpd-2.2.11.tar.gz
This installs a clean, separate Apache instance into your buildout directory–perfect for deployments.
For information, see plone.recipe.apache:build.
• Buildout can config your Apache:
[apacheconfig]recipe = plone.recipe.apache:configbind = 8000backends =
127.0.0.1:8085zope2_vhm_map =
foo.org:/Plone
• Apache is proxying at http://foo.org:8000
• Startup with bin/apachectl fg
To test this, you’ll need to replace “foo.org” with the name of your website.
For information, see plone.recipe.apache:config.
23.4.4 Varnish Buildout
• Can install Varnish yourself
• Or buildout can do for you:
[varnishbuild]recipe = zc.recipe.cmmiurl = http://downloads.sf.net/varnish/varnish-2.0.4.tar.gz
This installs a clean, separate Varnish instance into your buildout directory–perfect for deployments.
For information, see zc.recipe.cmmi.
• Buildout can config your Varnish:
[varnish]recipe = plone.recipe.varnish:instancedaemon = ${buildout:directory}/parts/varnishbuild/sbin/varnishdbind = 127.0.0.1:8000backends =
foo.org:127.0.0.1:8085cache-size = 1Gzope2_vhm_map =
foo.org:/Plone
• Varnish is proxying at http://foo.org:8000
142 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
• Startup with bin/varnish -F to run in foreground
To test this, you’ll need to replace “foo.org” with the name of your website.
For information, see plone.recipe.varnish:instance.
23.4.5 Squid Buildout
• Can install Squid yourself
• Or buildout can do for you:
[squidbuild]recipe = plone.recipe.squid:buildurl = http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE21.tar.gz
This installs a clean, separate Squid instance into your buildout directory–perfect for deployments.
For information, see plone.recipe.squid:build.
• Buildout can config your Squid:
[squid]daemon = ${buildout:directory}/parts/squidbuild/install/sbin/squidrecipe = plone.recipe.squid:instancebind = 127.0.0.1:8000backends =
foo.org:127.0.0.1:8085cache-size = 1000zope2_vhm_map =
foo.org:/Plone
• Squid is proxying at http://foo.org:8000
• Startup with bin/squid
To test this, you’ll need to replace “foo.org” with the name of your website.
For information, see plone.recipe.squid:instance.
23.5 Caching
23.5.1 CacheFu
• Add-on product (included in 2.5; separate in 3.x)
– Add Products.CacheSetup to your buildout.cfg
• Provides conservative caching out-of-box
– Can be 5-25x faster without staleness
23.5. Caching 143
Plone Bootcamp, Best Practices for Plone Development
23.5.2 Minimal CacheFu Setup
Cache Configuration Tool
•Enable CacheFu
•Set Proxy Cache Purge Configuration
•Set site domains
–http://foo.org:80 for our examples
23.5.3 CacheFu Concepts
• Configuration
– Basic information
• Headers
– Low level machinery
• Rules
– Which header is used when
23.5.4 CacheFu Rule Choices
• Cache in Zope memory
– Fast, but still pesters Zope
• Cache in proxy server
– Much faster
– Can only invalidate under Squid
• Cache in browser
– Fastest
– Can’t invalidate
144 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
23.6 Multiple Servers
23.6.1 ZEO: “Zope Enterprise Objects”
ZEO
Zope
Zope
• Splits database (ZEO) and app server (Zope)
– Multiple ZEO clients per server
– Failover
– Performance
– Debugging
23.6.2 Getting ZEO
• Universal installer can give you on setup:
$ ./install.sh zeo
• Or you can convert a standalone setup to ZEO
23.6.3 Converting to ZEO
• Add new section to your buildout:
[zeoserver]recipe = plone.recipe.zope2zeoserverzope2-location = ${zope2:location}zeo-address = 8079
– Don’t forget to add this section to parts =
• Update instance section:
23.6. Multiple Servers 145
Plone Bootcamp, Best Practices for Plone Development
[instance]zeo-client=truezeo-address=${zeoserver:zeo-address}# Keep rest of section
• Add additional instances, as desired:
[instance2]recipe = collective.recipe.zope2clusterinstance-clone = instancehttp-address = 8081
[instance3]recipe = collective.recipe.zope2clusterinstance-clone = instancehttp-address = 8082
– Don’t forget to add each section to parts =
• That’s it!
– Buildout will move instance Data.fs→ ZEO
– Buildout will create a startup script for zeoserver and each instance
See Also:
For more information
• Adding Sections
• Using ${variables}
• Deployment vs Development in Buildout
23.6.4 ZEO with Single Instance
Internet Proxy Zope ZEO
• Ready for additional Zope
– But not faster/better yet
– This is a great initial deployment setup
* Since you can add more Zopes easily at any time
146 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
23.6.5 Multiple Zopes
• Run at least 1 Zope/CPU
– Will need lots of memory for multi-core boxes
23.6.6 Load Balancing
• Handled by software
– Fine choice for most setups
• Dedicated hardware
– Same IP goes to different boxes
23.6.7 Software Load Balancing
• Pound: Simple, excellent separate product
• Apache: Special directives to perform
• Squid: Special directives to perform
Varnish (as of this writing) cannot do load balancing in a sane way.
If you want to use Apache or Squid for load balancing, you’ll have to set it up by hand.
Pound is generally the recommended way to go here.
23.6.8 Pound Buildout
• Can install Pound yourself
• Or buildout can do for you:
[poundbuild]recipe = plone.recipe.pound:buildurl = http://www.apsis.ch/pound/Pound-2.4.4.tgz
This installs a clean, separate Pound instance into your buildout directory–perfect for deployments.
For information, see plone.recipe.pound:build.
• Buildout can config your Pound:
[pound]recipe = plone.recipe.pound:configdaemon = 0log_facility = -balancers =
foo-org 127.0.0.1:8001 127.0.0.1:8080 127.0.0.1:8081
23.6. Multiple Servers 147
Plone Bootcamp, Best Practices for Plone Development
• Startup with bin/poundctl start to run in foreground
• Pound is load balancing 8001→ { 8080, 8081 }
To test this, you’ll need to replace “foo.org” with the name of your website. You’ll also change your proxyto point to Pound, not directly to Zope.
For information, see plone.recipe.pound:config.
23.7 Serious Deployments
23.7.1 Multiple Servers
Server #1
Server #2
Internet Proxy Zope
Zope
Zope
Zope
ZEO
• Can run Zopes on separate physical servers
– Make sure network to ZEO is fast & secure
• Products that store files on disk require shared disk access
– eg Reflecto
– NFS, Samba, or other solutions fine
148 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
23.7.2 Varnish + Pound + ZEO
InternetVarnishProxyCache
PoundLoad balance
Zope1
Zope2
ZEO
• Straightforward and high-performing
– Suitable for medium sites
– Can add additional Zope instances for more capacity
23.7.3 Apache + Varnish + Pound + ZEO
InternetApacheProxyAuth
PHP
VarnishCache
PoundLoad balance
Zope1
Zope2
ZEO
• Complex but flexible
– Great caching with Varnish (could be Squid, too)
– Can authenticate or serve non-Zope content via Apache
23.8 Speed Comparisons
23.8.1 Speed Comparisons
• Anonymous, no cache:
Requests per second: 6.17 [#/sec] (mean)
• Anonymous, with CacheFu:
23.8. Speed Comparisons 149
Plone Bootcamp, Best Practices for Plone Development
Requests per second: 37.17 [#/sec] (mean)
• Anonymous, with CacheFu + Varnish:
Requests per second: 506.33 [#/sec] (mean)
23.9 Maintenance
23.9.1 Backup
• Entire ZODB is in Data.fs
– repozo script at bin/
* Full or incremental backup
* Restore
• Also backup buildout.cfg and src/ directory
• Backups are platform neutral
23.9.2 Repozo Cheatsheet
repozo.py
-B backup
-R restore
-r path to backup directory (create first)
-f path to Data.fs
-F make full backup (default: incremental)
-z compress backups (default: no)
-v verbose mode (default: no)
23.9.3 Backup Recipe
• Can add recipe to buildout:
[buildout]sections =
...backup
150 Chapter 23. Deployment Considerations
Plone Bootcamp, Best Practices for Plone Development
[backup]recipe = collective.recipe.backup
• Gives you simple “backup” command with suitable choices
• For information, see collective.recipe.backup.
23.9. Maintenance 151
Plone Bootcamp, Best Practices for Plone Development
152 Chapter 23. Deployment Considerations
CHAPTER
TWENTYFOUR
THE ROAD AHEAD
24.1 Process
24.1.1 Process
• The way I build sites:
• What content do you need? Build types
• Business process? Workflow & security
• Application needs? Add-ons & scripting
• Does it Work? Make Selenium Tests
• Theme? Build CSS
• How fast vs. fresh? Add caching rules
• Deploy ... & profit!
24.2 Getting Help
24.2.1 Oh Noes! A Problem!
• Reduce the problem space
• Google for the obvious terms
• Use our online support channel & mailing lists
And, of course, if you’re a Python programmer, feel free to look at the source, too.
24.2.2 Reduce the Problem Space
• Does a fresh Plone site in same Zope do this?
– Most critical question to answer
153
Plone Bootcamp, Best Practices for Plone Development
– Go to root of Zope, make a new Plone site, any try
* Has same problem: On disk software
* Doesn’t: Related to your config or content
• Does “clean” Plone do this?
– A fresh buildout with no products except that one
You can always duplicate your buildout folder, remove the add-on products (eggs =, zcml =, and[productdistros]) to get a fresh, no-products Plone in under 3 minutes–with no software todownload or setup!
• This is usually the first thing we’ll ask you
• Go around your proxy server/cache
– Connect directly to Zope
• Try as the admin user
24.2.3 Internet Relay Chat (IRC)
• Not just for coders!
• We hang out in #plone
– Or #zope, but #plone more active
• 100+ developers available for help
– 24 hours a day
– Every day of the year
24.2.4 Getting on IRC
• Can do it right in browser:
– http://plone.org/support/chat/
• Pidgin is a good IRC client
“Gaim” was renamed Pidgin in mid-2007; you should be able to find it by searching under eithername.
– Others are very popular
– Come into #plone
24.2.5 IRC Basic Rules
• Don’t ask-to-ask
– We know why you’re here :)
154 Chapter 24. The Road Ahead
Plone Bootcamp, Best Practices for Plone Development
• You don’t have to stay and chat with us
– But you’re welcome to!
– You might learn useful things
24.2.6 Demonstrate Effort
• Demonstrate that you’ve tried:
I want to hide fields on my archetype edit formdepending on a particular condition. I know about"read_permission", but my condition isn’t apermission. What can I do?
24.2.7 Sample IRC
PloneUser123 connectedPloneUser123: Hi, all. How can I change the footer at
the bottom of the page? I looked for it in portal_skins, butit doesn’t seem to be there.
helpfulgeek: PloneUser123, it’s been moved. Go toportal_view_customizations--and just search that page for "footer"
PloneUser123: Can I customize it there, helpfulgeek?helpfulgeek: YesPloneUser123: Great, thanksPloneUser123 disconnected.
24.2.8 IRC Dont’s
• Don’t latch on to the first person
– Others often assume you’re being helped
• Don’t whine or tell us things suck
– We remember when you do that
24.2.9 Paste Site for Code
• Put full error reports and tracebacks
– http://paste.plone.org
PloneUser123 connectedPloneUser123: What could be causing this problem?
http://paste.plone.org/12345
24.2. Getting Help 155
Plone Bootcamp, Best Practices for Plone Development
24.2.10 Mailing Lists
• Plone-users
– General questions, how-do-I-do
• Plone-devels
– Discussion on developing Plone
– Only send advanced questions here, once they’ve gone to Plone-users
24.2.11 Consultants
• Hundreds of available companies and people
– From 1 person to 50 person shops
• People specialize in different areas and sizes
• RFPs to the plone-users mailing list can be smart
– Or better, ask around at user groups/online about who’s good
24.2.12 Plone Documentation
• In Plone Documentation Center
• Excellent coverage of HOWTOs, tips, etc.
– Organization is getting better – can you help?
• Check products for docs/ directory
24.2.13 Plone Books
• A User’s Guide to Plone at http://plonebook.info
– Excellent coverage of content-manager material
156 Chapter 24. The Road Ahead
Plone Bootcamp, Best Practices for Plone Development
– Organized, clear
– Free or can license for distribution
• Definitive Guide to Plone
– Introduction and early intermediate
– Somewhat out-of-date
It’s not so much that this book is no longer accurate, but, rather, that new things have been inventedthat aren’t in this book.
– Online in free version
You can find the free version linked from plone.org.
• Plone Live
– Introductory and intermediate
– Reasonably up-to-date (ca late 2005)
– Good coverage of testing, etc.
24.2. Getting Help 157
Plone Bootcamp, Best Practices for Plone Development
• Web Component Development With Zope 3
– Philipp von Weitershausen
• Excellent, clear book on Zope 3 technologies
– Plone and Five minimally discussed
– Best place to learn component architecture
• Professional Plone Development
– Martin Aspelli (optilude in #plone)
• Developer-focused book on Plone 3 techniques
– Dense and information-filled
– Philipp’s may be better place to start
158 Chapter 24. The Road Ahead
Plone Bootcamp, Best Practices for Plone Development
• Practical Plone 3
– Group authored work
• Similar in scope to this class
– Up-to-date
– I’d start with Definitive Guide to Plone
24.2.14 User Groups
• “Zope/Python User Groups”
– Washington DC, North Carolina, Boston, Fredericksburg, and other
• “Plone Lounge”
– San Francisco
• “PIGgies”
– Many places; generally Python experts
• Start your own!
24.3 Your Road
24.3.1 Customizing On Disk
• Can ship product w/customizations, sample content, etc.
• Building theme products with paster
• Creating “profiles” from your GenericSetup XML
24.3.2 Zope3 “Views”
• Page templates with associated Python code
24.3. Your Road 159
Plone Bootcamp, Best Practices for Plone Development
– For scripting
24.3.3 Caching
• “Functional” caches:
– RAMCache
– memoize
• CacheFu
• All covered well in “High Performance Plone” talk
24.3.4 KSS
• KSS
– for building interactive pages without JavaScript
• Covered well in “KSS Techniques” talk
24.3.5 Testing
• Writing on-disk tests that can be run from command-line
– unit tests
– functional tests
24.4 Thanks
24.4.1 Finding Me Online
• IRC: joelburton in #plone
• AIM: wjoelburton
• MSN: [email protected]
• Yahoo: wjoelburton
• Google: [email protected]
Please understand that I’m just not able to provide free support to my students–but I’m always happy topoint you toward a book mailing list, or other resource.
160 Chapter 24. The Road Ahead
Plone Bootcamp, Best Practices for Plone Development
24.4.2 Thanks
• One thing I should add
• One thing I should keep
• One thing I should cut/reduce
• Optionally, a public quote
24.4. Thanks 161
Plone Bootcamp, Best Practices for Plone Development
162 Chapter 24. The Road Ahead
CHAPTER
TWENTYFIVE
FUNCTIONAL TESTING
25.1 Overview
25.1.1 So, You Want To ...?
• Prove your site works
– And keeps working
– And not get fired
25.2 Selenium
25.2.1 Selenium Overview
• In-browser, functional testing
• Tests are straightforward to write
– Developers or clients can write them
• Running tests is easy and graphical
– Clients can run them in browser
– Or, from command line/test runner/cron
25.2.2 Selenium Tests
• Just like a bored intern!
– Runs in a real browser
– Tests real things
• Uses JavaScript
– Can run in any browser that can
163
Plone Bootcamp, Best Practices for Plone Development
25.2.3 Writing a Test
• Use the Selenium IDE for Firefox
– Records everything you do
– Test can be run in any browser
25.2.4 Sample Selenium Test
• Tests are just normal HTML tables:
Sample Testopen http://site/clickAndWait link=Log intype __ac_name testusertype __ac_password testpassclickAndWait //input[@value=’Log in’]assertTextPresent You are now logged in
25.2.5 Selenium Concepts
• Actions
– “Do what?”
• Element Locators
– “Where?”
• Checks
– “Did it Work?”
25.2.6 Selenium Actions
• open
• click
• type
• select
• And more
– Including “...AndWait” versions
For most of the actions, there is a second version that waits until a new page has been loaded; this isuseful for things like clicking a link, so that the next step in the test doesn’t try to run before the pageload has completed.
164 Chapter 25. Functional Testing
Plone Bootcamp, Best Practices for Plone Development
25.2.7 Selenium Locators
• Identifier: title
– Looks first for matching id, then name
• Link Text: link=Click Here
• DOM: document.forms[’myForm’].fname
• XPath: //input[@value=’Log in’]
25.2.8 Selenium Checks
• verifyLocation
– Are we at the right URL
• verifyTitle
• verifyElementPresent
25.2.9 Selenium Form Checks
• verifyValue
– Checks value of INPUT
• verifySelected
– Checks value of SELECT
25.2.10 Selenium Text Checks
• verifyText
– For a particular node, exact match
• verifyTextPresent
– Anywhere on page
• verifyTextNotPresent
25.3 Running Tests
25.3.1 Running From Browser
• Lightweight but manual
– Can save tests as HTML tables locally
25.3. Running Tests 165
Plone Bootcamp, Best Practices for Plone Development
– And open them from Selenium IDE
– And re-run
25.3.2 Selenium Remote Console
• Selenium Remote Console
– Runs a real browser
– Communicate with it via command-line
– So you can run scripts from command-line
25.3.3 Installing SeleniumRC
• Can download and install from Selenium HQ
• Easier: let buildout do it! :
[seleniumrc]recipe=collective.recipe.seleniumrc
– Windows: bin\seleniumrc
– Linux: bin/seleniumrc
– OSX: bin/seleniumrc
25.3.4 Saving Tests as Python
• To run tests as scripts, must save as script!
– “Export Test Case As ... Python”
– Save it somewhere you can find it
– Windows: python\python testName.py
– Linux: ../Python-2.4/bin/python testName.py
– OSX: ../Python-2.4/bin/python testName.py
You may need to install selenium with easy_install selenium.
25.4 Road Ahead
25.4.1 Road Ahead
• Learn about Zope’s testrunner framework
166 Chapter 25. Functional Testing
Plone Bootcamp, Best Practices for Plone Development
– You can run all your Selenium tests (and others) at once
• Learn about other kinds of functional testing
• Learn about unit testing (for serious devs only)
• Learn about collective.recipe.roadrunner
25.5 Exercises
25.5.1 Exercises
1. Using the SeleniumIDE, record a test for your site:
• Go to the home page
• Create a folder, enter a title and save the folder
• Ensure that you get back the view of the folder
2. The above test is fine for proving that you can create a folder, but it’s not very repeatable–you’ll keepadding multiple copies of the same folder. Add a step to the end of your test that deletes the folder atthe end, and checks to make sure deletion works.
25.6 Advanced Exercises
25.6.1 Advanced Exercises
3. Install SeleniumRC (easiest to do using buildout).
Convert the tests from the exercises above into Python, and save them.
Practice running them using the remote control.
25.7 Exercise Answers
1. Using the SeleniumIDE, record a test for your site:
• Go to the home page
• Create a folder, enter a title and save the folder
• Ensure that you get back the view of the folder
• Easiest to write this in the IDE; you should get something like:
25.5. Exercises 167
Plone Bootcamp, Best Practices for Plone Development
open http://localhost:8085/Ploneclick link=Add to folderclickAndWait link=Foldertype title Test FolderclickAndWait form_submitverifyTextPresent Changes saved.
2. The above test is fine for proving that you can create a folder, but it’s not very repeatable–you’ll keepadding multiple copies of the same folder. Add a step to the end of your test that deletes the folder atthe end, and checks to make sure deletion works.
• Added to end of last test:
click link=ActionsclickAndWait link=DeleteassertConfirmation Do you really want to delete this folder and all its contents?verifyTextPresent Test Folder has been deleted.
168 Chapter 25. Functional Testing
CHAPTER
TWENTYSIX
ADD-ON PRODUCTS
26.1 Overview
26.1.1 So, You Want To ...?
• Use add-on products
– Without getting bitten!
26.1.2 Overview
• Choosing an add-on product
• Top products
• Excellent products by area
26.1.3 About Add-Ons
• Almost all products are on plone.org
– Over 700!
– Some excellent, some dead-ends
• Most migration problems come from 3rd party products
26.1.4 How to Choose
• Generally, ignore product name
– Anything can be called “PloneThisOrThat”
• Generally, ignore version numbers
– Since they’re inconsistent
• Generally, ignore “developer buzz”
169
Plone Bootcamp, Best Practices for Plone Development
– Since their agendas/skills are different
• Look at the author
– Some have a reputation for excellence/support
• Ask around
– On IRC or at user group
And consider the skill level of the person making the recommendation. A recommendation froman advanced developer may not be as useful as one from an experienced integrator.
• See if they support old/new versions
– A product that doesn’t reach backwards may not reach forwards
26.2 The Short List
26.2.1 Best & Built-In
• CacheFu
Included in some versions of Plone; in other versions, you can add it easily via buildout (add theCacheSetup product).
• CMFEditions
• Iterate
26.2.2 Top Add-Ons
• PloneFormGen
• LinguaPlone
• TAL Portlet
• EnfoldDesktop
• GloWorm
• Clouseau
26.3 Membership
26.3.1 Users / Authentication
PloneLDAP
170 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
•Get users/password/metadata/groups from LDAP
WebServerAuth
•Delegate auth to proxy server (like Apache)
SQLPASPlugin
•Get users/password/metadata/groups from SQL DB
NoDuplicateLogin
•Prevent multiple logins
AutoRole
•Give roles automatically for in-network users
–Inside firewall?
–After 5pm?
–Has a certain cookie set?
26.3.2 Membership
Membrane
•Members can act like content
–New fields
–Membership can be workflowed
Remember
•Membrane setup that includes standard Plone member data
26.4 Content Types
26.4.1 Discussion Boards
Ploneboard
26.4. Content Types 171
Plone Bootcamp, Best Practices for Plone Development
•Standard, reasonably-well-featured discussion board
Plone Comments
•Drop-in replacement for Plone’s standard commenting; includes workflowable comments,anonymous comments, and more
AnonymousCommenting
•Allow easy commenting by anonymous users
26.4.2 Press Centers
PressRoom
•Simple, well-maintained press release product
26.4.3 Mailing Lists
Listen
•Mailing lists in your Plone site
26.4.4 Form Generation
PloneFormGen
•Top-10 product!
•Content managers can create forms
–Email results
–Or add to database
ReCaptcha
•Simple add-on to provide captcha authentication on your forms
172 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
26.4.5 Blogs
Scrawl
•Nice, simple blogging product
•Very compatible and safe
QuillsEnabled
•The “sane” parts of Quills, allowing you to use any content type for a blog entry, while providinglistings, comments, trackbacks, etc.
Quills
•More featureful and complex; tread carefully
26.4.6 Documentation
PloneHelpCenter
•Store FAQs, HOWTOs, etc
•Used to power Plone’s “Documentation Center”
26.4.7 Project Management
Poi
•Bug-tracking software
•Also useful for light project management
PloneSoftwareCenter
•Track software releases and projects
26.4.8 Biography/Staff
FacultyStaffDirectory
•Faculty/staff listings
26.4. Content Types 173
Plone Bootcamp, Best Practices for Plone Development
•Excellent example of a well-supported, well-build product
26.4.9 GeoSpatial
Maps
•Integration with Google Maps
26.4.10 Images
ImageEditor
•Provides image editor for in-Plone images
•Useful for cleaning up images
Slideshow Folder
•Turns normal folder of images into a nice slideshow
PloneTrueGallery
•Higher-end, nicely featured gallery
26.4.11 Flash
ATFlashMovie
•Store and display Flash .swp files
FlowPlayer
Player for MP3 and flash movies
26.4.12 General Content Types
RichDocument
•“Article”-type of content
174 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
•Stores images and files inside
I often use for magazine articles.
26.4.13 Rich Editors
FCKEditor.Plone
•Use FCKEditor instead of Kupu
Products.TinyMCE
•Use TinyMCE instead of Kupu; particularly nice
26.5 Archetypes Support
26.5.1 Helpers
ArchGenXML
•Converter for UML→ Archetypes product
26.5.2 Fields and Widgets
ArchAddOn
•Learn to make new fields & widgets
A nice learning product.
ATExtensions
•Useful fields for table-fields and more
DateBox
•Smarter, better date widget
ScriptableFields
•Body fields can contain TAL/TALES
26.5. Archetypes Support 175
Plone Bootcamp, Best Practices for Plone Development
•Fields that are Python scripts
Breaks some of the content/skin/script separation.
26.5.3 Date/Time
CalendarX
•“Microsoft Outlook” style views of calendar
–Monthly, daily, etc.
26.6 Internationalization
26.6.1 Internationalization
LinguaPlone
•Maintain your content in different languages
•Excellent!
i18ndude
•Many utilities for creating/maintaining i18n templates
26.7 Portlets
26.7.1 Portlets
plone.portlet.tal
•Build simple scripted portlets using PageTemplate TAL
collective.portlet.contribute
•Portlet that encourages users to upload certain types of content in the right places
FeedMixer
176 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
•Replacement for Plone’s built-in RSS portlet, providing more compatibility, multiple feeds, andserver-side caching
26.8 Services
26.8.1 Content Rule Helpers
collective.contentrules.template
•Allows you to add content to a newly created folder (“every time a Press Center is added, addthis template Welcome... page”)
collective.contentrules.parentchild
•Adds content rule condition for presence of children in workflow state (“there must be twopublished images to publish the gallery”, etc)
collective.contentrules.webservices
•Provides actions to twitter, send to eventful, and sent to upcoming.org
collective.contentrules.mail
•Much more featureful mail sending
26.8.2 Reporting
LinkChecker
•Reports on broken outbound links
RedirectionTool
•Allow moving of content without breaking links
plone.contentratings
•Rate content
26.8. Services 177
Plone Bootcamp, Best Practices for Plone Development
26.8.3 Version Control
CMFEditions
•View old versions of content
–Can diff to current version
–Can rollback to old version
•Built-in to Plone 3
Iterate
•Simple staging system for Plone
•Built-in to Plone 3
26.8.4 External Editor
ExternalEditor (Linux/Windows)
•External Editor client for Linux and Windows
•There’s also a Mac OSX editor
26.8.5 Search
PloneSEO
•Control search engine settings for content
26.8.6 Newsletters
Singing & Dancing
•Newsletter product
–Subscribe to newsletters
–aggregate Plone content into newsletters
178 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
26.8.7 Management
EnfoldServer
•Supported commercial version of Plone server
EnfoldDesktop
•Manage Plone content via Windows desktop
•Commercial product but free
26.8.8 Commerce
GetPaid
•New framework for ecommerce
•Still alpha, but interesting
•Complex and underdocumented
26.8.9 Workflow
DCWorkflowGraph
•Always up-to-date graphs of your workflows
•Useful for sanity-checking during design process
collective.portlet.workflowsteps
•Portlet showing details of workflow for current object
collective.wfcomment
•Pops up and asks user to comment when transitioning workflow
26.8.10 Mail
mailtoplone
26.8. Services 179
Plone Bootcamp, Best Practices for Plone Development
•Creates Plone content from email
PrintingMailHost
•Sends email to console window rather than actually sending
•Great for development/testing
26.8.11 Import/Export
GSXML
•XML-based import/export for content
26.8.12 Filesystem Integration
Reflecto
•Show server directories directly in Plone server
26.9 Presentation
26.9.1 Page Composition
Collage
•Build pages out of re-usable page components
•Visual editor for building composite pages
•Interesting but complex
26.9.2 Navigation
Webcouturier DropDownMenu
•Drop down menu for global tabs
180 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
26.9.3 Theming
CSSManager
•Easy way to begin theming your site
•Make CSS changes quickly and centrally
26.10 Catalog
26.10.1 New Catalog Indexes
TextIndexNG
•Very full-featured full-text search
FieldedTextIndex
•Search across indexes & weight indexes
ManageableIndex
•Advanced searching capabilities
26.11 Development Tools
26.11.1 Relational Databases
Alchemist
•Use SQLAlchemy with Plone
•Still rather beta
z3c.alchemy
•Lower level SQLAlchemy/Zope integration
•Somewhat advanced
26.10. Catalog 181
Plone Bootcamp, Best Practices for Plone Development
26.11.2 Development
GloWorm
•Fantastic introspection tool for viewlets and page templates
CallProfiler
•What scripts/templates are taking so long?
PageTemplateProfiler
•Detailed info about ZPT performance
FSDump
•Dump ZODB skin objects to disk
collective.cheatsheets
•Handy cheatsheets for Plone development; very useful
plone.reload
•Reload changed product code without restarting
26.11.3 Debugging
DocFinderTab
•Ask any object how to work with it
•Install whenever you use Clouseau to get help within Clouseau
Clouseau
•Python prompt for Plone
•An excellent product
WingIDE
182 Chapter 26. Add-On Products
Plone Bootcamp, Best Practices for Plone Development
•Commercial debugger/editor
•Best debugger for Zope/Plone
ZPT Debugger
•Lists all expressions evaluated in a Page Template
26.12 Deployment
26.12.1 Caching
CacheFu
•Centralized caching system for Plone
26.12.2 Deployment
Entransit
•Use Plone to manage content, other systems to deploy
Useful if you want to deploy with PHP, Java, etc.
Have to rebuild some dynamic features in the deployment language.
26.12. Deployment 183
Plone Bootcamp, Best Practices for Plone Development
184 Chapter 26. Add-On Products
CHAPTER
TWENTYSEVEN
INTRO TO BUILDOUT
27.1 Overview
27.1.1 So, You Want To ...?
• Install software from different repositories
• Upgrade your version of Plone
• Learn deployment buildout tricks
• Install proxy servers or cache software easily
• Create a custom development environment, quickly
27.1.2 Overview
• What is buildout?
• What’s in it?
• Tips and tricks for using
• Useful recipes
27.2 Buildout
27.2.1 Buildout
• System for installing and configuring Plone
– And add-on products
– And, possibly, Zope and libraries
– In a scripted, reproducible way
185
Plone Bootcamp, Best Practices for Plone Development
Technically, buildout have nothing directly to do with Plone–it was written for Zope–the Plone communityhas simply made useful recipes using buildout for building Plone sites.
It is now used by many Python projects.
27.2.2 Idea
• A single config file, buildout.cfg
– This downloads/generates/configs all components
– You don’t/can’t touch most things below it
• Very reproducible–just copy buildout.cfg to other box
27.3 Buildout File
27.3.1 Buildout Syntax
# Comments start with hash mark ("number sign")[section]key1 = value1key2 =
value2value3
• [section] divides file into sections by name
• Can put value on same line as key if there is only 1
– Or keep in aligned indented list for more than 1
27.3.2 Buildout Parts
• Identified at top of file
• Common ones
[buildout]parts =
zope2productdistrosinstance
Only sections listed in the buildout parts are “run”; even if they are present in the buildout file.
186 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
27.3.3 [buildout] find-links
find-links =http://dist.plone.orghttp://download.zope.org/ppix/http://download.zope.org/distribution/http://effbot.org/downloads
• Where we look for eggs to install
– If you find a useful repository, you can add it!
27.3.4 [buildout] eggs
eggs =Plonewebcouturier.dropdownmenu
• Eggs to download and use with this site
• Add new eggs, one per line
– Must be found in the “find-links” pages
– Eggs you install via python setup.py or copying: don’t list here
That is, anything you install by hand, not using buildout, won’t be listed here.
27.3.5 [buildout] zcml
zcml =collective.plone.gsxml
• List zcml “slugs” for eggs that require it (most do)
– Should say so in egg README
* But may not
– Products that have “Products” name, like “Products.foo”, don’t need this
In Plone 3.2, the Windows buildout.cfg does not have a zcml = declaration in the [buildout] section;instead, it’s in the [instance] or [client] section. It works the same.
27.3.6 Versions
• You can specify a version # or requirement for eggs
– If not specified, buildout uses most recent release
– If specified, buildout will meet requirement
27.3. Buildout File 187
Plone Bootcamp, Best Practices for Plone Development
• In Plone 3.2+, we package version dependencies in separate file
– Windows: Read across network
– Linux and OSX: versions.cfg
• Can upgrade to newer version of Plone by changing URL
For example, on Linux and OSX, you could upgrade by finding the lines reading:
# extends = http://dist.plone.org/release/3.2.1/versions.cfgextends = versions.cfg
and changing them to:
extends = http://dist.plone.org/release/3.3.0/versions.cfg# extends = versions.cfg
This switches to getting the dependencies from the network, and using the dependencies for Plone 3.3.0.
27.3.7 [productdistros]
[productdistros]recipe = plone.recipe.distrosurls =
http://foo.com/products/blog-1.0.ziphttp://bar.com/stuff/nifty-2.0.zip
nested-packages =version-suffix-packages =
• Will download and install blog and nifty non-egg products
Some classic products are zipped up in unusual ways, where there are multiple products in one zipfile, or where the zip file folder contains the version number of the product (“JoelsBlog-0.8”, wherethe actual product name should be “JoelsBlog”).
These problems are what nested-packages and version-suffix-packages can fix.
27.3.8 [zope2]
[zope2]recipe = plone.recipe.zope2installurl = http://www.zope.org/Products/Zope/2.10.7/Zope-2.10.7-final.tgz
• Download Zope and install it
– Possible to have buildout that uses pre-installed Zope
188 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
27.3.9 [instance]
• Is your $INSTANCE_HOME
• Top section provides critical stuff:
[instance]recipe = plone.recipe.zope2instancezope2-location = ${zope2:location}user = admin:adminhttp-address = 8080debug-mode = onverbose-security = on
• Stuff that would be in zope.conf goes here
27.3.10 [zeoserver]
• For ZEO setups:
[zeoserver]recipe = plone.recipe.zope2zeoserverzope2-location = ${zope2:location}zeo-address = ${buildout:zeo-address}
• In ZEO setups, will have one [instance] section for each client
– Often called [client1], [client2], etc.
– Often, many parts just refer to [client1]:
[client2]recipe = collective.recipe.zope2clusterinstance-clone = client1http-address = 8081
27.4 Using Buildout
27.4.1 Running Buildout
• Always shutdown Zope before running buildout
• Re-run buildout to pull down anything new
– Add new eggs, products
– Change instance settings
• Common Buildout options:
-v Run in “verbose” mode
27.4. Using Buildout 189
Plone Bootcamp, Best Practices for Plone Development
-c file Use config file (default: buildout.cfg)
-o Offline mode (do not use Internet)
-n Newest mode
27.4.2 Running Buildout in “New” Mode
• Re-run buildout to pull down and update
– Also updates existing things, as allowed
– Windows: bin\buildout -n
– Linux: bin/buildout -n
– OSX: bin/buildout -n
• Without this, buildout doesn’t check for newer versions
27.5 Buildout Techniques
27.5.1 Section Names
• [Section Names] are not magical or fixed
– It’s the recipe that makes it work:
[instance]recipe = plone.recipe.zope2instance
– So you can add new sections/rename sections
Remember: just because you add a new section doesn’t mean it will be used; you have to add itto parts to run it.
27.5.2 Buildout Templating
• Buildout can refer to itself:
http-address = ${buildout:http-address}
– Look in [buildout] for http-address key
• Can set values once and re-use in different sections
– That’s why buildout has “human config” at top
190 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
27.6 Buildout Tricks
27.6.1 Managing Deployment
• You can have more than one buildout file, and have them read each other
– common setup
– deployment: includes caching, etc.
– development: includes debugging, etc.
27.6.2 common.cfg
• Includes things common to both deployment + development:
[buildout]parts =
zope2instance
# Use these in both dev + deploymenteggs =
Products.PloneFormGen
[instance]recipe = plone.recipe.zope2instancezope2-location = ${zope2:location}
27.6.3 deploy.cfg
• Extends common.cfg with deployment-specific setup:
[buildout]extends = common.cfg
eggs +=Products.CacheSetup
[instance]http-address = 8099debug-mode = offverbose-security = off
– Note +=: current choices, plus ...
– There’s also a -= for current choices, minus
27.6. Buildout Tricks 191
Plone Bootcamp, Best Practices for Plone Development
27.6.4 devel.cfg
• Extends common.cfg with development-specific setup:
[buildout]extends = common.cfg
eggs +=Products.Clouseau
[instance]http-address = 8080debug-mode = off
27.6.5 Choosing Config
• Can keep files named devel.cfg and deploy.cfg
– And run buildout with -c filename.cfg to pick
• Can softlink file to buildout.cfg
Linux and OSX: ln -s config.cfg buildout.cfg
– Then can run buildout without -c option
• Can make a simple buildout.cfg that extends:
[buildout]extends = devel.cfg
27.6.6 Extending From Web
• Can also keep entire buildout on web
• No dependencies on box at all
• buildout.cfg:
[buildout]extends = http://project/devel.cfg
27.7 Migrating Buildout
27.7.1 Migrating Buildout
• To move a buildout to a new server, copy:
– buildout.cfg, your config
192 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
– src/, your home-build products
– var/filestorage/Data.fs, your database
– bootstrap.py, the bootstrapping script
• On a different server, copy these into a clean directory
– Run bootstrap.py
If you’ve stored classic products directly in a products/ folder (rather than using[productdistros] to download and manage for you), you should copy these, too.
Consider if any of your buildout file has assumptions about other software on the system–the standardPlone installer doesn’t, but some recipes may assume you have things like Apache or Varnish installedat particular places (happily, there are recipes that will make fresh installations of this, solving theseproblems).
The new server will need the correct version of Python and will need to have setuptools (the eggsoftware) installed.
If you don’t know how to do this, a decent way to get a clean buildout environment is to use theUniversal Installer (which will give you the right Python, plus setuptools, plus bootstrap.py .Then, just go into your installer-created buildout folder, remove the buildout.cfg from there andremove the parts/ directory, and copy your stuff into it. Then, you can run your buildout.
27.8 Useful Recipes
27.8.1 Generic Maker
zc.recipe.cmmi
Download, configure, make, and make install a software product. Expects a Unix-like set of compil-ers.
[varnishbuild]recipe = zc.recipe.cmmiurl = http://downloads.sf.net/varnish/varnish-2.0.4.tar.gz
27.8.2 Apache
plone.recipe.apache:build
Download and install private instance of the Apache web server.
[apachebuild]recipe = plone.recipe.apache:buildurl = http://apache.multidist.com/httpd/httpd-2.2.11.tar.gz
27.8. Useful Recipes 193
Plone Bootcamp, Best Practices for Plone Development
plone.recipe.apache:config
Configure Apache (your system Apache, or a private Apache installed with :build recipe) to proxy forPlone.
[apacheconfig]recipe = plone.recipe.apache:configbind = 8000backends =
127.0.0.1:8085zope2_vhm_map =
foo.org:/Plone
27.8.3 Varnish
plone.recipe.varnish:instance
Configure Varnish (your system Varnish or a private build) to proxy and cache for Plone.
[varnish]recipe = plone.recipe.varnish:instancedaemon = ${buildout:directory}/parts/varnishbuild/sbin/varnishdbind = 127.0.0.1:8000backends = 127.0.0.1:8085cache-size = 1Gzope2_vhm_map = foo.org:/Plone
27.8.4 Squid
plone.recipe.squid:build
Download and install a private instance of Squid.
[squidbuild]recipe = plone.recipe.squid:buildurl = http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE21.tar.gz
plone.recipe.squid:instance
Configure Squid (either system Squid or a private instance) to proxy and cache for Plone.
[squid]daemon = ${buildout:directory}/parts/squidbuild/install/sbin/squidrecipe = plone.recipe.squid:instancebind = 127.0.0.1:8000
194 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
backends = foo.org:127.0.0.1:8085cache-size = 1000zope2_vhm_map = foo.org:/Plone
27.8.5 Pound
plone.recipe.pound:build
Download and install a private copy of Pound, the load balancer.
[poundbuild]recipe = plone.recipe.pound:buildurl = http://www.apsis.ch/pound/Pound-2.4.4.tgz
plone.recipe.pound:config
Configure Pound (either system Pound or a private instance from :build recipe) to load balance forPlone.
[pound]recipe = plone.recipe.pound:configbalancers =
foo-org 127.0.0.1:8001 127.0.0.1:8080 127.0.0.1:8081
27.8.6 ArgoUML
plonebootcamps.recipe.argouml
Downloads ArgoUML and configures to use Plone’s profile.
[argouml]recipe=plonebootcamps.recipe.argouml
27.8.7 ArchGenXML
zc.recipe.egg:scripts
Downloads an egg and installs scripts from it.
Example usage (to setup ArchGenXML):
27.8. Useful Recipes 195
Plone Bootcamp, Best Practices for Plone Development
[archgenxml]recipe=zc.recipe.egg:scriptseggs=archgenxmlscripts=archgenxmlextra-paths = ${instance:zope2-location}/lib/python
27.8.8 Omelette
collective.recipe.omelette
Creates an easily-explored directory structure for your downloaded eggs. Much more convenient thandigging into buildout-cache/.
[omelette]recipe=collective.recipe.omeletteeggs = ${instance:eggs}products = ${instance:products}packages = ${instance:zope2-location}/lib/python ./
27.8.9 Backup
collective.recipe.backup
Sets up a simple script, bin/backup, that calls repozo with good default options.
[backup]recipe=collective.recipe.backup
In Linux, link bin/backup into your /etc/cron.daily for daily backups.
27.8.10 IPZope
zc.recipe.egg
Use IPython, the brilliant Python shell, for debug prompt.
[ipzope]# Download http://tinyurl.com/ipy-zope in $HOME/.ipythonrecipe = zc.recipe.eggeggs =
ipython${instance:eggs}
initialization =import sys, osenviron = os.environ
196 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
environ["SOFTWARE_HOME"] = "${instance:zope2-location}/lib/python"environ["INSTANCE_HOME"] = "${instance:location}"sys.argv[1:1] = "-p zope".split()
extra-paths = ${instance:zope2-location}/lib/pythonscripts = ipython=ipzope
Then, you can run this with bin/ipzope.
27.8.11 Subversion
infrae.subversion
Downloads products from subversion repository (useful when using products that are not yet released,or when you want to use a in-development version).
[development-products]recipe = infrae.subversionurls =
https://svn.plone.org/svn/.../trunk FolderName
• Good docs for this at Installing from svn with buildout.
27.8.12 Roadrunner
roadrunner:plone
Configures roadrunner, a much-faster testrunner, for Plone. Very useful for running unit tests over andover without restarting Zope each time.
[roadrunner]recipe = roadrunner:plonezope2-instance = instancepackages-under-test =
index:: supervisor,supervisorctl,supervisord
27.8.13 Supervisor
This is for Linux and OSX only. It will not run on Windows. collective.recipe.supervisor
Configures supervisor, a program that will run and manage all your servers (ZEO, Zope, Varnish,Pound, Apache, whatever), and provide a single start/shutdown, plus status consoles and more. Verynice.
27.8. Useful Recipes 197
Plone Bootcamp, Best Practices for Plone Development
[supervisor]recipe = collective.recipe.supervisoruser = adminpassword = adminprograms =
10 zeo ${zeoserver:location}/bin/runzeo true20 instance ${buildout:directory}/parts/instance/bin/runzope true20 instance2 ${buildout:directory}/parts/instance2/bin/runzope true30 pound ${buildout:directory}/bin/poundrun true40 varnish ${buildout:directory}/bin/varnish true
Then, you can start everything with bin/supervisord.
You can use bin/supervisorctl to start an interactive prompt that lets you get the status of items andstart of stop them.
You can visit http://localhost:9001 to see a dashboard.
27.8.14 Update/Create Site
collective.recipe.updateplone
Can create Plone site in Zope, install products, run scripts, etc. Many features.
[plonesite]recipe = collective.recipe.updateploneplone-site = instance.testyinstall = Clouseau
This creates a new Plone site, testy, and installs Clouseau in it.
27.8.15 Selenium Test Runner
collective.recipe.seleniumrc
Runs the Selenium TestRunner, which allows command-line use of Selenium tests, running in a realbrowser.
[seleniumrc]recipe=collective.recipe.seleniumrc
27.8.16 Dump Versions
buildout.dumppickedversions
198 Chapter 27. Intro to Buildout
Plone Bootcamp, Best Practices for Plone Development
Dumps the versions #s of eggs to a file. Good for “freezing” the current version numbers of everything(for documentation, or to make your required versions for deployment, so that, even over time, youcan guarantee exactly what versions of everything you get).
[buildout]extensions = buildout.dumppickedversionsdump-picked-versions-file = versions/current-versions.cfg
Your production buildout.cfg could then reference versions/current-versions.cfgin it’s versions =.
27.9 Road Ahead
27.9.1 Road Ahead
• Try out these useful recipes
• Learn to write recipes yourself
• Learn about Martin’s (advanced) recipes at Uber Buildout Mark II
27.9. Road Ahead 199
Plone Bootcamp, Best Practices for Plone Development
200 Chapter 27. Intro to Buildout
CHAPTER
TWENTYEIGHT
SOFTWARE LICENSES
Plone and Zope are issued under different Open Source licenses (the GPL and ZPL, respectively).Archetypes is issued under a third license, a BSD-ish license.
The licenses are reprinted here in whole.
28.1 General Public License
Plone is issued under this license.
Terms and Conditions for Copying, Distribution and Modification
0. This License applies to any program or other work which contains a notice placed by the copyright holdersaying it may be distributed under the terms of this General Public License. The “Program”, below, refers toany such program or work, and a “work based on the Program” means either the Program or any derivativework under copyright law: that is to say, a work containing the Program or a portion of it, either verbatimor with modifications and/or translated into another language. (Hereinafter, translation is included withoutlimitation in the term “modification”.) Each licensee is addressed as “you”.
Activities other than copying, distribution and modification are not covered by this License; they are outsideits scope. The act of running the Program is not restricted, and the output from the Program is covered onlyif its contents constitute a work based on the Program (independent of having been made by running theProgram). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program’s source code as you receive it, in anymedium, provided that you conspicuously and appropriately publish on each copy an appropriate copyrightnotice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence ofany warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warrantyprotection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work basedon the Program, and copy and distribute such modifications or work under the terms of Section 1 above,
201
Plone Bootcamp, Best Practices for Plone Development
provided that you also meet all of these conditions:
1. You must cause the modified files to carry prominent notices stating that you changed the files and thedate of any change.
2. You must cause any work that you distribute or publish, that in whole or in part contains or is derivedfrom the Program or any part thereof, to be licensed as a whole at no charge to all third parties underthe terms of this License.
3. If the modified program normally reads commands interactively when run, you must cause it, whenstarted running for such interactive use in the most ordinary way, to print or display an announcementincluding an appropriate copyright notice and a notice that there is no warranty (or else, saying thatyou provide a warranty) and that users may redistribute the program under these conditions, and tellingthe user how to view a copy of this License. (Exception: if the Program itself is interactive but doesnot normally print such an announcement, your work based on the Program is not required to print anannouncement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are notderived from the Program, and can be reasonably considered independent and separate works in themselves,then this License, and its terms, do not apply to those sections when you distribute them as separate works.But when you distribute the same sections as part of a whole which is a work based on the Program, thedistribution of the whole must be on the terms of this License, whose permissions for other licensees extendto the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you;rather, the intent is to exercise the right to control the distribution of derivative or collective works based onthe Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a workbased on the Program) on a volume of a storage or distribution medium does not bring the other work underthe scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code orexecutable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
1. Accompany it with the complete corresponding machine-readable source code, which must be dis-tributed under the terms of Sections 1 and 2 above on a medium customarily used for software inter-change; or,
2. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge nomore than your cost of physically performing source distribution, a complete machine-readable copyof the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on amedium customarily used for software interchange; or,
3. Accompany it with the information you received as to the offer to distribute corresponding sourcecode. (This alternative is allowed only for noncommercial distribution and only if you received theprogram in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For anexecutable work, complete source code means all the source code for all modules it contains, plus any asso-ciated interface definition files, plus the scripts used to control compilation and installation of the executable.However, as a special exception, the source code distributed need not include anything that is normally dis-tributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the
202 Chapter 28. Software Licenses
Plone Bootcamp, Best Practices for Plone Development
operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, thenoffering equivalent access to copy the source code from the same place counts as distribution of the sourcecode, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided underthis License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, andwill automatically terminate your rights under this License. However, parties who have received copies, orrights, from you under this License will not have their licenses terminated so long as such parties remain infull compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grantsyou permission to modify or distribute the Program or its derivative works. These actions are prohibited bylaw if you do not accept this License. Therefore, by modifying or distributing the Program (or any workbased on the Program), you indicate your acceptance of this License to do so, and all its terms and conditionsfor copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automaticallyreceives a license from the original licensor to copy, distribute or modify the Program subject to these termsand conditions. You may not impose any further restrictions on the recipients’ exercise of the rights grantedherein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (notlimited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise)that contradict the conditions of this License, they do not excuse you from the conditions of this License.If you cannot distribute so as to satisfy simultaneously your obligations under this License and any otherpertinent obligations, then as a consequence you may not distribute the Program at all. For example, if apatent license would not permit royalty-free redistribution of the Program by all those who receive copiesdirectly or indirectly through you, then the only way you could satisfy both it and this License would be torefrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balanceof the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims orto contest validity of any such claims; this section has the sole purpose of protecting the integrity of thefree software distribution system, which is implemented by public license practices. Many people havemade generous contributions to the wide range of software distributed through that system in reliance onconsistent application of that system; it is up to the author/donor to decide if he or she is willing to distributesoftware through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of thisLicense.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or bycopyrighted interfaces, the original copyright holder who places the Program under this License may add anexplicit geographical distribution limitation excluding those countries, so that distribution is permitted onlyin or among countries not thus excluded. In such case, this License incorporates the limitation as if writtenin the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public Licensefrom time to time. Such new versions will be similar in spirit to the present version, but may differ in detail
28.1. General Public License 203
Plone Bootcamp, Best Practices for Plone Development
to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of thisLicense which applies to it and “any later version”, you have the option of following the terms and conditionseither of that version or of any later version published by the Free Software Foundation. If the Program doesnot specify a version number of this License, you may choose any version ever published by the FreeSoftware Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditionsare different, write to the author to ask for permission. For software which is copyrighted by the FreeSoftware Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Ourdecision will be guided by the two goals of preserving the free status of all derivatives of our free softwareand of promoting the sharing and reuse of software generally.
No Warranty
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FORTHE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTH-ERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDETHE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IM-PLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABIL-ITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY ANDPERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFEC-TIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR RE-DISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, IN-CLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISINGOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TOLOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOUOR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PRO-GRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITYOF SUCH DAMAGES.
28.2 Zope Public License
Zope is issued under this license.
Terms of the Zope Public License 2.1
This software is Copyright (c) Zope Corporation (tm) and Contributors. All rights reserved.
204 Chapter 28. Software Licenses
Plone Bootcamp, Best Practices for Plone Development
This license has been certified as open source. It has also been designated as GPL compatible by the FreeSoftware Foundation (FSF).
Redistribution and use in source and binary forms, with or without modification, are permitted provided thatthe following conditions are met:
1. Redistributions in source code must retain the above copyright notice, this list of conditions, and thefollowing disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, andthe following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name Zope Corporation (tm) must not be used to endorse or promote products derived from thissoftware without prior written permission from Zope Corporation.
4. The right to distribute this software or to use it for any purpose does not give you the right to useServicemarks (sm) or Trademarks (tm) of Zope Corporation. Use of them is covered in a separateagreement (see http://www.zope.com/about_us/legal/zope_logo_usage.html)
5. If any files are modified, you must cause the modified files to carry prominent notices stating that youchanged the files and the date of any change.
Disclaimer
THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION “AS IS” AND ANY EXPRESSED ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NOEVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUD-ING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OFUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of contributions made by Zope Corporation and many individuals on behalf of ZopeCorporation. Specific attributions are listed in the accompanying credits file.
28.3 BSD License
Archetypes and its packages are issued under this license.
Archetypes BSD License
28.3. BSD License 205
Plone Bootcamp, Best Practices for Plone Development
Copyright 2002-2003, Benjamin Saller <[email protected]>, and the respective authors. All rightsreserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided thatthe following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and thefollowing disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions andthe following disclaimer in the documentation and/or other materials provided with the distribution.
• Neither the name of Archetypes nor the names of its contributors may be used to endorse or promoteproducts derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “ASIS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PUR-POSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORSBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSE-QUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTEGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOW-EVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIA-BILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OFTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
206 Chapter 28. Software Licenses
CHAPTER
TWENTYNINE
COPYRIGHT AND LICENSEINFORMATION
While Plone is free software (covered under the GPL), this manual for the training is not. It may not bereproduced in any manner, nor re-published or altered, without written permission of the author.
Copyright 2003-2009 Joel Burton.
207
Plone Bootcamp, Best Practices for Plone Development
208 Chapter 29. Copyright and License Information
CHAPTER
THIRTY
GLOSSARY
Archetypes System for building custom content types by defining a schema of fields. Archetypes generatesthe edit form, view page, and handles a great deal of automated functionality.
ArchGenXML Program to convert a UML drawing into Archetypes code.
Dublin Core A schema of metadata fields that is a very common international standard. Plone implementsthe core of this.
Egg A Python concept of packaging up add-on software with metadata and dependency information. Mod-ern Plone products are almost always packaged as eggs.
Kupu Plone’s visual editor (easily seen when you edit a page).
intrinsic role A role assignment made via Manage users and groups (or that comes from your storage, likeLDAP). This connects a user/group to a role directly and everywhere, not just in a certain part of thesite (cf Local role, where the assignment is made locally).
local role A role assignment made on the sharing tab; connects a user/group to a role in a particular sectionof a site (cf Intrinsic role, where a role is assigned to a user/group as part of their definition).
metadata Organizational information about content, such as categorization fields or copyright information.Plone implements the core parts of the Dublin Core.
short name (Also called the “id”). The unique name for an object in the database. It is similar to a filenameon a filesystem. For example, in a standard Plone site, there is a top-level folder titled “News” thathas the short name of “news”.
state Current status of content item (private, published, etc.). You can move to a different state by using atransition.
transition Action that can take you to a state (eg, “publish” transition could take you to the “published”state)
UML “Unified Modeling Language”, an international standard to represent data and processes as “models”,with visual components. Can be used to draw data models which ArchGenXML can convert intoworking Archetypes.
ZODB Zope Object Database, the underlying object database Plone uses.
• Index
• Search Page
209
Plone Bootcamp, Best Practices for Plone Development
210 Chapter 30. Glossary
INDEX
Symbols#plone (IRC channel), 154| (vertical bar), 119
AA User’s Guide to Plone (book), 156Access contents information (permission), 82accessor method, 120actions
action categories, 127creating or editing, 128what is, 127
actions changes, 128Add portal content (permission), 83Add portal member (permission), 84Add portal topics (permission), 83add-on products
Alchemist, 181AnonymousCommenting, 172ArchAddOn, 175ArchGenXML, 175ATExtensions, 175ATFlashMovie, 174AutoRole, 171CacheFu, 183CalendarX, 176CallProfiler, 182Clouseau, 120, 182CMFEditions, 178Collage, 180collective.cheatsheets, 182collective.contentrules.mail, 177collective.contentrules.parentchild, 177collective.contentrules.template, 177collective.contentrules.webservices, 177collective.portlet.contribute, 176collective.portlet.workflowsteps, 179
collective.wfcomment, 179CSSManager, 129, 181DateBox, 175DCWorkflowGraph, 96, 179DocFinderTab, 182EnfoldDesktop, 179EnfoldServer, 179Entransit, 183ExternalEditor (Linux/Windows), 178FacultyStaffDirectory, 173FCKEditor.Plone, 175FeedMixer, 176FieldedTextIndex, 181FlowPlayer, 174FSDump, 182GetPaid, 179GloWorm, 182GSXML, 180i18ndude, 176ImageEditor, 174Iterate, 178LinguaPlone, 176LinkChecker, 177Listen, 172mailtoplone, 179ManageableIndex, 181Maps, 174Membrane, 171NoDuplicateLogin, 171PageTemplateProfiler, 182Plone Comments, 172plone.app.gloworm, 126plone.contentratings, 177plone.portlet.collection, 45plone.portlet.static, 45plone.portlet.tal, 176plone.reload, 182
211
Plone Bootcamp, Best Practices for Plone Development
Ploneboard, 171PloneFormGen, 172PloneHelpCenter, 173PloneLDAP, 170PloneSEO, 178PloneSoftwareCenter, 173PloneTrueGallery, 174Poi, 173PressRoom, 172PrintingMailHost, 180Products.TinyMCE, 175Quills, 173QuillsEnabled, 173ReCaptcha, 172RedirectionTool, 177Reflecto, 180Remember, 171RichDocument, 174Scrawl, 173ScriptableFields, 175Singing & Dancing, 178Slideshow Folder, 174SQLPASPlugin, 171TextIndexNG, 181Webcouturier DropDownMenu, 180WebServerAuth, 171WingIDE, 182z3c.alchemy, 181ZPT Debugger, 183
admin user, 87Alchemist, 181allow comments, 17Anonymous (role), 85AnonymousCommenting, 172Apache setup, 141ArchAddOn, 175Archetypes, 65, 209
boolean, 68building with paster, 71date, 68file, 68float, 67getting values, 120image, 68int, 67license, 205lines, 68richtext, 67
setting values, 120string, 67text, 67
Archetypes field types, 67boolean, 68date, 68file, 68float, 67image, 68int, 67lines, 68richtext, 67string, 67text, 67
Archetypes tagged valuesdefault, 68required, 68searchable, 68widget:description, 68widget:label, 68
ArchGenXML, 66, 175, 209ArgoUML, 65
starting, 65ATContentTypes: Add [TYPE] (permission), 83ATExtensions, 175ATFlashMovie, 174attribute errors (in ZPT), 118Authenticated (role), 85authoring.css, 131AutoRole, 171
Bbackup, 150, 196base.css, 131base_properties, 130
backgroundColor, 130evenRowBackgroundColor, 130fontColor, 130fontFamily, 130globalBackgroundColor, 130globalBorderColor, 130globalFontColor, 130headingFontFamily, 130logoName, 130textTransform, 130
booksA Users’ Guide to Plone, 156
212 Index
Plone Bootcamp, Best Practices for Plone Development
Cascading Style Sheets: The Definitive Guide,132
Definitive Guide to Plone, 157Dynamic HTML: The Definitive Reference, 132Head First Guide to HTML and CSS, 132Plone Live, 157Practice Plone 3, 158Professional Plone Development, 158Web Component Development with Zope 3, 158
boolean (Archetypes field type), 68BSD License, 205buildot
new mode, 190buildout
${variables}, 190[instance], 188[productdistros], 188[zeoserver], 189[zope2], 188backup recipe, 150choosing config file, 192cloning instance, 189command-line options, 189deployment strategies, 191develop =, 51egg versions, 198eggs =, 49, 187extending from web, 192find-links =, 186idea, 186instance, 188Linux intall, 5migrating, 192OSX install, 5overview, 49parts =, 186Plone version, 187productdistros, 52repositories, 186running, 50section names, 190SeleniumRC, 166syntax, 186templating, 190versions, 187Windows install, 5zcml =, 51, 187
buildout recipes
buildout.dumppickedversions, 198collective.recipe.backup, 196collective.recipe.omelette, 196collective.recipe.seleniumrc, 198collective.recipe.supervisor, 197collective.recipe.updateplone, 198infrae.subversion, 197plone.recipe.apache:build, 193plone.recipe.apache:config, 194plone.recipe.pound:build, 195plone.recipe.pound:config, 195plone.recipe.squid:build, 194plone.recipe.squid:instance, 194plone.recipe.varnish:instance, 194plonebootcamps.recipe.argouml, 195roadrunner:plone, 197zc.recipe.cmmi, 193zc.recipe.egg, 196zc.recipe.egg:scripts, 195
buildout.dumppickedversions (buildout recipe), 198Burton, Joel, 2
CCache Configuration Tool (Site Setup configlet), 144CacheFu, 183
concepts, 143minimal setup, 143
caching, 143CacheFu, 143concepts, 143speed comparisons, 149
CalendarX, 176CallProfiler, 182Cascading Style Sheets: The Definitive Guide
(book), 132categories, 15Classic portlet, 44classic products, 52clipboards, 91Clouseau, 120, 182CMFEditions, 178Cofiglets
Cache Configuration Tool, 144Collage, 180Collection portlet, 44, 45collections
fields, 31other fields, 32
Index 213
Plone Bootcamp, Best Practices for Plone Development
overview, 31sorting, 32tips, 33views, 32
collective.cheatsheets, 182collective.contentrules.mail, 177collective.contentrules.parentchild, 177collective.contentrules.template, 177collective.contentrules.webservices, 177collective.portlet.contribute, 176collective.portlet.workflowsteps, 179collective.recipe.backup (buildout recipe), 196collective.recipe.omelette (buildout recipe), 196collective.recipe.seleniumrc (buildout recipe), 198collective.recipe.supervisor (buildout recipe), 197collective.recipe.updateplone (buildout recipe), 198collective.wfcomment, 179columns.css, 131comments, 17Community Folder Workflow, 76Community Workflow, 74consultants, 156contacting the trainer, 160content
add restrictions, 18adding, 18comments, 17contents tab, 14copying, 9cutting, 9definition of, 57deleting, 9display menu, 29, 60duplicating, 10exclude from navigation, 17folderish, 58linking, 12paste, 9referencing, 11relating, 11renaming, 9structuring, 55table of contents, 18types, 12
content rulesactions, 36adding, 35conditions, 36
email sending improved product, 36limitations, 36overview, 35
content typesallow content types, 28, 60allow discussion, 28, 59available view methods, 29, 60benefits of separate types, 27, 58cloning, 27, 58collections, 31default view method, 29, 60description, 28, 59event, 12file, 12filter content types, 28, 59folder, 12icon, 28, 59id, 28, 59image, 12implicitly addable, 28, 59link, 12news item, 12page, 12portal_type, 28, 59properties, 28, 59title, 28, 59Type, 28, 59
contentish, 57contents tab, 14Contributor (role), 24, 85contributors, 16Contributors() (built-in function), 61Copy or Move (permission), 83copying content, 9copyright, 207copyrights, 16CreationDate() (built-in function), 61Creator() (built-in function), 61creators, 16Creators() (built-in function), 61css
adding css to kupu, 136css files (see css files), 131CSSManager, 129development mode, 129learning, 132measuring elements, 133resources, 132
214 Index
Plone Bootcamp, Best Practices for Plone Development
saving, 134tricks, 134trying out edits, 133web developer extensions, 132
CSS development mode, 129css files
authoring.css, 131base.css, 131columns.css, 131deprecated.css, 132generated.css, 131IEFixes.css, 132kupu.css, 131member.css, 131mobile.css, 131navtree.css, 131NS4.css, 132ploneCustom.css, 132, 134portlets.css, 131presentation.css, 131print.css, 131public.css, 131RTL.css, 132textLarge.css, 132textSmall.css, 132
CSSManager, 129, 181custom_folder, 108customizing Zope 3 templates, 107cutting content, 9
DData.fs
backup, 150date (Archetypes field type), 68DateBox, 175DCWorkflowGraph, 96, 179DEBs, 139default pages, 77
workflow, 77Definitive Guide to Plone (book), 157Delete objects (permission), 83deleting content, 9deployment strategies
buildout, 191deprecated.css, 132Description() (built-in function), 61discussion, 17
content, 17
DocFinderTab, 182documentation, 156Dublin Core, 209duplicating content, 10Dynamic HTML: The Definitive Reference, 132
EEditor (role), 24, 85Egg, 209eggs
what is, 48your own eggs, 51
eggs (buildout), 187Enfold Systems
EnfoldDesktop, 179EnfoldServer, 179
EnfoldDesktop, 179EnfoldServer, 179Entransit, 183Event (content type), 12exclude from navigation, 17exporting steps (Generic Setup), 101ExternalEditor (Linux/Windows), 178
FFacultyStaffDirectory, 173fckEditor, 10FCKEditor.Plone, 175feedback, 161FeedMixer, 176field types
boolean, 68date, 68file, 68float, 67image, 68int, 67lines, 68richtext, 67string, 67text, 67
FieldedTextIndex, 181file (Archetypes field type), 68File (content type), 12filesystem directory views, 108find-links (buildout), 186float (Archetypes field type), 67FlowPlayer, 174
Index 215
Plone Bootcamp, Best Practices for Plone Development
Folder (content type), 12Folder Workflow, 76folderish, 58folders
settings, 18FSDump, 182functional tests
Selenium, 163
GGeneral Public License, 201generated.css, 131Generic Setup, 101
content, 102exporting steps, 101importing steps, 102snapshots, 101structure, 102
getAuthenticatedMember() (portal_membershipmethod), 88
getFolderContents() (built-in function), 60getGroupsByUserId() (built-in function), 89getId() (built-in function), 60GetPaid, 179getter method, 120getUserName() (built-in function), 88GloWorm, 182gloworm, 126grandmother problem, 140groups
API, 89GSXML, 180
HHead First Guide to HTML and CSS (book), 132help
#plone, 154IRC, 154mailing lists, 156paste.plone.org, 155plone-devels mailing list, 156plone-users mailing list, 156support channel, 154
HTML filtering, 11humane tips
duplicate, 10
Ii18ndude, 176ids, 9IEFixes.css, 132image (Archetypes field type), 68Image (content type), 12ImageEditor, 174images
adding, 11importing steps (Generic Setup), 102infrae.subversion (buildout recipe), 197inherit permissions, 25instance (buildout), 188int (Archetypes field type), 67Intranet Folder Workflow, 76Intranet/Extranet Workflow, 75intrinsic role, 24, 209IPython, 196IRC, 154
paste.plone.org, 155isEffective() (built-in function), 61Iterate, 178
Kkeywords, 15Kupu, 209
HTML mode, 10overview, 10styles, 10
kupustyle menu, 136
kupu.css, 131
LLDAP, 170Lightweight Directory Access Protocol, 170lines (Archetypes field type), 68LinguaPlone, 176Link (content type), 12LinkChecker, 177linking, 12Linux packages, 139Listen, 172load balancing, 147
Pound, 147local role, 209local role blacklisting, 25local roles, 24
216 Index
Plone Bootcamp, Best Practices for Plone Development
Mmailing lists, 156mailtoplone, 179Manage users (permission), 84manage-viewlets, 126ManageableIndex, 181Manager (role), 85Maps, 174member, 88Member (role), 85member.css, 131Membrane, 171Mercury
antidote, 163metadata, 209
allow comments, 17categories, 15contributors, 16copyrights, 16creators, 16exclude from navigation, 17keywords, 15rights, 16table of contents, 18tags, 15
METAL, 113Macro Expansion for TAL, 113
minimal setup, 143mobile.css, 131ModificationDate() (built-in function), 61Modify portal content (permission), 83monkey work order, 93monkeys, 91movie, 66mutator method, 120my_info (example ZPT), 117
Nnasty tags, 11navigation
exclude items, 17next/previous, 18
navigation portlet, 44settings, 129
navtree.css, 131new workflows, 92News Item (content type), 12next/previous navigation, 18
NoDuplicateLogin, 171nothing, 119NS4.css, 132
Oomelette, 196One State Workflow, 74Owner (role), 26, 85ownership, 26
Ppackages
UML, 65Page (content type), 12PageTemplateProfiler, 182parts (buildout), 186PAS (Pluggable Authentication System), 86paste.plone.org, 155paster
building Archetypes product, 71building through the web, 71introduction, 71local commands, 72ZopeSkel, 72
paster.joelburton.com, 71pasting content, 9path syntax, 116
available objects, 116permissions, 82
Access contents information, 82Add portal content, 83Add portal member, 84Add portal topics, 83API, 88ATContentTypes: Add [TYPE], 83Copy or Move, 83creating new, 84Delete objects, 83discovering permissions, 82Manage users, 84Modify portal content, 83Reply to item, 84Request review, 84Review portal content, 84View, 82YourProduct: Add [YOURTYPE], 83
Pidgin, 154Placeful Workflow, 77
Index 217
Plone Bootcamp, Best Practices for Plone Development
Plonecss files, 131license, 201version numbers, 160
Plone Comments, 172Plone documentation, 156Plone Live (book), 157Plone Persistent Cookie Award, 2Plone version upgrade, 187Plone Workflow (now Community Workflow), 74plone-devels (mailing list), 156plone-users (mailing list), 156plone.app.gloworm, 126plone.contentratings, 177plone.portlet.collection, 45plone.portlet.static, 45plone.portlet.tal, 176plone.recipe.apache:build (buildout recipe), 193plone.recipe.apache:config (buildout recipe), 194plone.recipe.pound:build (buildout recipe), 195plone.recipe.pound:config (buildout recipe), 195plone.recipe.squid:build (buildout recipe), 194plone.recipe.squid:instance (buildout recipe), 194plone.recipe.varnish:instance (buildout recipe), 194plone.reload, 182Ploneboard, 171plonebootcamps.recipe.argouml (buildout recipe),
195ploneCustom.css, 132, 134PloneFormGen, 172PloneHelpCenter, 173PloneLDAP, 170PloneSEO, 178PloneSoftwareCenter, 173PloneTrueGallery, 174Pluggable Authentication System (PAS), 86Poi, 173portal_actions, 127portal_actions.listFilteredActionsFor() (built-in
function), 128portal_membership.checkPermission() (built-in
function), 88portal_membership.getAuthenticatedMember()
(built-in function), 89portal_membership.getMemberById() (built-in
function), 89portal_membership.listMemberIds() (built-in func-
tion), 89
portal_membership.listMembers() (built-in func-tion), 89
portal_setup, 101content, 102exporting steps, 101importing steps, 102snapshots, 101structure, 102
portal_skins, 108portal_type, 28, 59, 60portal_types, 28, 59portal_view_customizations, 107portlet types
classic, 44collection, 44, 45navigation, 44RSS, 44static, 44, 45TAL, 45
portletsblocking, 44group-specific, 43navigation (settings), 129placeful, 43type-specific, 43types, 44
portlets.css, 131Pound (load balancer), 147
setup, 147Practical Plone 3 (book), 158prerequisites, 1presentation.css, 131PressRoom, 172print.css, 131PrintingMailHost, 180productdistros, 52, 188products
choosing, 169classic products, 52configuring Plone to use, 50debugging installation, 54eggs, 48installation flowchart, 52installation overview, 48multiple sites, 48what is, 48your own products, 51ZCML slugs, 51
218 Index
Plone Bootcamp, Best Practices for Plone Development
Products.TinyMCE, 175Professional Plone Development (book), 158proxy servers, 140public.css, 131Python
attributes versus methods, 118
QQuills, 173QuillsEnabled, 173
RReader (role), 24, 85ReCaptcha, 172RedirectionTool, 177references, 11Reflecto, 180related content, 11Remember, 171renaming content, 9Reply to item (permission), 84repozo, 150
buildout, 196Request review (permission), 84Review portal content (permission), 84Reviewer (role), 24, 85RichDocument, 174richtext (Archetypes field type), 67rights, 16road ahead, 159roadrunner, 197roadrunner:plone (buildout recipe), 197roles, 84
Anonymous, 85Authenticated, 85Contributor, 85Editor, 85intrinsic role, 24local roles, 24Manager, 85Member, 85Owner, 85Reader, 85Reviewer, 85
RPMs, 139RSS, 16RSS Portlet, 44RTL.css, 132
SSample Archetypes
movie, 66SampleCorp, 128
base_properties changes, 129differences from Plone default, 125mockup, 125moving viewlets, 127navigation portlet settings, 129
Scrawl, 173ScriptableFields, 175search
overview, 16SearchableText, 68security
admin user, 87Anonymous (role), 85Authenticated (role), 85Contributor (role), 85Contributor role, 24debugging, 86Editor (role), 85Editor role, 24HTML filtering, 11inherit permissions, 25intrinsic role, 24local role blacklisting, 25local roles, 24Manager (role), 85Member (role), 85members, 88Owner (role), 85Owner Role, 26ownership, 26PAS, 86permissions, 21, 24, 82Reader (role), 85Reader role, 24Reviewer (role), 85Reviewer role, 24roles, 22, 84sharing, 24, 26users, 24verbose security, 86
Selenium, 163actions, 164buildout testrunner, 198
Index 219
Plone Bootcamp, Best Practices for Plone Development
checks, 165concepts, 164locators, 164running tests from browser, 165running tests with SeleniumRC, 166sample test, 164saving tests as Python, 166
SeleniumRC, 166installing, 166
seleniumrc, 198Self Approval Workflow, 92setter method, 120setup
Apache, 141Linux, 139load balancing, 147multiple Zopes, 146Pound (load balancer), 147proxy servers, 140server startup, 140speed comparisons, 149Squid, 143Varnish, 142ZEO with single instance, 146
sharing, 26short name, 209short names, 9Simple Publication Workflow, 12, 73Simple Trusting Workflow, 77Singing & Dancing, 178Site Setup configlets
Cache Configuration Tool, 144site-building strategy, 7skinning
custom folder, 108customizing Zope 3 templates, 107filesystem directory views, 108finding skins, 108portal_skins, 108portal_view_customizations, 107process, 105skin object location, 106TALES (see TALES), 116test function, 110two skinning systems, 107types of skin objects, 106urls, 106where to put skins, 106
Zope 2 skin folders, 108Zope 3 templates, 107
Slideshow Folder, 174smart folders
overview, 31snapshots, 101SQLPASPlugin, 171Squid setup, 143src (directory), 51state, 209states, 93Static Text portlet, 44, 45string (Archetypes field type), 67stripped tags, 11structure
Generic Setup folder, 102structuring site, 55style menu in kupu, 136Subject() (built-in function), 61Subversion
getting eggs from, 197support channel, 154
paste.plone.org, 155svn
getting eggs from, 197syndication
RSS, 16syntax errors (in ZPT), 117
Ttable of contents, 18tags, 15TAL, 113
namespace, 114replacing best practices, 115syntax, 114tal:content, 114tal:replace, 114Template Attribute Language, 113using div tag, 115using span tag, 115
TAL portlet, 45tal: namespace, 114tal:content, 114tal:replace, 114TALES, 113, 116
| (vertical bar), 119alternative expressions, 119
220 Index
Plone Bootcamp, Best Practices for Plone Development
available objects, 116calling final element, 119nothing, 119path syntax (see path syntax), 116syntaxes, 116TAL Expression Syntax, 113vertical bar, 119
test runningroadrunner, 197
testingSelenium, 163
text (Archetypes field type), 67TextIndexNG, 181textLarge.css, 132textSmall.css, 132theming
base_properties, 130CSS development mode, 129SampleCorp mockup (see SampleCorp), 125theme overview, 126
TinyMCE, 10Title() (built-in function), 61transition, 209Type, 28, 59Type() (built-in function), 60
UUML, 209
boolean field type, 68converting, 66date field type, 68editors, 65file field type, 68float field type, 67image field type, 68int field type, 67lines field type, 68packages, 65richtext field type, 67string field type, 67text field type, 67
uml.joelburton.com, 66user, 88user groups, 159users
getting in Page Templates, 88getting in Python, 88
VVarnish setup, 142verbose security, 86version numbers, 160versions in buildout, 187vertical bar, 119View (permission), 82viewlets
rearranging viewlets, 126what is, 126
visual editoroverview, 10
WWeb Component Development with Zope 3 (book),
158Web Developer Extensions, 132Webcouturier DropDownMenu, 180WebServerAuth, 171WingIDE, 182workflow, 77, 93
adding permissions, 97adding states, 93adding transitions, 95changing states, 13DCWorkflowGraph, 96files and images, 77mapping workflow to types, 96placeful, 77state permission grid, 93state permissions, 94transition scripts, 94transitions, 94
workflows, 92Community Folder Workflow, 76Community Workflow (was Plone Workflow),
74Folder Workflow (now Community Folder
Workflow), 76folder-specific workflows, 76Intranet Folder Workflow, 76Intranet/Extranet Workflow, 75One State Workflow, 74Plone Workflow (now Community Workflow),
74Self Approval Workflow, 92Simple Publication Workflow, 12, 73Simple Trusting Workflow, 77
Index 221
Plone Bootcamp, Best Practices for Plone Development
WYSIWYG editors, 10
YYourProduct: Add [YOURTYPE] (permission), 83
Zz3c.alchemy, 181zc.recipe.cmmi (buildout recipe), 193zc.recipe.egg (buildout recipe), 196zc.recipe.egg:scripts (buildout recipe), 195ZCML
slugs, 51zcml
buildout, 187Zen view of span tag, 115ZEO, 145
installation, 145multiple Zopes, 146single instance, 146ZEO server, 145
zeoserver (buildout), 189zmi
portal_skins, 108portal_view_customizations, 107
ZODB, 209backup, 150backups, 196
Zopelicense, 204
Zope Public License, 204zope2 (buildout), 188ZopeSkel, 72ZPT
attribute errors, 118creating page template, 117my_info example template, 117syntax errors, 117TALES (see TALES), 116test function, 110testing templates, 117
ZPT Debugger, 183
222 Index