APPENDIX A Key Configurations and Some APIs

THIS APPENDIX CONTAINS some of the key development configurations for , Plone, and Python. This appendix provides information for developers of sites, and it also lists some ofthe most usefulApplication Programming Interfaces (APIs).

Setting Up Your Environment

The following sections relate to configuring your development or production environment for optimal usage. If you're developing a lot with Plone, I rec­ ommend these settings.

Setting Up PYTHONPATH

Setting up PYTHONPATH is extremely useful because it allows you to easily access all the Zope functionality from a Python prompt. You can easily test if you have this set up-you can just attempt to import the PageTemplate module from Products. If this isn't set up, you should see the following:

$ python -c "import Products.PageTemplates" Traceback (most recent call last): File "", line 1, in ? ImportError: No module named Products.PageTemplates

Unix} Linux} and Mac OS X

First, find the Products directory of your Zope installation (not the instance horne). On the standard installation, this is at /opt/Zope- 2.7 /lib/python; on Windows it's at c: \Program Files\Plone\Zope\lib\python. When Python starts, it reads an envi­ ronmentvariable called PYTHONPATH and puts all those directories in thatvariable into the search path for new modules. So you need to add your directory to that variable.

465 AppendixA

You do this using the export command, to see if PYTHONPATH contains anything initially, run the following:

$ export I grep PYTHONPATH declare -x PYTHONPATH="/home/andy/modules"

In my case, I already have an environment variable called PYTHONPATH, although chances are your computer won't have this set up. In my case, it contains a path to some internal modules, so you need to add Zope 2 into that path, like so:

$ export PYTHONPATH="loptlZope-2.7Ilib/python:$PYTHONPATH"

You can check that this works by repeating the following command and ensuring no error is raised.

python -c "import Products.PageTemplates"

Windows

The key directory on Windows is at c: \Program Files\Plone\Zope\lib\python. When Python starts, it reads an environment variable called PYTHONPATH and puts all those directories in that variable into the search path for new modules. So you need to add your directory to that variable. On Windows, to add an environment variable, right-dick the My Computer icon and select Properties. In the System Properties dialog box, dick the Advanced tab and then, underneath System Variables, dick New, as shown in Figure A-l.

Environment Variables IJ EI

~v~f~~ ------~ YI!ri.IbIe v...

~ ... I ~dot... ~

SYstemv8riables-- -- , v PROCESSOIUD... x86 faMy 6 Model 7 Steppr.g 3, GetU ••• PROCESSOR_LE ••• 6 PROCESSOR_RE ••• 0703 J lEM' C:\WItM\lEM' 1M' C:\WiN'IT\lEM' ;:J

Net!•.. ~ ... De!ete I'

Figure A-l. The Environment Variables dialog box

466 Key Canfiguratians and Same APIs

This will open the System Variable dialog box. To edit a variable, select a variable from the list and edit the value, as shown in Figure A-2. The variable should be PYTHONPATH, and the value should be the place your Plone is located, for example, c: \Program Files \Plone 2 \Zope \lib \python.

Edlt 5y,tem V.n.ble 613

Yar1/lble (:iorne: II'YTHC)fA>ATH

y~ ~okJe: J MUi ""'6411_

()I( C.....".

Figure A-2. Adding the variable

Now you should be able to run the import statement as usual. You can do that from the command line or fire up PythonWin and trythe import as Figure A-3 demonstrates.

'. PythonWin IIII~ EI

PythonWin 2.3.3 (#51, Oec 182003,20.22.39) [MSC v.1200 32 bit (Intel)] on win32 . PoTbons Copyright 1994-2004 Mark Hammond ([email protected]) - see 'HelplAbout PythonWin' for further copyright Information »> imuort Produces. PageTemplaees »> ~rint Produces. PageTemplaees

Figure A-3. Importing in Python Win

467 AppendixA

Not only can you now import products, but you can also import Zope from the Python command line, which is key for many scripts and tools in the more advanced chapters of the book.

Setting Up to Run Unit Tests

Plone comes with some several hundred unit tests, which are excellent ways of ensuring that your Plone is functioning correctly. You can find Plone unit tests in CMFPlone/tests. Ityou develop in Plone, then it'd be a good idea to set these up so you can add your own tests. To run these tests, you need ZopeTestCase. In the future, this will probably be packaged with Plone, but for the moment you can download it from http://zope . org/Members/ shh/Zope TestCase. The installation is a little unusual-you need to untar the package and then place it in lib/python/Testing directory ofyour Zope software horne. On this is usually in /opt/Zope- 2.7. On Windows this is c: \Program Files\Plone 2\Zope. Next you need a script that will run the tests. I usuallywrite a little shell script to do so and place it in the bin directory of my Plone instance. I can then just run the shell script to run the tests. On Unix where my instance is at /var /test, my script looks like the following:

export SOFTWARE_HOME=/opt/Zope-2.7/1ib/python export INSTANCE_HOME=/var/test123

echo Testing CMFPlone ... cd $INSTANCE_HOME/Products/CMFPlone/tests python2.3 runalltests.py

On Windows the equivalent is as follows:

set SOFTWARE_HOME=c:\Program Files\Plone 2\Zope set INSTANCE_HOME=c:\Program Files\Plone 2\Data

cd "c:\Program Files\Plone 2\Data\Products\CMFPlone\tests" "c:\Program Files\Plone 2\Python\python.exe" runalltests.py

The output should be something like the following:

468 Key Canfiguratians and Same APIs

[root@basil bin]# ./testAll.sh Testing CMFPlone ... SOFTWARE_HOME: /opt/Zope-2.7/lib/python INSTANCE_HOME: /opt/Zope-2.7/lib/python/Testing Loading Zope, please stand by ... done (7.8995) Installing CMFCore ... done (1.3635) Installing CMFDefault ... done (1.1795) Installing CMFCalendar ... done (0.1955) And so on ...

The unit testing framework is a great basis for allowing you to unit test your own products. Ifyou do write products or software development in Plone, then ideallyyou'd write unit tests for them. The unit tests in Plone provide an excellent set of examples for you.

Zope Configuration File

The Zope configuration file is written in a format called ZConfig. You can find more information on ZConfig at http://www . zope. org/Members/fdrake/zcanfig/. The configuration file is called zope. canf and is contained in the etc directory of your Zope installation. Some installers also create a plane. conf file that contains Plone-specific information. The recommended platform for all Plone 2 installations is Zope 2.7. This was the first version ofZope to feature this file; in earlierversions ofZope, parameters were passed to Zope in one command line. All comments in the file begin with #. In ZConfig you define variables that can then be used later in the configuration file; you do this with a line in the fol­ lowing format:

%define variable-name variable-value

The following are example definitions in my config file:

%define INSTANCE /var/test %define ZOPE /opt/Zope-2.7

You can then reference the variables using a $prefix (for example, $INSTANCE). Table A-l shows the full Zope configuration for 2.0.1. The Directive column shows the name of the variable in the configuration file. The Description column details what the directive does, and the Default column teIls you what will happen if no value is set. In the Example column, I've detailed some examples to help explain the directive.

469 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File Directive Description Default Example instancehome The path to the data files, local product files, import None Ivar Izope or the $INSTANCE directory, and Extensions directory. Each instance of Zope should have one of these. client home The directory in which a running Zope's process INSTANCE/var $INSTANCE_HOME/var identifier files are placed, such as the process ID file, Z2. pid. Not recommended for use; look at pid-filename instead. path Name of a directory that should be inserted into the None path Ihome/pythonModules beginning of Python's module search path. This directive may be specified as many times as needed to insert additional directories. Since this may be too late, altering the PYTHONPATH,described earlier in this appendix, is preferred. products Name of a directory that contains additional Product None products Ihome/chrisml packages. This directive may be used as many times projects/myproducts as needed to add additional collections of products. Each directory identified will be added to the _path _ ofthe Products package. I don't recommend using this; normally I find using an instance horne is enough. Using this has also caused some bug reports withPlone.

470 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example

PRODUCTENV environment A section that can be used to defme arbitrary key/value None MY- - pairs for use as environment variables during Zope's VARfoobar run cyde. It isn't recommended to set system-related environment variables such as PYTHONPATH within this seetion. Most startup scripts will defme system -related environment variables for you, so this isn't recommend for use. debug-mode A switch that controls several aspects of Zope operation On debug-mode off useful for developing under Zope. I recommend running all development servers in this mode. Plone installers may set this to off by default for performance reasons. effective-user !fyou intend to run Zope as the root user, you must None effective-user zope supply this directive with an effective username or user ID number to which Zope will suid after the server ports are bound. This directive has effect only under Unix and if Zope is started as the root user. This is useful because you can create a user account called zope and set the effective user to zope, ensuring Zope will be run as that user. It'll also let you bind to low-value ports such as 21 or 80.

471 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example enable-product­ If this direetive is turned on, Zope performs "produet On enable-produet-installation installation installation" (the registration ofPython modules in off various Produets direetories) at startup. Turning this off ean speed Zope/ZEO startup time, but it ean also eause YOUfControl_Panel produet list to beeome desynehronized with the contents OfyOUf Produets direetories. loeale This enables loeale (internationalization) support None loeale fr FR by supplying aloeale name to be used. See YOUf operating system documentation for loeale information speeifie to YOUfsystem. port-base This is the offset applied to the port numbers used for 0 1000 ZServer eonfigurations. For example, ifthe http-server port is 8080 and the port-base is 1000, the HTTP server will listen on port 9080. This is great ifyou're running multiple PIon es on one box and need to quickly change all the port numbers. datetime-format This sets this variable either to us or international us datetime-format to force the DateTime module to parse date strings international either with month-before-days-before-year (us) or with days-before-month-before-year (international). The default behavior ofDateTime (when this setting is left unset) is to parse dates as U.S. dates.

472 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example zserver-threads This specifies the number of threads that Zope's 4 zserver-threads 10 ZServer will use to service requests. Setting this high doesn't increase performance on most sites. Instead use ZEO and caching. python-check-interval This specifies an integer representing the Python 500 python-check-interval 1000 interpreter "check interval." This interval determines how often the interpreter checks for periodic things such as thread switches and signal handlers. Setting this high doesn't increase performance on most sites. zserver-read-only-mode Ifthis directive is set to on, it'll cause Zope to inhibit off zserver-read-only-mode on the creation of log files and process ID (PID) files. Access and event log files will be presented on standard output. pid-filename The path to the file in which the Zope PIDs will be CLIENT HOMEI pid-filename Ihome/chrisml written. This defaults to client-home/Z2. pid. Z2.pid projects/sessions/varl Z2.pid lock-filename The path to a "lock file," which will be locked CLIENT HOMEI lock-filename Ihome/chrisml by Zope while it's running. Z2.1ock projects/sessions/varl Z2.1ock mime-types This teIls Zope ab out additional mime. types files None mime-types $INSTANCE/etcl that should be loaded. The files have the same format mime. types as the mime. types file distributed with Apache. The mime-types setting may be given more than once in the configuration file.

473 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example structured-text­ This sets the default starting HTML header level for 3 structured-text-header­ header-level StructUfed Text documents. The default is 3, which level 1 implies that top-level headers will be created with an

tag. Unfortunately, at the moment, CMF ignores this value, something that'll be fixed one day. rest-input-encoding This specifies the input encoding of re- The system rest-input-encoding iso- StructuredText documents (for example, utf-8, iso- default 8859-15 8859-15, or any other valid encoding recognized by Python). The default is YOUfPython's default encoding. rest-output-encoding This specifies the output encoding of re- The system rest-output-encoding iso- StructuredText documents (for example, utf-8, iso- default 8859-15 8859-15, or any other valid encoding recognized by Python). The default is YOUfPython's default encoding. cgi-environment A seetion that allows a user to define arbitrary key I None value pairs for use as the initial CGI environment HTTPS SERVERFoobar variables. Server 1.0 HTTPS_PORT443 dns-server This specifies the IP address OfyOUf Domain Name None dns-server 127.0.0.1 System (DNS) server to cause resolved hostnames to be written to Zope's access log. If you set this, DNS delays in lookups will slow YOUfsite down.

474 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example

ip-address This is the default IP address on which Zope's None ip-address 127.0.0.1 various server protocol implementations will listen for requests. If this is unset, Zope will listen on all IP addresses supported by the machine.

http-realm The HTTP Rea1m he ader value sent by this Zope Zope Plone instance. This value often shows up in basic authentication dialog boxes.

automatically-quote­ Set this directive to off to disable the autoquoting on automatically-quote-dtml­ dtml-request-data of implicitly retrieved REQUESTdata by Dynamic request-data on HTML (DTML) code, which contains a < when used in construction. When this directive is on, all data implicitly retrieved from the REQUESTin DTML (as opposed to addressing REQUEST.somevarname directly) that contains a< will be HTML-quoted when interpolated via a or &dtml- construct. This mitigates the possibility that DTML programmers willleave their sites open to a dient -side Trojan horse attack. trusted-proxy This defines one or more trusted-proxies directives, None trusted-proxy each of which is a hostname or an IP address. www.example.com

475 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example publisher-profile-file This names a file on the file system that causes None publisher-profile-file Zope's Python profiling capabilities to be enabled. $INSTANCE/var/profile.dat For more information, see the Profiling tab of Zope's control panel via the Zope Management Interface (ZMI). Note that setting this file name will cause Zope code to be executed much more slowly than normal. This shouldn't be enabled in production. security-policy­ The default Zope security machinery is implemented C security-policy­ implementation in C. Change this to python to use the Python version implementation python of the Zope security machinery. The Python version is slower but provides key information via VerboseSecurity. skip-authentication­ Set this directive to on to cause Zope to skip checks off skip-authentication­ checking related to authentication for servers that serve only checking on anonymous content. skip-ownership-checking Set this directive to on to cause Zope to ignore on skip-ownership-checking off ownership checking when attempting to execute "through the Web" code. Ey default, this directive is on in order to prevent Trojan horse security problems whereby a user with less privilege can cause a user with more privilege to execute dangerous code.

476 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example maximum-number-of­ An integer value representing the number of items 1000 maximum-number-of-session­ session-objects to use as a "maximum number of subobjects" value objects 10000 of the /temp _ folder / session _ data transient object container. session-add-notify­ This is an optional Zope path name of a callable unset session-add-notify-script­ script-path object to be set as the "script to call on object path /scripts/add_notifier addition" of the session _ data transient object container created in the /temp _ folder folder at startup. For use with sessions. session-delete-notify­ An optional Zope path name of a callable object to Unset session-delete-notify­ script-path be set as the "script to call on object deletion" of the script-path /scripts/ session _data transient object container created in deI notifier the /temp _ folder folder at startup. For use with sessions. session-timeout­ This is an integer value representing the number 20 session-timeout-minutes 30 minutes ofminutes to be used as the "data object time out" ofthe /temp _ folder / session _ data transient object container. suppress-all-access­ Ifthis directive is set to on, no access mIes in your off suppress-all-access­ rules Zope site will be executed. This is useful ifyou lock rules on yourself out of a particular part ofyour site by setting an improper access rule.

477 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example suppress-all-site-roots Ifthis directive is set to on, no site roots in YOUf off suppress-all-site-roots on Zope site will be effective. This is useful if you lock YOUfseif out of a particular part OfyOUf site by setting an improper site root. database-quota-size Set this directive to an integer in bytes to place a None database-quota-size 1000000 hard limit on the size to which the default FileStorage-backed Zope database can grow. Additions to the database will not be permitted once this file size has been exceeded. read-only-database This causes the main Zope FileStorage-backed ZODB off read-only-database on to be opened in read-only mode. Other files, such as log files, will be written. zeo-client-name Ifyou want a persistent ZEO dient cache that None zeo-client-name on retains cache contents across ClientStorage restarts, you need to define a zeo-client-name. If you use ZEO and you dont set a zeo-client-name, the dient cache is stored in temporary files that are removed when the ClientStorage shuts down. The value of zeo- client -name uniquely identifies the local cache files created if this Zope is a ZEO dient.

478 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example logger This area should define one or more logger The access log will sections of the names access, event, and trace. log to the file level all The access logger logs Zope server access. The dnstancehome>/ dogfile> event logger logs Zope event information. The log/Z2 .log at level path $INSTANCE/log/ trace logger logs detailed server re quest INFO,the event log event.log information (for debugging purposes only). Each will log to the file log level info logger section may contain a level name/value at level INFO, and pair that indicates the level of logging detail to the trace log wont capture for this logger. The default level is INFO. be written dogger access> Level may be CRITICAL,ERROR, WARN, INFO, DEBUG, anywhere. level WARN and ALL. Each logger section may additionally dogfile> contain one or more handler sections that indicate path $INSTANCE/log/ a type oflog handler (file, syslog, NT event log, and Z2.log so on) to be used for the logger being defined. format %(message)s There are five types ofhandlers: logfile, syslog, win32-eventlog, http-handler, and email- noti fier. Each handler type has its own set of allowable subkeys that define aspects of the handler. All handler sections also allow for the specification of a format (the log message format string), a dateformat (the log message format for date strings), and a level, which has the same semantics of the overall logger level but overrides the logger's level for the handler it's defined upon.

479 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example warnfilter A section that allows you to define a warning filter. None

480 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example servers A set of seetions that allow the specification of HTTP server on port Zope's various ZServer servers. Seven server types 8080 and FTP on # valid keys are "address" may be defined: http-server, ftp-server, 8021 and "force-connection­ webdav-source-server,persistent-cgi,fast-cgi, close" monitor-server, and icp-server. Ifno servers are address 8080 defined, the default servers are used. Ports may be # force-connection-close specified either in simple form (80) or in complex on form including hostname 127.0.0.1:80. If the hostname is omitted, the default-ip-address is used as the hostname. Port numbers are offset by the setting of port-base, which defaults to 8000. # valid key is "address" Your Plone installation may have changed these address 8021 for you to make it easier for an initial instalI.

481 Key Canfiguratians and Same APIs

Table A -1. Directives in the Zope Configuration File (Continued) Directive Description Default Example

database A database section allows the definition of custom See example. database and storage types. More than one zodb_ db # Main FileStorage database section can be defined. The values inside the storage dilestorage> are set by the values in the particular database dient. path $INSTANCE/var/ Data.fs mount-point / # Temporary storage database (for sessions) name temporary storage for sessioning mount-point / temp_folder container-class Prod­ ucts.TemporaryFolder.Tempor aryContainer

482 Key Canfiguratians and Same APIs

üf all configurations, the last few (database, servers, and loggers) are directives inside a simple Extensible Markup Language (XML) style syntax. Users ofthe Apache log file will be familiar with this format. You can apply these directives multiple times. For example, one common configuration from the Mac and Windows installer is to create HTTP connections on two ports, port 80 and port 8080. You do this in the following manner:

address 8080

address 80

Text Formatting Rules

Plone has External Editor and Epoz, two excellent tools for editing HTML. However, two formats of plain text are common in Zope and Python: Structured Text and restructured text. Because ofthe quality ofthese editors, I don't believe you'lI need to use these formats, but ifyou're going to develop Zope or Plone, then chances are you'lI come across these formats. Both of these formats try to do similar things-they provide a system for marking up plain text in such a manner that it produces HTML. This is aimed at developers who like and are familiar with plain text but who don't want to go to the effort of producing HTML.

Structured Text

The following is the reproduction of an artide written previously. For an online example,refertohttp://plone.org/documentation/howto/UsingStructuredText.ln the following artide, the indentation of the text in code font is crucial to how the text displays.

Basic Formatting

The basic idea in structured text is a paragraph. The following snippet:

This is the first paragraph.

This is the second paragraph.

483 AppendixA

is converted to the following in HTML:

This is the first paragraph.

This is the second paragraph.

Whitespace matters in structured text. In this case, a blank line between two lines causes a new paragraph. This is an intuitive idea. For instance, in e- mail, paragraphs are separated by whitespace. To introduce emphasis, structured text uses another text convention: asterisks. Note the following snippet:

This is the *first* paragraph.

This is the **second** paragraph.

In HTML, this snippet intro duces the em tag and the strong tag:

This is the first paragraph.

This is the second paragraph.

Again, this is a common pattern in e-mail. Several other common patterns are supported, such as referring to a piece of jargon:

When you see 'STX', you know this is shorthand for 'Structured Text'.

The HTML output is as follows:

When you see STX, you know this is shorthand for Structured Text.

Using Indentation

The preceding section focused on text conventions that convey a semantic meaning. This semantic meaning, when processed by structured text, produces certain HTML tags. In structured text, indentation is also important in conveying semantic meaning. The most basic is the idea ofheadings in HTML. In the following snippet, indentation conveys an outline-like structure:

Using Indentation The preceding section focused on text conventions that convey a semantic meaning. This semantic meaning, when processed by Structured Text, produces certain HTML tags.

484 Key Canfiguratians and Same APIs

This pro duces the following HTML:

Using Indentation

The preceding section focused on text conventions that convey a semantic meaning. This semantic meaning, when processed by Structured Text, produces certain HTML tags.

That is, the indentation conveyed a semantic meaning. The paragraph was subordinate to the heading, and the relationship is thus expressed in HTML. In fact, outline relationship can be continued, like so:

Using Indentation

The preceding section focused on text conventions that convey a semantic meaning. This semantic meaning, when processed by Structured Text, produces certain HTML tags.

Basics of Indentation

In this section we will investigate the basics of indentation ...

This pro duces the following HTML:

Using Indentation

The preceding section focused on text conventions that convey a semantic meaning. This semantic meaning, when processed by Structured Text, produces certain HTML tags.

Basics of Indentation

In this section we will investigate the basics of indentation ...

Hyperlinks

485 AppendixA

Lists and Items

Lists are also supported in structured text, including unordered, ordered, and descriptive lists. The convention unordered lists is a common pattern in text­ based communication. HTML has three kinds oflists:

• Unordered lists

• Ordered lists

• Descriptive lists

Structured text allows you to use the symbols *, 0, and - to connote list items. The previous example produces this HTML:

HTML has three kinds of lists:

  • Unordered lists

  • Ordered lists

  • Descriptive lists

  • The structured text conventions for ordered lists is as follows:

    HTML has three kinds of lists: 1. Unordered lists

    2. Ordered lists

    3. Descriptive lists

    This pro duces the following:

    HTML has three kinds of lists:

    <01>
  • Unordered lists

  • Ordered lists

  • Descriptive lists

  • 486 Key Canfiguratians and Same APIs

    Descriptive lists are also easily accommodated using double dash es, like so:

    Ordered Lists -- HTML viewers convert the list items into a numbered series.

    Descriptive Lists -- Usually used for definitional lists such as glossaries.

    This becomes the following HTML:

    Ordered Lists

    HTML viewers convert the list items into a numbered series.

    Descriptive Lists

    Usually used for definitional lists such as glossaries.

    Example Code

    As mentioned, structured text authors can use an easy convention to get the monotype semantics ofthe code tag from HTML. For instance, the following code:

    When you see the dialog box, hit the 'OK' button. is rendered into the following HTML:

    When you see the dialog box, hit the Ok button.

    However, sometimes you want long passages of code. For instance, what if you wanted to document a Python function in the middle of an article discussing Python? You can indicate a code block by ending a paragraph with two colons (: :) and indenting the following paragraph(s). For instance, this structured text snippet:

    In our next Python example, we convert human years to dog years:def dog_years(age): """Convert an age to dog years""" return age*7 would be converted to the following HTML:

    487 AppendixA

    In our next Python example, we convert human years to dog years:

     def dog_years(age): """(onvert an age to dog years""" return age*7 

    The convention of combining : : at the end of a paragraph-ending sentence and indenting a block does more than apply code semantics. It also escapes the indented block. That is how the structured text and HTML snippets in this article are left alone, rather than being rendered. For example, the less than, greater than, and ampersand symbols in this code block are escaped:

    Here's an HTML example:

    This is a page about dogs &cats.

    to produce this HTML:

    Here's an HTML example:

      

    This is a page about dogs &cats.

    Hyperlinks

    The previous sections focused on ways to get certain presentation semantics in HTML by using common text conventions. But the Web isn't just HTML. Linking words and phrases to other information and including images are equa11y important. Fortunately, structured text supports conventions for hyperlinks and image tags. For instance, 1'11 start with a simple hyperlink. Ityou have a structured text paragraph discussing Python, like so:

    For more information on Python, please visit the "Python website":http://www.python.org/.

    488 Key Canfiguratians and Same APIs

    It becomes the following:

    For more information on Python, please visit the Python website.

    The convention is fairly simple:

    • The text of the reference is enclosed in quotes.

    • The second quotation mark is followed by a colon and a URL.

    • The URL can be followed by punctuation.

    This basic convention has a number ofvariations. Far instance, relative URLs are possible, as aremail to URLs and images. reStructured Text reStructured Text is a newvariation on the Structured Text to avoid some ofthe issues people have encountered with the older version. Not only does Structured Text fail in internationalization cases, but it produces nonvalid markup. Further, the syntax can be a little hard to follow. The new reStructured Text has now become one of the standards of Python far documenting code and is used in the Docutils project. The onIine documentation is so good that I fully recommend reading it at http://docutils.sourceforge.net/rst.html. The following is a reproduction ofthe material by Richard Jones.

    Introduction

    The most basic pattern recognized is a paragraph. This is achunk oftext that's separated by blank lines (one is enough). Paragraphs must have the same indentation-that is, they must line up at their left edge. Paragraphs that start indented will result in indented quote paragraphs. Far example, the following code:

    This is a paragraph. It's quite short

    This paragraph will result in an indented block of text, typically used for quoting other text.

    This is another one.

    489 AppendixA

    results in this:

    This is a paragraph. It's quite short.

    This paragraph will result in an indented block of text, typically used for quoting other text.

    This is another one.

    Text Styles

    Inside paragraphs and other bodies oftext, you can additionally mark text for italies with *italics* or bold with **bold**. Ifyou want something to appear as a fixed-space literal, use double backquotes: ' '. Note that no further fiddling happens inside the double back­ quotes-so asterisks and whatnot are left alone. If you find that you want to use one of the "special" characters in text, you'lI generally be OK-reStructuredText is pretty smart. For example, the asterisk is handled just fine. If you actually want text surrounded by asterisks to not be ital­ icized, then you need to indicate that the asterisk isn't special. You do this by placing a backslash just before it, like so:

    \*

    Or you enclose it in double backquotes (inline literals) , like so:

    Lists

    Lists ofitems come in three main flavors: enumerated, bulleted, and definitions. In all list cases, you may have as many paragraphs, sublists, and so on, as you want, as long as the left side of the paragraph aligns with the first line of text in the list item. Lists must always start a new paragraph-that is, they must appear after a blank line. Start a line with a number or letter followed by aperiod (.), surrounded by a right bracket 0), or surrounded by brackets (( ) )-whatever you're comfortable with. All the forms in Listing A-l are recognized.

    490 Key Canfiguratians and Same APIs

    Listing A-l. Example Points

    1. numbers

    A. upper-case letters and it goes over many lines

    with two paragraphs and all! a. lower-case letters

    3. with a sub-list starting at a different number 4. make sure the numbers are in the correct sequence though!

    I. upper-case roman numerals i. lower-case roman numerals

    (1) numbers again

    1) and again

    ListingA-2 shows the results (note that the different enumerated list styles aren't always supported by every Web browser, so you may not get the full effect here).

    ListingA-2. Example List

    <01 class="arabic simple">

  • numbers
  • <101> <01 class="upperalpha">
  • upper-case letters and it goes over many lines

    with two paragraphs and all!

  • <101> <01 class="loweralpha simple">
  • lower-case letters
    1. with a sub-list starting at a different number
    2. make sure the numbers are in the correct sequence though!
    3. 491 AppendixA

      <101> <101> <01 class="upperroman simple">

    4. upper-case roman numerals
    5. <101> <01 class="lowerroman simple">
    6. lower-case roman numerals
    7. <101> <01 class="arabic simple">
    8. numbers again
    9. <101> <01 class="last arabic simple">
    10. and again
    11. <101>

      Just like enumerated lists, start the line with a buHet point character, either -, +, or *, like so:

      * a bullet point using "*11

      - a sub-list using "-"

      + yet another sub-list

      - another item

      That code results in the foHowing:

      • a bullet point using "j*"j
        • a sub-list using "j-"j
          • yet another sub-list
          • another item
          • 492 Key Canfiguratians and Same APIs

            Unlike the other two, the definition lists consist of a term and the definition of that term. The format of a definition list is as follows:

            what Definition lists associate a term with adefinition.

            *how* The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition.

            That code results in the following:

            • a bullet point using "*"
              • a sub-list using "-"
                • yet another sub-list
                • another item
                • Preformatting (Code Samples)

                  To just include achunk ofpreformatted, never-to-be-fiddled-with text, finish the prior paragraph with : :. The preformaued block is finished when the text falls back to the same indentation level as a paragraph prior to the preformatted block. For example:

                  An example::

                  Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. Lookie here, I've dropped an indentation level (but not far enough)

                  no more example

                  493 AppendixA

                  That code results in the following:

                  An example:

                   Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. Lookie here, l've dropped an indentation level (but not far enough) 

                  no more example

                  Note that if a paragraph consists only of : :, then it's removed from the output, like so:

                  This is preformatted text, and the last "::" paragraph is removed

                  That code results in the following:

                  This is preformatted text, and thelast" "paragraph is removed

                  Sections

                  To break longer text up into sections, you use section headers. These are a single line oftext (one or more words) with adornment: an underline alone, or an underline and an overline together, in dashes -----, equals ======, tildes ------, or any of the nonalphanumeric characters that you feel comfortable with:

                  ..... I " ""' 1\ * + # < >

                  An underline-only adornment is distinct from an overline-and-underline adornment using the same character. The underlinel overline must be at least as long as the title text. Be consistent, since all sections marked with the same adornment style are deemed to be at the same level, like so:

                  494 Key Canfiguratians and Same APIs

                  Chapter 1 Title

                  Section 1.1 Title

                  Subsection 1.1.1 Title

                  Section 1.2 Title

                  Chapter 2 Title

                  This results in the following structure, illustrated by simplified pseudo-XML:

                  ditle> Chapter 1 Title ditle> Section 1.1 Title Subsection 1.1.1 Title <seetion> <title> Section 1.2 Title <seetion> ditle> Chapter 2 Title </p><p>Pseudo-XML uses indentation for nesting and has no end tags. It's not possible to show actual processed output, as in the other examples, because sections can't exist inside block quotes. For a concrete example, compare the section structure of this document's source text at http://docutils.sourceforge.net/docslrst/ quickstart . html to the processed output. Note that section headers are available as link targets, just using their name. To link to the Lists_ heading, you write Lists_ . Ifthe heading has aspace in it such as text sty les _' you need to quote the heading like so: 'text sty les'_. </p><p>495 AppendixA </p><p>To indicate the document title, use a unique adornment style at the beginning of the document. To indicate the document subtitle, use another unique adornment style immediately after the document title. For example: </p><p>Document Ti tle </p><p>Subtitle </p><p>Section Title </p><p>Note that Document Title and Section Title both use equals signs but are distinct and unrelated styles. The text of overline-and-underlined titles (but not underlined-only) may be inset for aesthetics. </p><p>Images </p><p>To include an image in YOUf document, you use the ' , image" directive, like so: For example, the following code: </p><p> image:: images/biohazard.png </p><p> results in this: </p><p> image:: images/biohazard.png </p><p>The images/biohazard. png part indicates the filename ofthe image you want to appear in the document. There's no restriction placed on the image (format, size, and so on). Ifthe image is to appear in HTML and you want to supply addi­ tional information, you may do the following: </p><p> image:: images/biohazard.png :height: 100 :width: 200 :scale: 50 :alt: alternate text </p><p>496 Key Canfiguratians and Same APIs </p><p>Miscellaneous </p><p>The following are some tips that may be useful to Plone developers. </p><p>All the Global Defines in the Main Template </p><p>Table A-2lists the global defines in the main template, the code that defines them, and a description. As ever, this list is flexible and may change, so I recommend looking at the source. This is taken from CMFPlone/skins/main _template/ global_defines.pt. These definitions are used mostly in page templates and are useful shortcuts. For example: </p><p><a href="" tal:attributes="portal_url">Url to the portal</a> </p><p>Table A-2. Global Defines in the Main Template Name Code Description utool nocall:here/portal_urlj The portal_url tool portal utool/getPortalObjectj The actual portal object portal_object nocall: portalj Another name for portal portal_url utoolj Another name of the porta 1_ ur 1 tool mtool nocall:portal/portal_membershipj The portal membership tool gtool nocall:portal/portal_groups The portal groups taol, if present nothingj dtool nocall:portal/portal_groupdata The portal groups data taol, if nothingj present atool nocall:portal/portal_actionsj The portal actions tool aitool nocall:portal/portal_actionicons The portal action icons tool I nothingj putils nocall:portal/plone_utilsj The portal utils tool wtool nocall:portal/portal_workflowj The portal workflow tool ifacetool nocall:portal/plone_interface The portal interface taol, if present nothingj portal_title portal_object/Titlej The tide of the portal </p><p>497 AppendixA </p><p>Table A -2. Global Defines in the Main Template (Continued) Name Code Description here/Title; The title of the current object member mtool/getAuthenticatedMember; The current member checkPermission nocall:mtool/checkPermission; The check permission function of the membership tool membersfolder mtool/getMembersFolder; The Members folder the current member, if present isAnon mtool/isAnonymousUser; Boolean if the user is anonymous actions python: The actions for the current location portal.portal_actions.listFiltere dActionsFor(here); keyed_actions python: portal. keyFil teredActions The list of all actions that have IDs (actions); user actions actions/user; Actions for the user workflow actions actions/workflow; Workflow actions folder actions actions/folder; Folder actions global_actions actions/global; Global actions portal_tabs actions/portal_tabslnothing; Portal tabs actions wf state python :wtool. getInfoFor(here, 'rev The workflow state of the current iew _state ' ,None) ; object portal_properties portal/portal_properties; The portal properties object site_properties portal_properties/ The site properties object site_properties; ztu modules/ZTUtils; The ZTUtils module, a useful module with some utilities actions options/actionslactions; The actions passed through to the template explicitly wf actions workflow_actions; Another name for workflow actions isFolder python:here.getTypeInfo(). Boolean if the context is a folder getId() in site_properties. use_folder_tabs; template_id options/template_id I template/ The ID of the current template getId I nothing; </p><p>498 Key Canfiguratians and Same APIs </p><p>Table A-2. Global Defines in the Main Template (Continued) Name Code Description slots_mapping options/slots_mappinglhere/ The slots mapping prepare_slotsI nothing; Iterator python:modules['Products. An iterator, for use in templates CMFPlone'].Indexlterator; tabindex python:lterator(pos=30000); The tab index iterator for forms here url here/absolute_url; Current absolute url 51 slots_mapping/left; Left slots mapping sr slots_mapping/right; Right slots mapping default_language site_properties/ The default language from site default_languagelnothing; properties allowed_types here/getAllowedTypes; Allowed content types into this folder is editable python:here.showEditableBor- Ifthe current object is editable and der(template_id=template_id, should have the green border allowed_types=allowed_types, actions=actions ); </p><p>DateTime API </p><p>I've used DateTime objects throughout the book and haven't explained their API. These objects are used a great deal in Plone. So me common operations include searching on dates or displaying dates. To create a DateTime, pass astring that can be interpreted as a date: </p><p>»> from DateTime import DateTime »> d = DateTime('2004/12/01') »> d.month() 12 </p><p>You can then perform operations on the dates. For example, to subtract two dates, you use the following: </p><p>»> x = DateTime('2004/11/02') »> z = DateTime('2004/11/30') »> z - x 28.0 </p><p>499 AppendixA </p><p>This section contains an abbreviatedAPI; you can find the full notes in the DateTime directory in your Zope installation. DateTime objects represent instances in time and provide interfaces for con­ trolling its representation without affecting the absolute value of the object. You can create DateTime objects from a wide variety of string or numeric data, or you can compute them from other DateTime objects. DateTimes support the ability to convert their representations to many major time zones, as well as to create a DateTime object in the context of a given time zone. DateTime objects provide partial numerical behavior: </p><p>• Two DateTime objects can be subtracted to obtain a time, in days between thetwo. </p><p>• A date DateTime object and a positive or negative number may be added to obtain a new DateTime object that's the given number of days later than the input DateTime object. </p><p>• A positive or negative number and a DateTime object may be added to obtain a new DateTime object that's the given number of days later than the input DateTime object. </p><p>• A positive or negative number may be subtracted from a DateTime object to obtain a new DateTime object that's the given number of days earlier than the input DateTime object. </p><p>You can convert DateTime objects to integer, long, or float numbers of days since January 1,1901, using the standard int, lang, and flaat functions. (Note that int, lang, and flaat return the number of days since 1901 in Greenwich mean time rather than local machine time zone.) DateTime objects also provide access to theirvalue in a float format usable with the Python time module, provided that the value ofthe object falls in the range ofthe epoch-based time module. A DateTime object should be considered immutable; all conversion and numeric operations return a new DateTime object rather than modify the current object. To create a DateTime object, pass in astring that's recognizable as a valid date. Ityou create a DateTime object, the current time will be used. A DateTime object always maintains its value as an absolute UTe time and is represented in the context of so me time zone based on the arguments used to create the object. A DateTime object's methods return values based on the time zone context. Table A-3 describes all the methods that can be called on a DateTime object. </p><p>500 Key Canfiguratians and Same APIs </p><p>TableA-3. Available Methods on a DateTime Object Method Description aMonthO Returns the abbreviated month name. pCommon() Returns astring representing the object's value in the format Mar. 1, 1997 1:45 pm. minuteO Returns the minute. isLeapYearO Returns true if the current year (in the context of the object's time zone) is a leap year. pMonth() Returns the abreviated (with period) month name. DayOfWeekO Compatibility: see Day (). Compatibility: see pDay (). isCurrentDay() Returns true ifthis object represents a date/time that falls within the current day, in the context ofthis object's time zone representation. </p><p>Mon() Compatibility: see aMonth (). hourO Returns the 24-hour dock representation of the hour. DateO Returns the date string for the object. aCommonZO Returns astring representing the object's value in the format Mar 1, 1997 1:45 pm US/Eastern. fCommonZO Returns astring representing the object's value in the format March 1, 1997 1:45 pm US/Eastern. isCurrentYearO Returns true if this object represents a date/time that falls within the current year, in the context of this object's time zone representation. </p><p>AMPMMinutes() Returns the time string for an object not showing seconds. ddO Returns day as a two-digit string. TimeMinutes() Returns the time string for an object not showing seconds. </p><p>Returns the 24-hour dock representation of the hour. isPastO Returns true if this object represents a date/time earlier than the time of the call. dowO Returns the integer day of the week, where Sunday is o. isFutureO Returns true if this object represents a date/time later than the time of the call. </p><p>501 AppendixA </p><p>Table A -3. Available Methods on a DateTime Object (Continued) Method Description pCommonZ() Returns astring representing the object's value in the format Mar. 1, 1997 1:45 pm US/Eastern. timezone() Returns the time zone in which the object is represented. </p><p>Returns the 12-hour dock representation ofthe hour. </p><p>PreciseTime() Returns the time string for the object. isCurrentMinute() Returns true if this object represents a date/time that falls within the current minute, in the context of this object's timezone representation. rfc822() Returns the date in RFC 822 format. equalTo(t) Compares this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true if the object represents a date/time equal to the specified DateTime or time module-style time. yy() Returns calendar year as a two-digit string. mm() Returns month as a two-digit string. Compatibility: see pMonth (). toZone(z) Returns a DateTime with the value as the current object, represented in the indicated time zone. ear liestTime () Returns a new DateTime object that represents the earliest possible time (in whole seconds) that still falls within the current object's day in the object's time zone context. aDay() Returns the abbreviated name of the day of the week. dayOfYear() Returns the day of the year, in context of the time zone representation ofthe object. latestTime() Returns a new DateTime object that represents the latest possible time (in whole seconds) that still falls within the current object's day in the object's time zone context. notEqualTo(t) Compares this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true if the object represents a date/time not equal to the specified DateTime or time module-style time. </p><p>PreciseAMPM() Returns the time string for the object. </p><p>502 Key Canfiguratians and Same APIs </p><p>Table A-3. Available Methods on a DateTime Object (Continued) Method Description dayO Returns the integer day. timeTimeO Returns the date/time as a floating-point number in UTC, in the format used by the Python time module. Note that it's possible to create date !time values with DateTime that have no meaningful value to the time module, and in such cases a DateTimeError is raised. A DateTime object's value must generally be between Jan 1, 1970 (or your local machine epoch) and Jan 2038 to produce a valid time. time 0 style value. ampmO Returns the appropriate time modifier (a.m. or p.m.). greaterThan(t) Compares this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true ifthe object represents a date/time greater than the specified DateTime or time module-style time. monthO Returns the month of the object as an integer. </p><p>AMPMO Returns the time string for an object to the nearest second. second() Returns the second. partsO Returns a tuple containing the calendar year, month, day, hour, minute, second, and time zone ofthe object. greaterThanEqualTo(t) Compare this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true ifthe object represents a date/time greater than or equal to the specified DateTime or time module-style time. lessThanEqualTo(t) Compares this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true ifthe object represents a date/time less than or equal to the specified DateTime or time module-style time. isCurrentHourO Returns true if this object represents a date/time that falls within the current hour, in the context of this object's time zone representation. aCommonO Returns astring representing the object's value in the format Mar 1, 19971:45 pm. </p><p>Returns the integer day of the week, where Sunday is 1, as opposed to the dow method. </p><p>DayO Returns the full name of the day of the week. </p><p>503 AppendixA </p><p>Table A -3. Available Methods on a DateTime Object (Continued) Method Description fCommonO Returns astring representing the object's value in the format March 1, 1997 1:45 pm. Month() Returns the full month name. isCurrentMonth() Returns true ifthis object represents a date/time that falls within the current month, in the context ofthis object's time zone representation. yearO Returns the calendaryear ofthe object. lessThan(t) Compares this DateTime object to another DateTime object or a floating-point number such as that's returned by the Python time module. Returns true ifthe object represents a date/time less than the specified DateTime or time module-style time. </p><p>TimeO Returns the time string for an object to the nearest second. pDayO Returns the abbreviated (with periodl name ofthe day ofthe week. </p><p>Table A-4 describes all the buHt-in methods that DateTime supports. </p><p>Table A -4. Python Built-In Methods for DateTime Objects Method Description 'aDateTime' Converts a DateTime to astring that looks like a Python expression str(aDateTime) Converts a DateTime to astring cmp(aDateTime, other) Compares a DateTime with another DateTime object or a float such as those returned by time. time () hash(aDateTime) Computes a hash value for a DateTime object </p><p>Iable A-5 describes the generic services that DateTime supports. </p><p>504 Key Canfiguratians and Same APIs </p><p>Table A-5. Generic DateTime Functions Method Description aDateTime + other A DateTime may be added to a number, and a number may be added to a DateTime; two DateTime objects can't be added. aDateTime - other Either a DateTime or a number may be subtracted from a DateTime; however, a DateTime may not be subtracted from a number. other + aDateTime Add aDateTime to other. A DateTime may be added to a number, and a number may be added to a DateTime; two DateTimes can't be added. int(aDateTime) Converts to an integer number of days since Jan. 1, 1901 (GMT). long(aDateTime) Converts to a long int number of days since Jan. 1, 1901 (GMT). f1oat(aDateTime) Converts to floating-point number of days since Jan. 1, 1901 (GMT). </p><p>Writing Workflows in Python </p><p>This section covers the API for writing a workflow in Python so that you don't need to develop through the Web. The following sections contain an abbreviated list ofthe methods you'll need to create a workflow. For an exhaustive list, you'll need to read the source, available in the Products/DCWorkflow directory ofyour Plone instance. Writing a workflow stars by creating adefinition. This is importable from here: from Products.DCWorkf1ow.DCWorkf1ow import DCWorkflowDefinition </p><p>Create a new instance ofthis definition and give it an ID: wf = DCWorkflowDefinition(id) </p><p>You now have a workflow you can start manipulating. In the following, wf is the workflow definition I just created. </p><p>505 AppendixA </p><p>States </p><p>The following are the methods for states: </p><p>• addState(ld): This adds astate of a given ID. You must add states prior to being able to manipulate them. </p><p>• setInitiaIState(ld): This sets the initial state for this workflow. </p><p>• setProperties([key=value, ... ]): This is aseries ofkey/value pairs that map to properties for astate. For example, to set the transitions to be new and reject, use setproperties (transi tions= ( , publish " 'rej ect ' ) ). </p><p>• setPermission(permission name, acquire, (role, [role... ])): This is the per­ mission name, if acquire is enabled or not (a boolean value) and then a tuple of all the roles to which this applies. </p><p>To access these methods, use the states object inside the workflow object. For example, use wf. states. addState(' new'). </p><p>Transitions </p><p>The following are the methods for transitions: </p><p>• addTransition(id): This adds astate of a given ID. You must add transitions prior to being able to manipulate them. </p><p>• setProperties([key=value, ... ]): This is aseries ofkey/value pairs that map to properties for astate. </p><p>To access these methods, use the transitions object inside the workflow object. For example, use wf. transi tions. addTransition ( 'reject' ). </p><p>506 Key Canfiguratians and Same APIs </p><p>Variables </p><p>The following are the methods for variables: </p><p>• addVariable(id): This adds a variable of a given ID. You must add variables prior to being able to manipulate them. </p><p>• setStateVar(id): This sets the state variable name, which is usually review state. </p><p>• setProperties([key=value, ... ]): This is aseries ofkey/value pairs that map to properties for a variable. </p><p>To access these methods, use the variables object inside the workflow object. For example, use wf . transitions. addVariable ( , action' ). </p><p>Ofhers </p><p>Worklists perform in the same mann er as the transitions, variables, and states. To add a worklist, call addWorklist. One other useful method is to add permissions to the list of managed permissions for the workflow. The addManagedPermission(permission name) method achieves this. </p><p>507 APPENDIX B Code Listings </p><p>THIS APPENDIX LISTS the code used in the rest of the book. Some of these scripts that are run externally require that you have the Zope/lib/python directory in your Python path, as described in Appendix A. All these scripts are described in detail in the book. </p><p>Chapter 5 </p><p>The following are the code listings for Chapter 5. </p><p>Page Template: test_context </p><p>Listing B-l shows all the variables that are available in page templates. It's useful to show information for debugging. </p><p>Listing B-l. test _ context </p><p><html> <head I> <body> <hl>Debug information</hl> <h2>CONTEXTS</h2> <ul> <tal:block tal:repeat="item CONTEXTS"> <li tal:condition="python: item != 'request'" tal:define="context CONTEXTS;"> <b tal:content="item" I> <span tal:replace="python: context[item]" I> </li> </tal:block> </ul> <h2>REQUEST</h2> <p tal:replace="structure request" I> </body> </html> </p><p>509 AppendixB </p><p>Page Template: user_info (1) </p><p> user_info (1) is a emde page template that isn't in the Plone style and that shows user information, as shown in Listing B-2. To user this template, you'll have to pass the user ID you want to examine in the query string. For example, use user_info ?userName=andy. </p><p>ListingB-2. user_info (1) </p><p><html> </p><p><body> <div tal:omit-tag="" tal:define=" userName request/userNamelnothing; userObj python: here.portal_membership.getMemberByld(userName); getPortrait nocall: here/portal_membership/getPersonalPortrait; getFolder nocall: here/portal_membership/getHomeFolder "> <p tal:condition="not: userName"> No username selected. </p> <p tal:condition="not: userObj"> That username does not exist. </p> </p><p><table tal:condition="userObj"> <tI> <td> </td> <td> <ul> <1i> <i>Username:</i> <span tal:replace="userName" I> </li> <1i> <i>Full name:</i> <span tal:replace="userObj/fullname" I> </li> </p><p>510 Code Listings </p><p><li tal:define="home python: getFolder(userName)" tal:condition="home"> <i>Home folder:</i> <a href="" tal:attributes="href home/absolute url" tal:content="home/absolute url">Folder</a> </li> <li> <i>Email:</i> <a href="" tal:define="email userObj/email" tal:attributes="href string:mailto:$email" tal:content="email">Email</a> </li> <li> <i>Last login time:</i> <span tal:replace="userObj/last_login_time" I> </li> <lu!> </td> </tr> </table> </p><p></div> </body> </htm!> </p><p>Chapter 6 </p><p>The following are the code listings for Chapter 6. </p><p>Page Template: user_info (2) </p><p>Listing B-3 shows a refined version of the user info page template from Chapter 5. You don't need to pass the userName because it's just going to loop through every member in the site for you. </p><p>511 AppendixB </p><p>ListingB-3. user_info (1) </p><p><html xmlns=''http://www.w3.org/1999/xhtml'' xml:lang="en-US" lang="en-US" i18n:domain="plone" metal:use-macro="here/main_template/macros/master"> </p><p><body> <div metal:fill-slot="main"> <tal:block tal:define=" getPortrait nocall: here/portal_membership/getPersonalPortraitj getFolder nocall: here/portal_membership/getHomeFolder "> <table> <tal:block tal:repeat="userObj here/portal_membership/listMembers"> <metal:block metal:use-macro="here/user section/macros/userSection" /> </tal:block> </table> </tal:block> </div> </body> </html> </p><p>Page Template: user_section </p><p>Listing B-4 shows a page template macro that accompanies the user_info page template previously and shows the individual users information for each invocation. </p><p>Listing B-4. user _ section </p><p><div metal:define-macro="userSection" tal:define="userName userObj/getUserName"> <tI> <td> </td> </p><p>512 Code Listings </p><p><td tal:define="prop nocall: userObj/getProperty"> <u!> <1 i> <i>Username:</i> <span tal:replace="userName" I> </li> <1 i> <i>Full name:</i> <span tal:replace="python: prop('fullname')" I> </li> <1i tal:define="home python: getFolder(userName)" tal:condition="home"> <a href="" tal:attributes="href home/absolute url">Home Folder</a> </li> <1i> <i>Email: <li> <a href="" tal:define="email python: prop('email')" tal:attributes="href string:mailto:$email" tal:content="email">Email</a> </li> <1 i> <i>Last login time:</i> <span tal:replace="python: prop('last_login_time')" I> </li> <lu!> </td> </tr> </div> </p><p>Script (Python): google_od_portlet </p><p>Listing B-5 shows a page template that provides Google ads in a slot. </p><p>513 AppendixB </p><p>Listing B-5. google _ ad _portlet </p><p><div metal:define-macro="portlet"> <div class="portlet"> <script type="text/javascript"><!-­ google_ad_client = "yourUniqueValue"; google_ad_width = 120; google_ad_height = 600; google_ad_format = "120x600_as"; //--></script> <script type="text/javascript" src="http://pagead2.goog1esyndication.com/pagead/show_ads.js"> </script> </div> </div> </p><p>Script (Python): recentlyChanged </p><p>Listing B-6 shows a script that examines all objects passed to the script and then finds out what's new. The objects need to be passed in using the object's parameter. </p><p>Listing B-6. google _ad _portlet </p><p>##title=recentlyChanged ##parameters=objects from DateTime import DateTime </p><p> now = DateTime() difference = 5 # as in 5 days result = [] </p><p> for object in objects: diff = now - object.bobobase_modification_time() if diff < difference: dct = {"object":object,"diff":int(diff)} result.append(dct) </p><p> return result </p><p>External Method: readFile </p><p>Listing B-7 shows a sampie external method that reads a file. </p><p>514 Code Listings </p><p>Listing B-7. readFile def readFile(self): fh = open(r'c:\Program Files\Plone\Data\Extensions\README.txt', 'rb') data = fh.read() return data </p><p>Python Script: zpt.py </p><p>Listing B-8 shows a script totally external to and independent ofPlone that will syntax check a page template. This is useful for when you're debugging page templates written outside ofPlone. </p><p>Listing B-B. zpt. py </p><p>#!/usr/bin/python from Products.PageTemplates.PageTemplate import PageTemplate import sys def test(file): raw_data = open(file, 'r').read() pt = PageTemplate() pt.write(raw_data) if pt._v_errors: print "*** Error in:", file for error in pt._v_errors[l:]: print error if name main if len(sys.argv) < 2: print "python check.py file [files ... ]" sys.exit(l) else: for arg in sys.argv[l:]: test(arg) </p><p>Page Template: feedbackForm </p><p>Listing B-9 shows the form for users to enter feedback. </p><p>515 AppendixB </p><p>Listing B-9. feedbackForm </p><p><html xmlns=''http://www.w3.org/1999/xhtml'' xml:lang="en-US" lang="en-US" i18n:domain="plone" metal:use-macro="here/main_template/macros/master"> <body> <div metal:fill-slot="main" tal:define="errors options/state/getErrors;"> <p>Please send us any feedback you might have about the site. </p> <form method="post" tal:attributes="action template/id;"> dieldset> <legend class="legend" i18n:translate="legend_feedback_form">Website Feedback</legend> <div class="field" tal:define="error email address errors/email_addresslnothing;" tal:attributes="class python:test(error_email_address, 'field error', 'field') "> </p><p><label i18n:translate="label email address">Your email address</label> <span class="fieldRequired" title="Required" i18n:attributes="title" i18n:translate="label_required">(Required)</span> <div class="formHelp" 118n:translate="label_email_address_help">Enter your email address.</div> <div tal:condition="error email address"> <tal:block i18n:translate="" content="error email address">Error</tal:block> </div> <input type="text" name="email_address" tal:attributes="tabindex tabindex/next; value request/email_addresslnothing" I> </div> </p><p>516 Code Listings </p><p><div class="field"> <label i18n:translate="label feedback comments"> Comments</label> <div class="formHelp" id="label_feedback_comments_help" i18n:translate="label_feedback_comments_help">Enter the comments you have about the site.</div> <textarea name="comments" rows="10" tal:content="request/commentsI nothing" tal:attributes="tabindex tabindex/next;" I> </div> <div class="formControls"> <input class="context" type="submit" tabindex="" name="form.button.Submit" value="Submit" i18n:attributes="value" tal:attributes="tabindex tabindex/next;" I> </div> </fieldset> <input type="hidden" name="form.submitted" value="l" I> </form> </div> </body> </html> </p><p>Controller Python Script: sendEmail </p><p>Listing B-lO shows the controlled script to actually send the e-mail to the user. </p><p>Listing B-lO. send Email mhost = context.MailHost emailAddress = context.REQUEST.get('emai1_address') administratorEmai1Address = context.emai1 from address comments = context.REQUEST.get('comments') </p><p># the message format, %s will be filled in from data message = From: %s Ta: %s Subject: Website Feedback </p><p>517 AppendixB </p><p>%s </p><p>URL: %s </p><p># format the message message = message % ( emailAddress, administratorEmailAddress, comments, context.absolute_url()) </p><p> mhost.send(message) </p><p> screenMsg = "Comments sent, thank you." state.setKwargs( {'portal_status_message' :screenMsg} return state </p><p>Controller Python Script: validEmail </p><p>Listing B-ll shows the script to validate the e-mail. </p><p>Listing B-ll. validEmail </p><p> email = context.REQUEST.get('email_address', None) </p><p> if not email: state.setError("email_address', 'An email address is required', new_status='failure') </p><p> if state.getErrors(): state.set(portal_status_message='Please correct the errors shown. ') </p><p> return state </p><p>Chapter 7 </p><p>The following are the code listings for Chapter 7. </p><p>518 Code Listings 5cript (Python): set5kin </p><p>If assigned as an access rule in your Plone site, the script in Listing B-12 will change all requests to internal. somesite.org to use the skin Plone Default. Ifnot, the Custom Chrome skin will be used. </p><p>Listing B-12. setSkin </p><p>##title=Skin changing script ##parameters= req = context.REQUEST if req['SERVER_URL'].find('internal.somesite.org') > -1: context.changeSkin("Plone Default") context.changeSkin("Custom Chrome") </p><p>C55: ploneCustom.css </p><p>Listing B-13 shows the Cascading Style Sheet that powers the NASA Mars site. </p><p>Listing B-13. ploneCustom. css body { background: #343434; } </p><p>#visual-portal-wrapper { width: 680px; margin: lem auto 0 auto; } </p><p>#portal-top { background: ur 1 (" http://mars . telascience. org/header. jpg") .. transparent no-repeat; padding: 162px 0 0 0; position: relative; } </p><p>519 AppendixB </p><p>#portal-logo { background: transparent; background-image: none; margin: 0; position: absolute; top: 130px; left: Spx; z-index: 20; } </p><p>#portal-logo a { padding-top: 2Spx; height /**/: 2Spx; width: 37Spx; } </p><p>#portal-globalnav background: url(''http://mars.telascience.orgllistspacer.gif'') .. transparent; padding: 0; height: 21px; border: 0; margin: 0 0 lpx 6px; clear: both; } </p><p>#portal-globalnav li { display: block; float: left; height: 21px; background: url(''http://mars.telascience.orglliststart.gif'') .. transparent no-repeat; padding: 0 0 0 33px; margin: 0 O.Sem 0 0; } </p><p>#portal-globalnav li a { display: block; float: left; height: 21px; background: url(''http://mars.telascience.orgllistitem.gif'') .. </p><p>520 Code Listings transparent right top; padding: 0 33px 0 0; border: 0; line-height: 2em; color: black; font-size: 90%; margin: 0; } </p><p>#portal-globalnav li a:hover, #portal-globalnav li.selected a { background-color: transparent; border: 0; color: #444; } </p><p>#portal-personaltools { clear: both; margin-left: 6px; border-top-color: #776a44; border-top-style: solid; border-top-width: 1px; } </p><p>#portal-breadcrumbs clear: both; } </p><p>#portal-breadcrumbs, #portal-columns, .documentContent { background: white; margin-left: 6px; } </p><p>.documentContent margin: 0; font-size: 100%; } </p><p>.screenshotThumb float:right; } </p><p>521 AppendixB </p><p>#portal-footer { margin: -lpx 0 0 6px; padding: 0.8em 0; border: 1px solid #ddd; border-style: solid none none none; background: white; color: #666; font-size: 90%; } </p><p>#portal-footer a color: #333; text-decoration: underline; } </p><p> dt { color: #ECA200; } </p><p>.documentDescription { font-size: 110%; } </p><p>#portal-breadcrumbs img display: none; } </p><p> li. reqlist margin-top: 0; margin-bottom: 0; } </p><p>Chapter 8 </p><p>The following are the code listings for Chapter 8. </p><p>Script (Python): mail.py </p><p>Listing B-14 shows a script to send mail to users whenever the object changes in the workflow. </p><p>522 Code Listings </p><p>Listing B-14. mail. py </p><p>##parameters=state_change # the objects we need object = state_change.object mship = context.portal_membership mhost = context.MailHost </p><p># the message format, %s will be filled in from data message = """ From: noreply@yourwebsite.com To: %s Subject: New item submitted for approval - %s </p><p>%s </p><p>URL: %s for user in mship.listMembers(): if "Reviewer" in mship.getMemberByld(user.id).getRoles(): if user. email: msg = message % ( user.email, object.TitleOrld(), object.Description(), object.absolute_url() ) mhost. send (msg) </p><p>Chapter 9 </p><p>The following are the code listings for Chapter 9. </p><p>External Method: importUsers </p><p>Listing B-15 shows an external method to import users fram a . csv file on the file system. </p><p>523 AppendixB </p><p>Listing B-15. importUsers </p><p># An external method to import user import csv </p><p># the full path to your csv file fileName = "/var/zope.zeo/Extensions/test.csv" </p><p> def importUsers(self): reader = csv.reader(open(fileName, "rn)) pr = self.portal_registration pg = self.portal_groups out = [] </p><p># if your csv file contains a header line that # explains the contents of each column ignoreLine = 1 for row in reader: if ignoreLine: ignoreLine 0 continue </p><p># check we have exactly 4 items assert len(row) == 4 id, name, email, groups = row groups groups.split(', ') </p><p># make a password password = pr.generatePassword() try: # add in member pr.addMember(id = id, password = passward, roles = ["Member",], properties = { 'fullname': name, , username ': id, 'email': email, </p><p>524 Code Listings </p><p># groups are separated by commas for groupId in groups: group = pg.getGroupByld(groupld) group.addMember(id) </p><p> out.append("Added user %5" % id) </p><p> except ValueError, msg: # if we skipped this user for a reason, tell the person out.append("Skipped %5, reason: %5" % (id, msg)) </p><p># return something return "\n".join(out) </p><p>External Method: fixUsers </p><p>Listing B-16 shows a script that sets the properties for all users to Epoz. </p><p>Listing B-16. fixUsers def fixUsers(self): pm = self.portal_membership members = pm.listMemberlds() </p><p> out = [] for member in members: # now get the actual member m = pm.getMemberByld(member) # get the editor property for that member p = m.getProperty('wysiwyg_editor', None) </p><p> out.append("%s %5" % (p, member)) if p is not None and p!= 'Epoz': m.setMemberProperties({'wysiwyg_editor': 'Epoz' ,}) out.append("Changed property for %5" % member) return "\n".join(out) </p><p>External Method: getGroups </p><p>Listing B-17 shows a script that first gets the creator of the object. Then it gets all the users in same group as that creator. </p><p>525 AppendixB </p><p>Listing B-17. getGroups </p><p>##parameters=object=None # object is the object to find all the members of the same group for users = [l # get the creator userName = object.Creator() user = context.portal_membership.getMemberByld(userName) pg = context.portal_groups </p><p># loop through the groups the user is in for group in user.getGroups(): group = pg.getGroupByld(group) </p><p># loop through the users in each of those groups for user in group.getGroupUsers(): if user not in users and user != userName: users.append(user) </p><p> return users </p><p>Chapter 11 </p><p>The following are the code listings for Chapter 11. </p><p>Script (Python): scriptObjectCreation </p><p>Listing B-18 shows a script to create a folder and then a document inside it. </p><p>Listing B-18. scriptObj ectCreation </p><p>##title=Create ##parameters= # create with a random id newld = context.generateUniqueId('Folder') </p><p># create a object of type Folder context.invokeFactory(id=newld, type_name='Folder') newFolder = getattr(context, newId) </p><p># create a new Document type newFolder.invokeFactory(id='index.html', type_name='Document') </p><p>526 Code Listings </p><p># get the new page newPage = getattr(newFolder, 'index.html') newPage.edit('html', '<p>This is the default page.</p>') </p><p># return something back to the calling script return "Done" </p><p>Page Template: getCatalogResults </p><p>Listing B-19 shows a sampie catalog query that takes the REQUEST parameters and runs a query on them. </p><p>Listing B-19. getCatalogResul ts </p><p>##title=Get Catalog Results ##parameters= return context.portal_catalog.searchResults(REQUEST=context.REQUEST) </p><p>Page Template: testResults </p><p>Listing B-20 shows a sampie results from a catalog query. </p><p>Listing B-20. testResul ts </p><p><html xmlns=''http://www.w3.org/1999/xhtml'' xml:lang="en-US" lang="en-US" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <div metal:fill-slot="main"> <ul tal:define="results here/getCatalogResults"> <li tal:repeat="result results"> <a href="" tal:attributes="href result/getURL" tal:content="result/Title" I> <span tal:replace="result/Description" I> </li> </ul> </div> </body> </html> </p><p>527 AppendixB Page Template: testForm </p><p>Listing B-21 shows a sampIe form to caH the testResul ts page with a drop-down list based on a catalog query. </p><p>Listing B-21. testForm </p><p><html xmlns=''http://www.w3.org/1999/xhtml'' xml:lang="en-US" lang="en-US" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <div metal:fill-slot="main"> <p>Select a content type to search for</p> <form method="post" action="testResults"> <select name="Type"> <option tal:repeat="value python:here.portal_catalog.uniqueValuesFor('Type')" tal:content="value" I> </selecb <br I> <input type="submit" class="context"> </form> </div> </body> </html> </p><p>Chapter 12 </p><p>The foHowing relate to Chapter 12. </p><p>Example Product: PloneSilverCity </p><p>You can find this product in the CoHective at http://sf . netlprojects/collective. You can also download this product from the Plone book Web site at http://plone-book.agmweb.ca. </p><p>528 Code Listings Example Product: PloneStats </p><p>You can find this product in the Collective at http://sf . netlprojects/collective. You can also download this product from the Plone book Web site at http://plone-book.agmweb.ca. </p><p>Chapter 13 </p><p>The following relate to Chapter 13. </p><p>Example Product: ArchExample </p><p>This product is in the Archetypes release, and you can download a copy from the Plone book Web site at http://plone-book. agmweb. ca. </p><p>Page Template: email_widget.py </p><p>Listing B-22 shows an example custom widget for Archetypes. </p><p>Listing B-22. email_widget.py </p><p><html xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" i18n:domain="plone"> </p><p><body> <div metal:define-macro="edit"> <div metal:use-macro="here/widgets/string/macros/edit" I> </div> </p><p><div metal:define-macro="search"> <div metal:use-macro="here/widgets/string/macros/search" I> </div> </p><p><div class="field" metal:define-macro="view"> ca href="#" tal:attributes="href string:mailto:${accessor}" tal:content="accessor">emailc/a> </div> </p><p></body> </html> </p><p>529 AppendixB Example Product: WordExample </p><p>You can download the product listing for WordExample from the Plone book Web site at http://plone-book . agmweb. ca. </p><p>Python Module: PersonSQL.py </p><p>Listing B-23 shows an Archetypes content type for a person who stores the data in a relational database. </p><p>Listing B-23. PersonSQL. py </p><p> from Products.Archetypes.public import Schema from Products.Archetypes.public import IntegerField, StringField from Products.Archetypes.public import IntegerWidget, StringField from Products.Archetypes.SQLStorage import PostgreSQLStorage from config import PROJECTNAME </p><p> schema = BaseSchema + Schema(( </p><p>IntegerField('age' , validators=("islnt",), storage = SQLStorage(), widget=IntegerWidget(label="Your age"), </p><p>) , </p><p>StringField('email' , validators = ('isEmail' ,), index = "TextIndex", storage = SQLStorage(), widget = StringWidget(label='Email' ,) ) , </p><p>)) </p><p> class PersonSQL(BaseContent): """Our person object""" schema = schema </p><p> registerType(PersonSQL, PROJECTNAME) </p><p>530 Code Listings </p><p>Chapter 14 </p><p>The following are the code listings for Chapter 14. </p><p>Python Module: header.py </p><p>Listing B-24 shows a script that'll print the headers for a URL. </p><p>Listing B-24. header. py </p><p>#!/usr/bin/python import sys from http1ib import HTTP from urlparse import urlparse def getHeaders(url, method): p = list(urlparse(url)) if not p[o]: url = 'http://' + url p = list(urlparse(url)) </p><p> h = HTTP(p[l]) </p><p> h.putrequest(method, p[2]) h.putheader('Accept-Encoding', gzip, deflate') h.endheaders() </p><p> reply = h.getreply() print "Status:", reply[o] print "Status message:", reply[l] hdrs = reply[2].headers hdrs. sort 0 for header in hdrs: print header[:-l] def usage 0 : print """Usage: headers.py URL [method] </p><p>URL - the URL to get headers for, http:// default method - GET default </p><p> sys.exitO </p><p>531 AppendixB </p><p> if name main if len(sys.argv) < 2: usage() method = 'GEI' if len(sys.argv) > 2: method = sys.argv[2] getHeaders(sys.argv[l], method) </p><p>Script (Python): myCachingRules </p><p>Listing B-25 provides a custom caching rule for a policy manager, just to give you more options. </p><p>Listing B-25. myCachingRules </p><p>##parameters=content # cache all files, images and anything # that is published if content.portal_type in ['File', 'Image']: return 1 if content.review state == ['published' ,]: return 1 </p><p>External Method: Purge Cache </p><p>Listing B-26 shows an exampie script to purge a cache. </p><p>Listing B-26. Purge Cache </p><p> import urllib import urlparse import httplib </p><p>URLs = [ # enter the URLs you would like # to purge here 'http://localhost:8080', </p><p>532 Code Listings def purge(objectURL): for url in URLs: if not url: continue assert url[:4] == 'http', "No protocol specified" </p><p> url = urlparse.urljoin(url, objectURL) parsed = urlparse.urlparse(url) host parsed [1] path = parsed[2] </p><p> h = httplib.HTTP(host) h.putrequest('PURGE', path) h.endheaders() errcode, errmsg, headers = h.getreply() h.getfile.read() i f name main print purge('/') </p><p>533 APPENDIX ( Glossary and Tools </p><p>THIS APPENDIX DESCRIBES all the default tools, objects that are created in a Plone site, and references to their location in the book. The glossary provides a list of all the terms used in this book and Plone. </p><p>Too15 </p><p>Table C-l describes the default tools that Plone creates. </p><p>Table C-l. Plone Tools Tool Name Description Handles caching for content; see Chapter 14. Provides different ways of processing new content; see Chapter 11. General utility functions that aren't usually accessed. portal_actionicons Associates an image to an action. portal_actions The core action provider. portal_calendar Provides the calendar slot and isn't used beyond that; see Chapter 4 for information about the calendar slot. portal_catalog Catalog tool for providing indexes content; see Chapter 11. portal_controlpanel Provides an interface to the actions visible in Plone control panels. portal_discussion Handles discussions of content; see Chapter 4. portal_factory Ensures the default creation of content doesn't leave partially created objects in the database; see Chapter 12. </p><p>535 AppendixC </p><p>Table C-l. Plane Taals (Cantinued) Tool Name Description portal_form Deprecated, maintained for backward compatability. </p><p>Provides form handling services; see Chapter 7. portal_groupdata Stores information about the groups; see Chapter 9. </p><p> portal_groups Handles group creation; see Chapter 9. portal_interface This provides an Application Programming Interface (API) for developers to examine object interfaces. </p><p> portal_memberdata Stores information about the users; see Chapter 9. portal_membership Handles user membership options; see Chapter 10. portal_metadata Metadata about portal content types. This isn't usedmuch. portal_migration Handles the migration to new versions of Plone; see Chapter 14. portal_navigation Deprecated but is maintained for backward compatibility. portal_properties Properties and values for the site; see Chapter 4. </p><p> portal_quickinstaller A utility for quickly installing products; see Chapter 10. </p><p> portal_registration Handles options for registering users; see Chapter 9. </p><p> portal_skins Provides skinning services and contains all the skins; see Chapters 4-7 for more information. portal_syndication Access to RSS feeds for Plone content. (RSS stands for Rich Site Summary or Really Sirnply Syndication.) portal_types Main tool for handling content types within a portal; see Chapters 11-13. Provides access to Plone's undo mechanisms. </p><p>Access to useful APIs for determining Uniform Resource Locators (URLs). portal_workflow Handles and provides workflow capabilities; see Chapter7. </p><p>536 Glossaryand Tools Default Objects </p><p>Table C-2 describes the default objects that Plone creates inside a Plone site. </p><p>Table C-2. Plone Objects Object Description HTTPCache Provides HTTP headers for skins; see Chapter 14. </p><p>MailHost SimpleMail Transfer Protocol (SMTP) server access for sending e-mail. Members A large folder where site members folders are created; see Chapter 9. RAMCache Provides RandomAccess Memory (RAM) caching for skins; see Chapter 14. acl users The main user folde; see Chapter 9. cookie authentication Provides authentication ofusers via cookies; see Chapter9. error_log The log of errors that have occurred in the system; see Chapter 4. index html The default index _ html that appears in the site; see Chapter6. </p><p>Glossary </p><p>Table C-3 defines all the useful terms in the Plone world. </p><p>Table C-3. Plone Definitions Object Description Action In Plone terminology, actions are a configurable way of providing navigational elements in a site. So me examples are view, edit, and members. See Chapter 5 for more details. Acquisition Acquisition is a Zope mechanism for inheriting object properties. Zope object hierarchy is built using acquisition and makes heavy use ofit. </p><p>537 AppendixC </p><p>Table C-3. Plone Definitions (Continued) Object Description </p><p>Anonymous role This is a standard role in the Zope security architecture. The anonymous role is assigned to site visitors until they log in using their Zope ID/password. </p><p>Archetypes This is a framework for the development of new content types in Zope/CMF/Plone; see Chapter 13. </p><p>Authenticated user An authenticated user is a user who is logged into the Zope system. If no user is currently logged in, anonymous users are considered the authenticated user. </p><p>Authentication This is the identification process used by Zope. </p><p>Base dass A base class, or top class, is a dass that passes its methods, properties, and so on, to its subdasses. The subdasses inherit the properties and methods of their base dass. Calendar The portal_calendar allows for a mechanism to administer what content is shown in calendar. </p><p>Catalog The catalog is an internal index of the content inside Plone so that it can be searched. The catalog object is accessible through the ZMI as the portal_catalog object; see Chapter 11. </p><p>CSS Cascading Style Sheets are a system in Hypertext Markup Language (HTML) to aHow styles to be specified for elements. Plone uses a great deal of CSS; for some examples, see Chapter 7. </p><p>Class A class is the mold from which objects are stamped out. Objects are instances of a dass. You can think of a dass as a blueprint for an object. Class constructor method A constructor method for a dass is a method that allows execution of certain actions as soon as a dass instance is created and before it's started to be used. For example, setting the standard attributes would be done in a constructor method. CMF The Content Management Framework (CMF) is a Zope addition to provide services that a content management system needs. </p><p>CMFTypes This is the old name for Archetypes. </p><p>CMS A Content Management System (CMS) is a system to, weH, manage content. </p><p>538 Glossaryand Tools </p><p>Table C-3. Plone Definitions (Continued) Object Description </p><p>Content In the CMF worldview, everything is content. This applies to traditional things such as Hypertext Markup Language (HTML) pages. But it also applies to dynarnic information such as posts in a threaded discussion or calendar events. It also means that images, downloadable executables, logic in scripts, and so on, are also content. </p><p>Content Type Content type is the type of content allowed in a CMF / Plone instance. Plone comes with stock content types, but you can create your own content types specific to your needs and plug them into your Plone instance. </p><p>Cookie authentication cookie_authentication (also known as CookieCrumbler) allows form-based login; see Chapter 9. </p><p>DTML Document Template Markup Language (DTML) is a server-side templating language used to produce dynamie pieces of content. It's primarily used in conjunction with HTML. It's hardly used in Plone and generally is considered deprecated; see page templates. </p><p>Discussions The portal_discussion tool holds the poliey regarding how the discussions work in a Plone system. </p><p>ECMAscript This is essentially JavaScript. </p><p>External method External methods are essentially Python modules sitting on the file systems linked into Zope via the external method object that you can create from the drop-down list. External methods are more powerful than Script (Python) objects because they arent subjected to the Zope security architecture as rigorously as the Script (Python) objects may be. </p><p>Factory Afactory is a tool for creating other objects. Folderish object Afolderish object in Zope is an object that can contain other objects. The Folder and Plone Folder objects are examples of folderish objects. </p><p>Factory Type Information Factory type information contains the information to be loaded (FTI) into the portal_types too1. </p><p>GPL This includes the terms under which Plone is licensed. </p><p>Globbing (ZCatalog) Globbing allows you to search the ZCatalog using wildcards (*). Globbing also enables partial word searches in that ZCatalog. </p><p>539 AppendixC </p><p>Table C-3. Plone Definitions (Continued) Object Description </p><p>HTML Hypertext Markup Language is the basic mark up language for the Web. This book assumes you know what HTML iso </p><p>Instance Objects are also called instanees. An instance or object is an instance of a given dass. il8n Internationalization is preparing a program so that it can be used in multiple languages without further altering the source. The term i18n is formed by the first and last letter of the word and the number of letters in between. </p><p>JavaScript This is the language that's shipped with Web browsers that allow them to make Web pages dynamic. A good example of JavaScript is in the green drop-down menu for adding items. </p><p>Keywords In the Properties tab of content, you can assign keywords (also known as subjeet in metadata terminology). This is a mechanism that allows you to relate content to each other. Keywords can be predefined in the portal_metadata too1. </p><p>Layer A skin in Plone is an enumerated collection of layers. Layers arent currently circumscribed in what they can do. They can change visual aspects of a Plone site, they can surface new content types in a more or less presentation-neutral way, or they can change/ override the behavior specified in other skins. </p><p>Local role Loeal roles are assigned to a particular Zope user with respect to a given Zope object. A local role determines that users' permissions for that 0 bject. A local role may be used to restrict a users' permissions for a given object. You can also use a local role to give users-who may have limited global rights-expanded rights for a small subsets of objects. </p><p>Login This is the process you go through when you enter your username and password on the login screen. This is the same as authentication. nOn Loealization is the actual preparing of data for a particular language. For example, Plone is il8n aware and has localization for severallanguages. The term 11 On is formed by the first and last letter of the word and the number of letters in between. </p><p>Manager This is a standard role in Zope. </p><p>540 Glossaryand Tools </p><p>Table C-3. Plone Definitions (Continued) Object Description Metatype This is a unique string for each Zope product in the Available Objects menu in the Zope Management Interface (ZMI). Product instances are created using this metatype. Each product has a unique metatype. </p><p>Metadata Information about content, see http://www. dublincore. org. </p><p>METAL Macro Expansion Template Attribute Language. </p><p>Memberdata In Plone, portal_memberdata stores the attributes of users. Migration Migration is the mostly automated process through which you upgrade your Plone instance to a new release level. Namespace A namespace contains the names of all valid variables of a given dass instance (an object) in a specific scope. Nonfolderish objects These are objects that can't contain other Zope or Plone objects. For example, these can be documents or files. </p><p>Object An object is an instance of a dass. Object DataBase (ODB) This is a system that stores a heirarchy of instances. The ZODB is an example of an object database. You cant query object databases like you can their relational counterparts. Ownerrole This is the owner standard Zope role. Ownership (of objects) Users who create objects in Zope are given ownerships of those objects. Every object in Zope has an owner except perhaps the ones created by the Zope Install process. OOTB Plone is an example of an out-of-the-box (OOTB) Web application. Permissions Permissions tell you what actions a user can take while in Zope. Permissions can be applied only to roles. You can't give permissions directly to individual users. Portal actions Portal actions affect the whole site, as opposed to the content types actions, which are more localized. Properties Essentially these are the attributes of any given object. You can see a Zope object's properties by dicking the Properties tab in the ZMI when you're viewing that particular object. Properties are also used on objects in the Plone interface to describe properties an object may have, such as keywords. Plone "!fyou don't know by now.... " </p><p>541 AppendixC </p><p>Table C-3. Plone Definitions (Continued) Object Description </p><p>Portal type Portal type is a unique string for each content type in Plone. In Plone each content type will have a unique string to identify it (although they may be based on the same metatype). </p><p>Portlets Portlets are the little sections on a Plone site that manifest themselves as little boxes on the left and right side of a Plone instance. </p><p>Python Python is an object-oriented high-level scripting language. Zope is written in Python. </p><p>QuantumLeap When viewing large result sets in Plone, you'll notice they're presented in pages. You can leap to any of these pages, and the navigation will display nearby pages. This mechanism is affectionately known as QuantumLeap(ing). </p><p>Registration More specifically, portalJegistration controls the sitewide policy for how users register with the system. </p><p>Request Each page view by a dient generates arequest to Plone. This incoming request is encapsulated in arequest object in Zope, usually called REQUEST or request. </p><p>Response For each re quest a response is generated. This outgoing request from Zope is encapsulated in a response object, usually called RESPONSE or response. </p><p>Repurposing Content types can be based on another content types' FT!, which is called repurposing. You can then specify unique metadata attributes for new content type such as id, title, and description. </p><p>Services The goal of the CMF is to unify the management of content and apply a suite of services. These services indude cataloging, workflow, and syndication. CMF and Plone provide many services to your site. There are publidy available services such as search and discussion and management services such as workflow. </p><p>Skin Think of skins as the look and feel of a Plone experience. A skin contains the HTML, CSS, JavaScript, images, and all the interactions between the user and the Plone. You can apply different skins to the same content, meaning a content can be viewed in many different ways. Some skins provide extra features andpages. </p><p>542 Glossaryand Tools </p><p>Table C-3. Plone Definitions (Continued) Object Description </p><p>Syndication Syndication is the process by which a site is able to share information with other sites. Content syndication in the CMF allows you to make content available to other sites. The syndication tool allows site managers to control sitewide syndication of content. Syndicated content is made available in RSS format for folders where syndication has been enabled. </p><p>TAL Tag Attribute Language (TAL) is a method for dynamically marking upHTML. </p><p>TALES TAL Expression Syntax (TALES) is a syntax for extending TAL. </p><p>Tool A tool is an instance of a dass inside the Plone site. However, unlike other objects, there can only ever be one instance of a particular tool inside a Plone site at any one time. Some tools, such as portal_catalog, give administration options for the site manager. </p><p>UI (User Interface) The User Interface (UI) consists ofthe screens and way in which you interact with a software program. </p><p>View A presentation view displays information in a predefined structure. The actions in portal_types, for instance, are views. </p><p>Workflow This is a method for encapsulating business logic in aseparate module; see Chapter 8. </p><p>XML Extensible Markup Language (XML) is a standard for data interchange. </p><p>Zope Zope is an open-source Web application server written in Python. Plone uses Zope. </p><p>ZMI The Zope Management Interface (ZM!) generally refers to the Web interface used for Zope Management and Administration. (When you log in using http://your. zope. site: 8080/manage, note the manage at the end.) </p><p>ZPT Zope Page Templates (ZPT) is the system for creating dynamic pages using TAL. </p><p>ZPL The Zope Public License (ZPL) indudes the terms under which Zope is licensed. </p><p>543 Index </p><p>A Advanced search, 68-69 Accelerated HTTP Cache Manager, 447-449 Archetype Image objects, listing, 413 Access contents information permission, Archetypes content type, 530 262,265 Archetypes framework, 387 Access future portal content permission, 260 Archetypes tool, 387-426 Access log file, 429 custom widget for, 529 Access rules, 201 fields available in, 394-395 Accessors, overriding, 407-408 installing, 389 acLusers (actual users) folder, 256, key features of, 388 258-259,280 ArchExample example product, 389-412, 529 ACME product, 413 configuration file for, 410 Acquisition feature, 107, 188,262 installing, 389 Action properties, key/value pairings for, 325 ArchGenXML product, 387, 421 Actions, 93-94, 322-324 complex example, 422 adding for users, 254 placing in a directory, 389 changing in portaLtypes tool, 407 ArgoUML,422 for Controller Page Template object, 166 Article Blurb content type, in and the entities that can make them, 217 ArchExample, 391 explained, 217, 322 ARTICLE_GROUPS variable, 410 in the file system, 205 Article schema fields, in ArchExample, 393 properties for default, 93-94 article3iew page template, for revisited, 111 ArchExample, 407 Actions for content types, how Plone looks ArticleGroups, HTML for, 410 up,323 Article.py, for ArchExample, 390, 409-410 Actions tab, portal_membership, 256 ASP 404, 300, 302 Actions and transitions combined, 217 Assignable roles, 245 Active Directory, using for authentication, 280 attributes statement (Il8N), 143 Ad-hoc keywords, 92 attributes statement (TAL), 122-123 Add-ons, Plone, 285 Authenticated role, 244 Add portal member permission, 264 Authentication systems Add/Remove products options, 291 external, 279-282 Add Workflow button, 222 LDAp, 280-281 addMember function of relational databases, 282 portaljegistration, 269 Authoring content (WebDAV), 308 Admin user, 244 Administering a Plone site, 71-81, 427-433 </p><p>545 Index </p><p>B button validation, 165 Background color, 209 byline element attributes, 185 Background image, 103 Backing up, bash script for, 428 c Backing up a Plone site, 427-430 Cache parameters in the control panel, 438 Backup log files, 429 Cached copy of an object (Zope), 202 bad_template.pt, 159-160 Caches Base dass views and actions, overriding, assigning, 450 406-407 between a dient and a server, 446 base_properties object, 208 script to purge, 532-533 BaseBTreeFolder, 416 Caching BaseBTreeFolderSchema, 416 ofcontent, 446-447,450-453 BaseContent dass, 406-407 of content types, 450-453 BaseFolder content type, 416 things that can be cached, 446 BaseSchema, 393 on ZopeZen.org, 453-454 BaseSchema elements, 393 Caching mechanisms, 447 Bash script for backing up, 428 cachinK-policy_manager tool, 450-452, Benchmark numbers, 435-436 457-458 Benchmarking a Plone site, 434-439 Caching rule for a policy manager, 532 Binary tree folder, 416 Caching servers, using, 454-458 blurb content type, in ArchExample, 390-391 Caching skins, 447-450 Body text field (Edit Document screen), 47 Cadaver product, 308 Bold byline, 185 Calendar, viewing events in, 59 Book license, 12 Calendar portIet, 83 Boot volume, 23 Call Profiler, 440-441 Boulanger, Robert, 421 with file system hooks selected, 440 Braces ({}), variables wrapped with, 110 results ofthe profile, 441 Broken page template, 159-160 Canadian Plone logo, 100 BrowserWYSIWYG editor, 310 Case-sensitivity of Zope, 107 Browsers Case of text, Plone changes to, 95 functional, 14 Catalog recommended, 13 getting a random object from, 344 BTreeFolder, 417 searching, 337-344 Bug tracker, 239 Catalog brains, 342 Bugzilla, 240 Catalog query, 527 Burnette, Tommy, 9 drop-down list based on, 528 Burton, Joel, 426 sampie results from, 527 Business rules Catalog search, reserved keywords in, 338 applying to content, 4 Catalog tool (portal_catalog), 337 examples of, 213 Indexestab,332,334 Update Catalog, 336 </p><p>546 Index </p><p>Categorizing content, 331-346 Content (see also Content types) CGI (Common Gateway Interface), 106 accessing using Web Drive, 309 Changes, propagating, 412 adding comments to, 65-66 Class for a content type, writing, 353-356 adding and editing, 55-61 Class views and actions, overriding, 406-407 allowing users to add and edit, 4 Classes applying business mIes to, 4 adding security to, 362-363 broad definition of, 2 for each content type, 406 caching of, 446-447 Python vs. Plone, 364 default workflow for, 218 ClassSecurityInfo dass, 361-362, 382 discussing and finding, 65-69 ClassSecurityInfo dass methods, 362 editing with rich editors, 309-316 CMF (Content Management Framework), expired,63 8-9, 130 explained, 446 CMFCollector object, 416 folder workflow for, 220 CMFExternalFile product, 287, 306 indexing, 331-334, 336 CMFNewsFeed, 462 managing from within Plone, 306 CMFSquidTool, 457 Microsoft Office, 417-421 CMS (Content Management System), organizing, 61-64 2-3,304 owner of, 219 benefits of, 3-4 page templates and, 114-115 definition of, 3 reindexing, 336 Code layers (Plone page), 180-181 review of, 54-55 Code listings used in this book, 509-533 searching for, 66-68 Collaborating on a document, 246 searching and categorizing, 331-346 Collections of objects, creating, 416 separating from presentation, 3 Collective project at SourceForge, 285 storing in a relational database, 423 Collector objects, 416 storing in a SQL database, 423-426 Colors, customizing, 181,208 submitted for review, 52 COM interfaces, listing available, 419 transforming, 417 COM Makepy utility, 419 where to add, 45 Command line, mnning Plone from, 21 Content authoring (WebDAV), 308 Comments, adding to content, 65-66 Content customization, Plone, 6 Community, Plone, 7 Content management, 213 condition statement (TAL), 123-124 content statement (TAL), 124-125 Conditions, evaluating, 123-124 Content tabs, 93 config. py file, 357, 380-381 Content type information, storing in the Containers (Plone site) , 107 file system, 325 Containment, 107 contenctypejegistry tool, 330-331 Containment hierarchy, 107 </p><p>547 Index </p><p>Content types, 42, 330, 402. See also CPU (Central Processing Unit) power, 437 Content CPU bound, 437 caching, 450-453 create_generator function, 351-353 changing the icon for, 322 Creative Commons license, 12 code for, 408-412 Creator method, 272 configuring, 320 Credit card bill, workflow of, 214-217 creating from existing types, 326-328 Credit card billing example, 214-217, 229 defined,318 Crystal Reports, 385 examples of custom, 317 CSS (Cascading Style Sheet), 100, 105, how Plone looks up actions for, 323 178-180 installed in each Plone instance, 320 benefits of, 180 instalIed in Zope, 320 changing, 97-103 manipulating, 317-331 changing to point to a new image, 102 overview of, 318-331 customizing, 184-186 persisting in a relational database, 424 hiding elements, 192 registration in portal_types, 321-325 that powers the NASA Mars site, setting up, 418-419 519-522 starting, 349-350 CSS properties, 183-184 testing, 419-420 CSV (comma-separated) file transformation of, 417 importing users from, 523-525 two-step installation, 320 users in, 267-268 using SQLStorage, 425 csv module, 268 when to make, 319-320 Custom Chrome skin, 199 writing a dass for, 353-356 Custom Errors tab, 301 writing custom, 347-378 custom folder, 185 writing in UML diagrams, 421-423 Custom skin, 200 ContentInit function parameters, 360 Customizingyour site, 71-103 Context, of object being executed, 106 CVS (ConcurrentVersioning System), 27, 285 Context hierarchy, 108 installing Plone from, 27 contextType validation, 165 for source code control, 286 Contributors field (properties form), 51 CVS repository in Zope, 286 Control panel (Plone), 72, 249 Controller Page Template object, 165-166 D Controller Page Template object actions, 166 da Silva, Sidnei, 421 Controller Python scripts, 517-518 data statement (Il8N), 143 Controller Validator objects, 165-166 Databases Conventions used in this book, 11-12 deaning up, 430-432 Cookie authentication, 257-258, 274 old 2GB limit on, 430-431 cookie_authentication object, 257-258, 274 Date formats, altering, 90-91 Cookies, enabling, 37-38 Date index, searching, 338-339 Copyright field (properties form), 51 Date range, searching on, 339 </p><p>548 Index </p><p>DateRangeValidator dass, 405 Development environment, setting up, Dates 465-483 effective,51 Discussions, enabling, 65 expiration,51 DisplayList dass, 410 DateTime API, 499-505 Do nothing option (in review), 54 DateTime functions, generic, 505 doActionFor method of portal_workflow, 235 DateTime objects DOCTYPE dedaration, 113 methods of, 501-504 Document, 2, 43 numerical behavior, 500 adding, 44-45 Python built-in methods for, 504 adding from green drop-down menu, 44 DCWorkflow, 214, 220 adding from main folder content DCWorkflowDump, 242 menu,45 Debian Linux, installing Plone on, 24-25 collaborating on, 246 Debug mode, 202 creating in a folder, 526-527 running Plone in, 20-21, 30 editing, 46-49 slow performance in, 436 editing in Epoz, 310 Debugger, Python, 377-378 editing published, 55, 230-231 Debugging during development, 374-378 loaded into Word, 420 Debugging a product using Zope, 375 publishing, 51-55 Debugging proxy servers, 303 retracting published for editing, 55 Debugging skins, 202 sharing,55 dedareProtected method, 362 documenCactions, 97 Default methods, overriding, 407-408 Document content types, 43 defauicoutpuctype, 402 Document description method, 106 default page, changing, 92-93 documencedit.cpy, 369-370 Default workflow, 218-219 Document metadata, setting, 49-51 permissions, 219 Document states, 51-54 for Plone content, 218 Documentation, Plone, 7 DefaultDublinCoreImpl dass, 361 documentContent element, 209 define-macro function (METAL) , 134-136 Dollar sign, 110 define-slot function (METAL) , 136-137 DOM (Document Object Model) element ID, 192 define statement (TAL), 125-126 domain statement (Il8N) , 141-142 Definitions ofterms, 537-543 DOS (Denial of Service) attacks, 292 Description, Plone site, 28 Dreamweaver MX, 314-315 Description field (Edit Document screen), 47 DTML (Document Template Markup Developing with Archetypes, 387-426 Language), 113 Developing with ZClasses, 349 DTML syntax for a style sheet, 181 Development, debugging during, 374-378 DTMLfor Zope, 181 Dynamic update tool, 412 </p><p>549 Index </p><p>E Error checking page templates, 161 E-mail Error handling, TAL, 126-127 sending to everyone in a group, 272 Error list, 302 sending to the Webmaster, 167-171 Error log, 78-81 E-mail address in portal settings, 76 Error log form settings, 79 E-mailform, building, 168-169 Error Log option, 78 E-mail form validator, 169-170,273 Error messages, 80, 275 E-mail notification script, 272 Error on startup, 376 E-mail notifications, sending, 237-239, 272 Error types, standard, 80-81 E-mail script, 170-171 Errors E-mail users, viewing or editing, 254 components of, 79 E-mail validation, setting on or off, 253 logging in as user who got, 274 Edit Document screen Event log file, 429 Document Details, 46 Event types, adding, 91-92 fields, 46-47 Events Edit option (in review), 55 adding and editing, 58-59 Edit page, making, 368-371 viewing in the calendar, 59 Edit script, 369-370 Events list, editing, 91 Editing a published document, 55 Events pordet, 83 Edits, method for handling, 355 Excel documents, handling, 417-421 Effective date, 50-51 Execution order of TAL attributes, 129-130 Effective Date field (properties form), 50 Expiration Date field (properties form), 50 effective-user, in zope.conffile, 277 Expiration dates, 50-51 Element attributes, changing, 122-123 Expired content, 63 Elements Expressions, 108-111 finding, 195-198 Extensibility, Plone, 6 moving with position attribute, 193 Extension content type, 330 Elements and pordets, removing, 207-208 Extensions, object vs. Zope object, 203 emaiLtemplate macro, 414-415 Extensions directory, 271 emaiLwidget.pt page template, 414 External authentication systems, 279-282 emaiLwidget.py page template, 529 External Editor too!, 63, 311-314, 417, 420 EmaiIWidget.py, 415 editing page templates with, 314 Emergency access ac count, 278-279 installing the dient product, 311-314 Emergency access on Windows, 279 installing the server product, 311 Emergency user, explained, 278-279 External File content type, 306 Emergency User page, 20 External method objects, 149, 156-158,525 Environment, setting up, 465-483 ExternalFile directory, 288-289 Environment Variables dialog box, 466 ExternalFile folder, 289 Epoz (WYSIWYG editor), 309-310, 368 exUserFolder (extensible user folder), 282 </p><p>550 Index </p><p>F Folder contents, 70 Factory-based type information, 325 features in, 63 Factory type information and actions, viewing, 62-63 357-358 Folder properties, 182-183 Failover, 463 Folder workflow, 219-220 Favorites, icon to add, 84 Folderish objects, developing, 416-417 Favorites portlet, 84 Folderish type, creating, 416 Features, turning off or removing, 207, 445 fontColor, 181 FeedbackForm page template, 515-517 Fonts, customizing, 181 Field attributes, 395-397 Forgotten password, getting, 38-39 Field index, searching, 338-339 Form to call a template, 346 Field and widget combinations, 401-402 Form controller new object types, 162 Fields, 390, 394-397 Form and script actions, 166-167 available in Archetypes, 394-395 Form for sen ding e-mail, building, 168-169 instantiating, 394 Form for users to enter feedback, 515-516 name attribute for, 395-396 Form validators, creating, 164-166, 169-170 and schemas and widgets, 392 Format field (Edit Document screen), 47 File management, 306 Format field (properties form), 50 File system Forms actions in, 205 creating, 163-167 creating a Python module on, 241 hiding help in, 194 integrating Plone with, 303-316 sequence of events when executing, making a skin on, 201-205 162-163 storing content type information on, 325 using, 162-171 using validators in, 204-205 Forwardslash (I), 108-109 File system object metadata, setting, Free Software Foundation Web site, 4 203-204 French, Plone.org in, 144 File system objects, 202-204 FSDVs (file system directoryviews), 175-176 File type configuration on Windows, 312 adding to skins directory, 373 Files, adding and editing, 57-58 creating objects in, 202 Fill slot, defining a slot inside, 189 FTP (file transfer protocol), 330, 403 fill-slot function (METAL), 137-138 FTP Access field (Ports page), 20 Firefox browser, 180 FTP access in Internet Explorer, 307 Firewall, port protection at, 277 FTP access into Plone, 306-308 FixUsers external method, 525 FTP clients, 307-308 Folder,61 Fullbackup, 428-429 adding and removing properties from, 88 Fulton, Jim, 243 creating, 329, 416, 526-527 publishing, 64 G setting up, 39-40 generate_html function, 352 using, 62-64 generatePassword function, 269 </p><p>551 Index </p><p> generateUniqueId Script (Python) object, H 328-329 HEAD requests, 448 getCatalogResults page template, Header image, 209 344-345,527 header.py Python module, 448, 531-532 GetGroups external method, 525-526 Help, hiding in forms, 194 getGroupUsers script, 271-272 Hiding elements at the CSS level, 192 getHTMLCode function, 368 Hierarchy (object), 107-108 getInfoFor method ofportal_workflow, 240 Horne page, customizing, 2l1-2l2 getLanguages method, 368-369 Horne tab, altering, 94 getPhysicalPath method, 266 HTML (HypertextMarkup Language), 3,105 getRawCode method, 357 with custom tags, 113 getSpecialBlurb method, in ArchExample, 408 testing and cleaning up, 159-160 GIF image, 100 turning program code into, 349 global_cache_setting page template, 450 HTML editors, 48-49 Global defines in the main template, 497-499 HTML generation systems, 113-114 globalBackgroundColor, 208 HTML-Kit editor, 315-316 globals function, 411 HTML select element, 410 Globbing (in searching), 67, 341 HTML size attribute, widget, 398 Glossary ofterms, 537-543 HTML Tidy output, 160 google_ad_portlet listing, 514 HTML Tidytool, 159-160 Google ads HTTP (Hypertext Transfer Protocol), 257 creating a portlet with, 147-148 HTTP authentication, 257 page template that provides, 513-514 HTTP headers, checking, 448-449 GPL (General Public License), 4, 284 HTTP proxy, 293 group Management, 259 HTTPCache, 447-449 Group members, list of, 251 HTTPCache defaults, 447-448 Group members option, 251 Hybrid storage solution, 306 Groups, 245 adding users to, 251 I administering, 249-251 il8n (internationalization) namespace, assigning roles to, 248, 251-252 133, 140 default properties for, 255 il8n:attributes statement, 143 listing users in, 271-272 il8n:data statement, 143 removing users from, 251 il8n:domain statement, 141-142 when to use, 250 il8n:name statement, 142 and workspaces, 250 il8n:source statement, 142 Groups tab, 249 il8n:target statement, 143 GroupWorkspaces folder, 250 il8n:translate statement, 141 GRUF (Group User Folder), 245, 258 Icon, changing for a content type, 322 Guards, transition, 266 Icons for a document, altering, 96-97 ICP (Internet Cache Protocol), 463 </p><p>552 Index </p><p>ID Installing Plone, 13-31 getting, 329 fromCVS,27 Plone site, 27 on Debian Linux, 24-25 searching for, 196 on Mac OS X, 21-23 ID field, BaseSchema, 393 from source, 25-28 IIS (Internet Information Services) Web using an RPM, 23-24 server, 299-303 305-306 on Windows, 14-21 Image directive, 496 Installing Plone products, 285-292 Image field, 402 Installing products Images in Plone, 290-292 adding and editing, 56-57 on Unix, 289 changing, 97-103 on Windows, 288-289 top tabs as, 2l0-211 in Zope, 286-290 uploading, 56 INSTANCE_HOME, 287 viewing,57 IntegerField, testing, 403-404 Images policy (caching), 452 Integration with other systems, 283-316 Import statements, 360-361 Internationalization, 5, 133, 140-146 Imports, definitions of, 361 Internationalization (Il8N) namespace, Importusers external method, 523-525 133,140 Incremental backup, 429 Internet Explorer, FTP access in, 307 Indentation error in Script (Python) Internet Explorer 4.x, enabling cookies, 37 object, 151 Internet Explorer 5.x, enabling cookies, 37 index_htm!, 92, 211-212 Internet Explorer 6.x, enabling cookies, 37 Index search results, using, 342-344 invokeFactory Script (Python) object, Index types, table of, 332 328-329 index. asp, as the first default page, 92 I/ 0 bound, 438 Indexes, 331-334 islnt validator, 404 default Plone, 333-334 Issue-tracking system, 239-240 explained, 331 Issues (bug) report, 239 Indexes tab of portal_catalog, 332, 334 Hem Indexing an object, process of, 336 as an object, 106 Indexing and searching information, 4 defined,318 Ingeniweb, 245 __ init__ .py file, 350, 380-381 J __ init_.py module, 359-360 Join link, 33 Initial state, setting for a workflow, 223-224 InitializeClass function, 361 K Input, validations of, 403-406 Key /value pairings for action properties, Installation function, 372 203,325 Installers, Plone, 5 Keyword index, searching, 340 Keywords, adding, 91-92 Keywords field (properties form), 50 553 Index </p><p>L Logs, Plone, 31 LAMP development paradigm, 337 Long date, 90 Language, drop-down list for selecting, 369 Look and feel ofPlone, 81-103,173-212. See also Skins Language field (properties form), 51 Looping, 127-129 Layers, 174-175, 180-181 Lowercase, text changed to by Plone, 95 explained, 174 order of within a skin, 174 skin as a collection of, 198 M Layers and skins, sorting, 175 Mac OS X, installing Plone on, 21-23 LDAp, using for authentication, 280-281 Macro property for widgets, 413-415 LDAPUserFolder, 281 Macros Left and right slots, moving, 193-194 how Plone uses, 138-140 len function (Python), 343 viewingl editingl searching, 414 Lesser GPL, 284 Macros and slots, main template, 189-191 Licensing, open-source, 284 Macros and slots (METAL), using, 137-138 Links, adding and editing, 60 Maestro program, 206 Linux, installing Plone on, 24-25 Maestro site, 206-207 liscgenerators function, 352 Mail server, setting up, 77-78 List portal members permission, 267 Mail Settings option, 77 listMembers methed of MailHost, 77, 237-239 portal_membership object, 238 Maiiman (mailing list manager), 305 listTypes function, 411 mail. py listing, 523 Load balancing, 463 main slot in page template, 187 Local role, 246 Main template 10calLongTimeFormat, 90 customizing, 186-191 LocalSystem account, 277 global defines in, 497-499 10calTimeFormat, 90 macros and slots, 189-191 Lock icon, 63 Main workflow page tabs, 223 Locking down Plone, 276-277 mainFontColor, 181 Log files, backup, 429 majocminor content type, 330 Log out link, Plone site, 39 Makepy utility, 419 Logging errors, 78-81 manage_options tuple, 384 Logic error, 376 Management interface page, 383-384 login_form object, 106 ManagePortal perrnission, 381 Login pordet, 84-85 Manager role, 230, 245 Login settings for a site, changing, 275 Mapping tab, 294 login_success template, 198 master macro, main_template, 186 Logo Members role, 245 alte ring, 98-100,178 Members tab, moving, 94 default,98 Membership source, Plone site, 28 logo.jpg image, 98-100, 178 Memory amount, slow performance and, 437 </p><p>554 Index </p><p>Memory bound, 437 N meta_type, 99 Name attribute (fields), 395-396 Metadata, 334-335 Name lookup, limiting, 444 changing in bulk, 270-271 name_regex content type, 330 explained, 49 name statement (Il8N) , 142 file system object, 203-204 Namespaces (XML), 113, 158-159, 188 Plone default, 335 NASA Mars site, CSS that powers, 519-522 Metadata file, 203 NASA skin case study, 206-212 specifying actions in, 205 Navigation portIet, 85, 89-90 validator section of, 204 Navigation tree, altering, 90 METAL (Macro Expansion Template Navigation tree properties, altering, 89 Attribute Language), 133-140 Netscape Navigator 6.x, enabling cookies, 38 METAL namespace, 133 Network connection, slow performance metal: prefix, 158, 188 and,438 metal:define-macro function, 134-136 News items, adding, 60-61 metal:define-slot function, 136-137 News items list, 61, 93 metal:fill-slot function, 137-138 News portIe!, 85-86 metal:use-macro function, 135-136 Nocall expression, 109 Methods, overriding, 407-408 Not-assignable roles, 244 Microsoft Office content, handling, 417-421 Not expressions (in seaches), 68, 109,342 Migration steps (Plone), 433 MIME (Multipurpose Internet Mail Extensions) types, 50, 100,418-419 o MIME type forWord document, 418 Object hierarchy, 107-108 mimetype_regex content type, 330 Object inheritance, 107 mkdemo script, 422 Objectpublishing, 106-108 mkzeoinstance script, 460 ObjectManager API, 236 Mozilla l.x, enabling cookies, 38 ObjectMoved exception, 237 Mozilla-based browser, 180 Objects, 105-106,318. See also Content Multiple skins, using, 199-201 creating collections of, 416 Multiple user information, displaying, indexed, 336 146-147 moving during workflow, 235-237 Mutator methods, overriding, 407-408 Plone default, 537 mxTidy product, 284 Objects up to five days old, returning, My content, 44 153-154 My folder link, 40, 44-45 on-error statement (TAL), 126-127 My preferences link, 40 One liners (simple expressions), 108 myCachingRules script, 453, 532 Open-source licensing, 284 MySQL,423 OpenFlow, 214 OpenOffice.org bindings, 283 OpenOffice.org suite, 417 Opera browser, 38, 186 </p><p>555 Index </p><p>Optimization, whether to use, 445-446 syntax checking, 161-162, 515 Optimization tricks, 444-446 user information in, 272-273 Or (search option), 67, 341 variables available in, 509 Organizing content, 61-64 Page templating, 105-132 OSCOM (Open Source Content advanced, 133-148 Management Conference), 1 underlying machinery of, 105-112 outline_argo directory, 422 Page width, setting for all pages, 210 outputPage method, 384 PageTemplateFile dass, 384 Owner of content, 219 parentuid (uid of parent object), 426 Owner role, 245 Passwords Owners editing documents in published forgotten, 38-39 state, 231 gene rating random, 269 Ownership concept, 217 Path, looking up, 106 Ownership ofimported objects, 241 Path expressions, 108-109 Path index, searching, 340-341 p Path traversal, 119 Package PDF (Portable Document Format), 385 turning into a product, 356-360 Pending state (document), 53 turning into a too!, 380-381 Performance (Plone), 433-458 Packaging, Plone, 5 amount ofmemory and, 437-438 Packing the ZODB, 430-432 applications causing poor, 439 Page Template Attribute expressions, 149 network connection and, 438 Page template code, checks on, 158-162 processor usage and, 437 Page template elements, searching reasons for slow, 436-439 through,195-198 Permissions, 259 Page template error, 117 acquired, 262 Page template expressions, 108-111 applied to a role, 260 Page template management screen, 118 editing, 230-231 Page Template option, 115 for published state, 265 Page Template Profil er, 442 setting, 259-267, 358-359 Page templates, 114-115 setting through the ZMI, 262 as objects, 106 settings for, 261 basic syntax for, 119-132 table of common, 263 broken, 159-160 user, 233 creating, 115-119 Permissions tab, 230, 265 to display user information, 130-132 Personal preferences, 40-41 editing, 116 Personalization, 5 editing in Dreamweaver, 315 PersonSQL object, 425 editing with External Editor, 314 personsql table, 425-426 error checking, 161-162 PersonSQL.py module, 530 generating the page, 118 Phrases option (in searches), 68, 342 </p><p>556 Index </p><p>PIL (Python Imaging Library), 283 Plone default objects, table of, 537 Pipe symbol (1),108-109 Plone Default skin, 177, 200 Plain text, 49 Plone default tools, table of, 535-536 Plain-text file, adding, 58 Plone demonstration Web site, 1 Plone Plone HTTPfieid (Ports page), 19 configuring, 293-295 Plone installers, 5 content customization, 6 Plone instance, content types instalied in development of, 8 each,320 documentation for, 7 plone_log script, 232 extensibility, 6 Plone look and fee!, customizing, 81-103, features of, 4-7 173-212 FTP access into, 306-308 Plone performance, improving, 433-458 hooking into using METAL, 134-140 Plone products, installing, 285-292 installing, 13-31 Plone search engine, 66 installing products in, 290-292,371-373 Plone server security and setup, 277-279 integratingwith the file system, 303-316 Plone setup option, 72, 77, 249, 291 integrating with other services, 277-282 Plone site internationalization, 5 adding, 27-28 locking down, 276-277 administering, 427-433 packaging, 5 backing up, 427-430 profiling, 439-444 benchmarking, 434-439 Python script uploaded into, 328 customizing, 71-103 registration system, 5-6 getting to the root of, 74 vs. relational databases, 337 joining, 33-39 running from the command line, 21 key user interface elements, 186-187 Scripting Plone, 153-155 stopping users from accessing, 264 scripting with Python, 148-158 stopping users from joining, 264 starting in Debug Mode, 20-21 stopping users from searching, 264 upgrading, 432-433 three columns to a page, 81 usability, 5 tide and description, 76 WebDAV access into, 308-309 Plone site examples, 7-8 Plone 2 skins, 177 Plone site form, prompts on, 27-28 Plone dass, 364-366 Plone site login settings, changing, 275 Plone dass vs. Python dass, 364 Plone site properties, accessing, 301 Plone community, 7 Plone site states (production and debug modes), 202 Plone control panel, 71-72, 249 Plone site tabs accessing, 72 altering, 93-97 functions, 73 types of, 93 Plone default indexes, table of, 333-334 plone_skin, 200 Plone default metadata, table of, 335 Plone skins. See Skins </p><p>557 Index </p><p>Plone status portal_memberdata properties, 254-255 not running, 17 portal_memberdata tool, 254-257 running,18 Portal membership, 256 Plone Tableless skin, 177 portal_membership object listMembers Plone templating, 105-148 method,238 Plone Windows installer, 14-18 portaLmembership tool, 238, 256 Enter a Password screen, 16 portaLmembership tool APIs, 256-257 Select Destination Directory screen, 16 Portal object, 81 Welcome screen, 15 portaLquickinstaller tool, 371-372 plone_workflow tool, 265 Portal registration, 253-254 PloneCollector object, 416 portal_registration addMember function, 269 PloneCollectorNG, 220, 239-240 portaLregistration tool, 253-254, 269 plone.css file, 181 Portal Settings option, 75-76 ploneCustom.css file, 184-186,209,519-522 Portal skins, 97-98 ploneCustom.css object, customizing, 101 portaLskins taol, 175-177, 198 PloneIssueNG, 239 Contents tab, 175, 177 Plone.org in French, 144 Find tab, 196 Plone.orgWeb site, 1-2 Properties tab, 176, 199 Plone.org ZEO configuration, 463 in standard Plone installation, 175 PloneSilverCity dass, 353-356 Portal tabs, 93 PloneSilverCity directory, 350 adding or removing, 96 PloneSilverCity example product, 528 alte ring, 94, 192-193 PloneSilverCity. py module, 356 portal-top element, 209 PloneStats example product, 529 portal_transforms tool, 417-419 PloneStats on ZopeZen, 379 documentation, 421 PloneWorkflows, 220 downloading, 421 Policy manager, caching rule for, 532 portaLtypes taol, 357 Port protection at the firewall, 277 changing an action in, 407 portal_actionicons taol, 96 content type registration in, 321-325 portaLactions taol, 94-97 portaLworkflow, 221 portal_catalog tool, 337 doActionFor method, 235 Indexestab,332,334 getInfoFor method, 240 searchResults method, 337 PortalContent dass, 361 Update Catalog, 336 Portlet properties, default, 82 portaLfactory tool, 371 Portlets, 81-89 portal-globalnav element, 210 creating, 147-148 portal_groupdata tool, 255 default,82 portal_groups tool, 256 in different parts of a site, 88-89 Portal member data, 254-256 explained,81 portaLmemberdata form, 255 Portlets and elements, removing, 207-208 </p><p>558 Index </p><p>Ports Properties, CSS, 183-184 binding to as root, 277 Properties of a folder, 182-183 changing, 19-20,29-30 Properties form fields, 50-51 Plone running on, 19 Properties tab, 88-89 Ports page, 19-20 Proxy roles, 266-267 position attribute, for moving elements, 193 Proxy servers, 292 Postgres database, 423-424 checking the URL, 303 Pound load balancer, 463 configuring, 295-303 Predefined roles, 244-245 debugging, 303 Preference options, 41 testing the site for, 303 Preferences using, 305-306 changing, 40 virtual hosting using, 293-295 setting up, 40-41 Proxy settings, on a script, 234 Preformatted text (code sampies), 493-494 Proxy tab, ZMI, 267 Presentation, separating from content, 3 Proxying Press release example, 326-328 explained, 292 Primary field marshalling, 403 how it works, 296 Private state (document), 54 Pseudo-XML,495 Privileges, creating and deleting, 424 PT Profile Vi ewer, 442 process_types function, 411 Published document Processor usage, slow performance and, 437 editing, 55, 230-231 Product attributes, 348 retracting for editing, 55 Product initialization, 359-360 Published state (document), 53 Product installation, testing, 289-290 Published state permissions, 265 Product modules, altering, 360-366 Publishing, rules for, 4 Production environment, setting up, 465-483 Publishing a document, 51-55 Production mode, 202 Publishing a folder, 64 Products, 285 Publishing objects, 106-108 finding, 285-286 Purge Cache extern al method, 532-533 installing in Plone, 290-292, 371-373 Pygame product, 283 installing in Zope, 286-290 Python, 9-11 installing on Unix, 289 books ab out, 11 installing on Windows, 288-289 external method objects, 156-158 testing, 373-374 len function, 343 turning packages into, 356-360 method for handling edits, 355 writing in Python, 347-385 Restricted Python, 155-156 Products directory, 201, 287 Scripting Plone with, 148-158 Products list, 291 searching the catalog using, 337-344 Profiling tools, 439-444 StringIO module, 352 Programming error, 376 strings and, 112 Projection style sheet, 186 test code, 353 </p><p>559 Index </p><p> using inside Zope Page Templates, 111 Random password, gene rating, 269 writing workflows in, 241-242, 505-507 RangeValidator dass, 404 Python built-in methods for DateTime Rapid development, 422 objects, 504 ReadFile external method, 514-515 Python dass Recent portlet, 86 code for, 354 recentlyChanged listing, 514 vs. Plone dass, 364 redirecCto option, 166 writing, 353-356 redirecCto_action option, 167 Python debugger, 377-378 Redirection vs. traversal, 167 Python dictionary keys, 323-325 References between existing objects, 413 Python expressions, 110-111 Refresh too1, 377 Python License, 284 refresh.txt,377 Python module RegexValidator dass, 404 creating on the file system, 241 registerDirectory function, 367 PersonSQL.py, 530 Registering custom validations, 404-406 Python (Script) objects. See Script (Python) Registering users, 267-270 objects registerType function, 410 Python package Registration of content types, 321-325 _init_.py file, 350 Registration page/form, 34 text files, 350 Registration page/form errors, 36 Python products, 149,283-284 Registration page/form fields, 35 Python Profil er, 443-444 Registration and personalization, 5-6 Python Profiler results, 443 Registration system, Plone, 5-6 Python prompt on Windows, 10 Registration tools, 252-259 Python script uploaded into Plone, 328, 348 Reindexing all Plone site content, 336 PYTHONPATH Reject option (in review), 54 setting up, 465-468 Related portlet, 86-87 setting up in Unix/Linux/Mac OS X, Relational database, 337 465-466 authentication, 282 setting up in Windows, 466-468 persisting content type in, 424 Pythonwin, 419,467 storing content in, 423 PyXML, installing, 389 repeat statement (TAL), 127-129,344 repeat statement variables, 128 Q replace statement (TAL), 129, 383 Query, explained, 339 Reporting too1, 385 Quick Instalier, 371-372 ReportLab product, 283 repozo.py script, 428 R Repurposing, 326-328 RAMCache RAM Manager, 449, 453 RE QUEST methods, RAMCache RAM Manager defaults, 449 cachinß-policy_manager, 458 Random object, getting from the catalog, 344 Request variable, 200 </p><p>560 Index </p><p>Reserved keywords in catalog search, 338 Script (Python) objects, 105, 149-156,201 Restricted Python mode, 155-156 adding, 150, 200 Restricted Python modules, 155-156 editing, 150 reStructured Text, 489-496 explained, 149 example list, 491-492 indentation error in, 151 example points, 491 Scriptable Type Information, 325 lists, 490-493 Scripting object, creating, 328-329 text styles, 490 Scripting Plone, 153-155 Review of content, 52, 54-55 layers of, 149 Review list, 54 with Python, 148-158 Review list choices, 54 Scripting users, 267-277 Review portlet, 87 scriptObjectCreation listing, 526-527 Reviewer role, 237, 245, 251-252 Scripts tab, 229 settings for, 261 Search,advanced,68-69 for Supervisor group, 252 Search engine (Plone), 66 Rich editors, editing contentwith, 309-316 Search form, making, 344-346 Right and left slots, moving, 193-194 Search options, 67-68 Roles, 244-245 Search on Plone.org, 67 adding, 264 Search results, using, 342-344 assigning to a group, 248 Search ZCatalog permission, 264 assigning to auser, 247 searchable attribute, 402 giving to groups, 251-252 SearchableText index, 363 permissions applied to, 260 SearchableText method, 363 viewing and removing, 248 Searching Roles of people, 217 by using the URL, 196-197 Roles and security in workflow, 216-217 the catalog, 337-344 Round-tripping, 422 and categorizing content, 331-346 RPM, installing Plone using, 23-24 for content, 66-68 a date index, 338-339 s a field index, 338-339 Schemas, 390, 392-393 for an ID, 196 Scintilla text editor, 349 and indexing information, 4 Script a keyword index, 340 as an object, 106 a path index, 340-341 assigning to a transition, 232 for a piece of text, 197-198 editing, 229-230 on a range, 339 proxy settings on, 234 through template elements, 195-198 Script (after) and script (before) settings, for auser, 246 230,232 a ZCText index, 341-342 Script (Python) object variables, 152 searchResults method, 337, 345 Section headers, 494 </p><p>561 Index </p><p>Sections of code, 494-496 SilverCity Security, 6, 273-277 API for, 351 adding to a dass, 362-363 installing, 350-351 external authentication systems, 279-282 SilverCity module, 349 giving roles to groups, 251-252 silvercity_ view. pt, 367 locking down Plone, 276-277 silvercity.css file, 368 permissions, 259-267 SimpleItem dass, 382 registration tools, 252-259 Single wildcards (search option), 67 roles, 244-245 site_actions, 96-97 scripting users, 267-277 Skin cookie persistence, 98 on the server, 277-279 Skin elements, 173 Sharing tab, 246-248 Skin of examples in this book, installing, 206 for a user running Zope, 277-278 Skin flexibility, 98 Web administration of groups, 250-251 Skins,5,97,173-177,446 Web administration ofusers, 249-252 adding, 367-371 workflow and, 216-217, 265-266 as a collection oflayers, 198 Security checks and traversal, 444-445 caching, 447-450 Security guard components, 227 changing, 97-98, 177 Security model (Plone), 6, 243 concept of, 97 Security settings, 260 customizing, 177-198 Security settings for apermission, debugging, 202 acquired, 262 default, 98,174 Security tab, 260, 262 layers within, 174-175 Select element (HTML), 410 making, 198-199 SelectionWidget, 401 making on the file system, 201-205 send method ofMailHost, 239 managing, 175-177 SendEmail script, 170-171, 517-518 order of layers within, 174 Server with Plone 2, 177 security on, 277-279 setting in the installation method, 373 testing product installation, 289-290 setting programatically, 200 Server configuration, 18-21 using multiple, 199-201 Services, integrating Plone with, 277-282 skins directory, 367, 373 SetObject method (Zope), 356 Skins and layers, sorting, 175 setSkin Script (Python) object, 200, 519 Skins and layers in standard Plone setup.py program, 350 installion, 176 Sharing a document, 55 Slot inside a fill slot, defining, 189 Sharing tab, 246-248 Slots,136 Short date, 90 altering, 87-88 Short name field (Edit Document screen), in earlier Plone versions, 81 46-47 how Plone uses, 138-140 left and right, 193-194 </p><p>562 Index </p><p>Slots and macros, main template, 189-191 methods for, 506 SMTP (SimpleMail Transfer Protocol) permissions for published, 265 server, 238 possible transitions from, 224 SOFTWARE_HOME, 287 setting initial, 223-224 Software used for this book, 12 setting initial as private, 224 sorUimit (keyword), 338 title and description, 224 sorCon (keywordl, 338 workflow, 215 sorCorder (keywordl, 338 States tab, 223-224 Sorting skins and layers, 175 Static HTML, 212 Source code control, CVS for, 286 Stats object, code for, 380 source statement (Il8N) , 142 stats. py module, 379 SourceForge, 220 Storage solution, hybrid, 306 SourceForge Collective project, 285 Storing content in a relational database, 423 SourceForge CVS, 285 Storing content in a SQL database, 423-426 source.py module, 351, 353 Storing content type information on the file Spacing, customizing, 181 system, 325 Splash page, creating, 211-212 String expressions, 110 SQL database, storing content in, 423-426 String field, 392, 401, 414 SQLStorage, 423-426 StringIO module (Python), 352 Squid caches Strings, Python and, 112 avoiding having to clean, 458 Structured text, 49, 483-489 cleaning, 456-457 basic formatting, 483-484 Squid Guard, 298-299 example code, 487-488 Squid server, 298-299 hyperlinks, 488-489 configuring, 299 indentation of, 484-485 installing, 298 lists and items, 486-487 using for caching, 455-456 Style sheets (CSS) , 178-180 Varytag,458 alternate for different clients, 185 Standard error types, 80-81 base properties, 182 Startup, error on, 376 creating,209-211 state_change parameter attributes, 231 DTML syntax for, 181 State drop-down menu, 52 Plone with vs. without, 179 State form fields, 53 Sub skin, explained, 411 State machine for paying credit card bills, 216 Sugarbaker, Mike, 1 State permissions page, 225 Supervisor group, reviewer role for, 252 States, 214, 218 Syntax checking of a page template, applying to content, 53 161-162,515 default,53 Syntax-highlighted HTML, turning document, 51-54 program code into, 349 editing, 224-225 </p><p>563 Index </p><p>T Text sections, 494-496 Tabs, 94-96,210-211 textTransform property, 182 Take ownership ofimported object Title, Plone site, 27 option, 241 Title field of BaseSchema, 393 TAL (Template Attribute Lauguage), 112 Title field of Edit Document screen, 47 TAL attributes execution order, 129-130 Tool code, altering, 382 TAL expressions, 232-233 Toollnit function, 381 TAL statement syntax, 122-129 Tools, 318 tal: prefix, 158-159 adding custom, 385 tal:attributes statement, 122-123 Plone default, 535-536 tal:condition statement, 123-124 testing, 385 tal:content statement, 124-125 turning packages into, 380-381 tal:define statement, 125-126 writing custom, 378-382 tal:on-error statement, 126-127 Top tabs, 94-96, 210-211 tal:repeat statement, 127-129,344 Topics, 61, 64 tal:repeat statement variables, 128 TortoiseCVS, 286 tal:replace statement, 129, 383 Transformations, setting up on Windows, 419 TALES (Template Attribute Language Transforming content, 417 Expression Syntax), 105, 133 Transition details page, 226 wrapped in Python, 110 Transition guard settings, 266 in Zope Page Templates, 108 Transition guards, 266 target statement (Il8NJ, 143 Transitions, 214-215, 218, 224 Templates. See Page templates assigning scripts to, 232 Terms, glossary of, 537-543 editing, 225-227 tesecontext page template, 120-121,509 entities that can make them, 216 Test function, 111 methods for, 506 </p><p>Testtab,Z~I,271 starting points and destination for, 227 tesevalidator, 165 triggering, 226 TestForm page template, 528 Transitions and actions combined, 217 test.gif, 452 Transitions tab, 225 Testing a custom too!, 385 translate statement (Il8N) , 141 Testing a product, 373-374 Translation service, 143-146 test.py external method, 156-157 Traversal, 119,444-445 testResults page template, 345, 527 explained, 106 Text vs. redirection, 167 preformatted, 493-494 traverse_to option, 167 reStructured, 489-496 traverse_to_action option, 167 searching for, 197-198 Trigger types, 226 structured, 483-489 Troubleshooting common problems, 276 Text format, choosing, 48-49 Text formatting rules, 483-496 </p><p>564 Index u User permissions, 233 UI (user interface) User record, editing, 259 adding elements to, 383-385 usecsection page template listing, 512-513 removing a block from, 191-192 User settings, changing, 249, 270-271 removing features from, 276 Users, 244 UI (user interface) elements, 186-187, adding, 249 383-385 adding actions for, 254 uid_catalog, in ZMI, 412-413 adding to a group, 251 UML diagrams, 421-423 administering, 243-252 UML model, 387 administering through the Web, 249-252 UML (Unified Modeling Language) too!, 387 allowing to add and edit content, 4 Unique IDs, 412-413, 426 assigning a role to, 247 uniqueValuesFor method, 346 finding, 246 Unit tests, setting up to run, 468-469 registering, 269-270 Unix, installing products on, 289 registering in bulk, 267-270 Update Catalog option, 336 registering themselves, 252 Update Schema, 412 removing from groups, 251 Update security settings option, 265 scripting, 267-277 Upgrade steps (Plone), 432 stopping from joining a site, 264 Upgrading Plone, 432-433 stopping from searching a site, 264 Upload document field (Edit Document Users in a group, listing, 271-272 screen), 47 Users and Groups Administration option, 249 Uploading an image, 56 Users tab, 249 URL (Uniform Resource Locator) components of, 296 v searching by using, 196-197 Validation options, 165 URL headers, script to print, 531-532 Validations (of input), 403-406 URL munging, 297 registering your own, 404-406 URL request, 106 table of, 404 URL rewriting in Apache, 297 that a number has been provided, 164 Usability, Plone, 5 Validator section of metadata file, 204 use-macro function (METAL) , 135-136 Validators User folder replacement, 282 creating, 164-166, 169-170 User form to enter feedback, 515-516 creating in ascherna, 406 usecinfo (1) page template listing, 510-511 using in a file system, 204-205 usecinfo (2) page template listing, 511-512 Validators list, 165 usecinfo page template, 130-132, 146-147 validEmaillisting, 518 User information in page templates, 272-273 Variable properties for workflows, 228 User metadata, changing in bulk, 270-271 </p><p>565 Index </p><p>Variables WebDAV Source field (Ports page), 20 available in page templates, 509 WebDrive program, 308-309 defining, 125-126 Webmaster editing, 227-228 explained, 3 methods for, 507 sendinge-mail to, 167-171 page templates built-in, 119-121 Widget and field combinations, 401-402 script default, 121 Widgets, 398-401 in tal:repeat, 128 alte ring, 413-415 wrapped with {}, 110 as SelectionWidgets, 401 Variables tab, 227 attributes of, 400-401 Vary tag, in caching_policy_manager, 458 defining and registering, 415 VerboseSecurity product, 273-275 extra attributes of, 398 VHM (Virtual Host Monster), 294 HTML size attribute, 398 View, adding, 327 instantiating, 398 View groups option, 248 macro property for, 413-415 Viewpage, making, 367-368 possible values for, 401 View permission, 265 and schemas and fields, 392 View tab, after saving content, 48 table of, 399-400 Viewing events in the calendar, 59 Width for all the pages, setting, 210 Viewing folder contents, 62-63 Wildcards, in index search, 341 Viewing an image, 57 Windows Virtual hosting, 74, 292 creating an emergency user on, 279 with access to root, 295 file type configuration on, 312 how it works, 293 installing Plone on, 14-21 using a <a href="/tags/Proxy_server/" rel="tag">proxy server</a>, 293-295 installing products on, 288-289 Visible state (document), 51, 53 Python prompt on, 10 visual-portal-wrapper HTML element, 209 server configuration on, 18-21 Vocabulary attribute, 401 setting up PYTHONPATH on, 466-468 setting up transformations on, 419 w Windows extensions product, 283 Web, administering users through, 249-252 windows.ini key/value pairs, 203 Web servers, 292-303 Word, document loaded into, 420 changing the ports, 29-30 Word 9.0 Object Library, 419 configuring, 28-31 Word documents in front of Plone, 292 editing, 314 in front of ZServer, 276 handling, 417-421 Web Site for this book, 69-70 MIME type for, 418 Web sites, company or organization, 1 WordExample product, 418, 530 WebDAV protocol, 330, 403 Workflow content type, 221-222 access into Plone, 308-309 Workflow e-mail notification script, 272 content authoring, 308 </p><p>566 Index </p><p>Workflow expression namespace x parameters, 233 XHTML (Extensible HTML), 49,113,158 Workflow expressions, 232-235 XMI (XML Metadata Interchange), 421 Workflow script, editing, 231-232 XML (Extensible Markup Language), 113 Workflow states. See States XML generation system, 421 Workflow transitions. See Transitions XML namespaces, 113, 158-159, 188 Workflow variable properties, 228 Workflows, 6,214-220 y adding, 221-222 common tasks using, 233-242 You are now logged in page, 195 concept of, 214-216 in content management, 213 z in credit card bill example, 214-217 ZCatalog, 66,445 deleting objects in, 237 ZClasses, developing with, 349 distributing and writing, 240-242 ZConfig, 469-483 editing, 222-233 ZCText index, searching, 341-342 explained, 2, 53, 213 ZEO (Zope Enterprise Objects) tool, 427 folder workflow, 219-220 applications based on, 462 list of, 222 installing, 459-461 listed by type, 221 standard setup, 459 managing, 213-242 using, 458-463 moving objects during, 235-237 ZEO clients, 459, 461-463 Plone default, 218-219 ZEO configuration, Plone.org, 463 registering in the system, 241 ZEO server, 459 roles in, 216-217 ZMI (Zope Management Interface), security in, 216-217, 265-266 73-75,115 separation ofbusiness mIes logic, 213 adding and editing workflow in, setting initial state, 223-224 221-233 using to track changes, 235 emergency access to, 278-279 writing in Python, 241-242, 505-507 exporting a workflow from, 240 writing through the ZMI, 240-241 Plone Site in, 26 Worklist properties, 228-229 Proxytab,267 Worklists, editing, 228-229 Security tab, 260 Worklists tab, 228 setting permissions through, 262 Workspace, groups and, 250 Test tab, 271 wvWare, 417 writing a workflow in, 240-241 WYSIWYG (What You See Is What You Get) ZODB (Zope Object Database), 319 editors, 48, 114,310,368 backing up, 428-429 packing, 430-432 </p><p>567 Index </p><p>Zope, 8-9 Zope Public License, 284 case-sensitivity of, 107 Zope security, 362 content types installation in, 320 ZOPE_SECURITLPOLICY=PYTHON debugging a product using, 375 environment variable, 274 installing products in, 286-290 Zope Web server (ZServer), 276, 292-293 security for, 277-278 zope.conffile, 277, 306, 469-483 setObject method, 356 zope.conf file directives, 470-482 Zope application container, 107 zopectl, 375 Zope cached copy of an object, 202 ZopeZen, 220 Zope configuration file, 277, 306, 469-483 caching on, 453-454 Zope configuration file directives, 470-482 PloneStats on, 379 Zope CVS repository, 286 zpasswd.py script, 278 Zope installation, getting to the root of, 74 zpt.py listing, 515 Zope Management HTTP field ZServer, 276,292-293 (Ports page), 20 ZSQL methods, 423 Zope object, defined, 319 Zope object extensions, 203 Zope Page Templates, 112-119, 181 TALES in, 108 uses for, 114 using Python inside, 111 </p><p>568 JOIN THE APRESS FORUMS ANO BE PART OF OUR COMMUNIW You'll lind discussions that cover topics 01 interest to IT prolessionals, programmers, and enthusiasts just like you. II you post a query to one 01 our lorums, you can expect that some 01 the best minds in the business-especially Apress authors, who all write with The Expert's Voice™-will chime in to help you. Why not aim to become one 01 our most valuable partic­ pants (MVPs) and win cool stul!? Here's a sampling 01 what you'll lind: </p><p>DATABASES PROGRAMMING/BUSINESS Data drives everything. Unfortunately, it iso Share inlormatiOll, exchange icleas, and discuss any database Talk about tl18 Apress line 01 IJOoks tl13t cover soffware programming or aelmnistratlon issues. methodology, best practices, anel how programmers Interact with tl18 "suits." </p><p>INTERNET TECHNOLOGIES AND NETWORKING WEB DEVELOPMENT/DESIGN Try living without plumbing (and eventually IPv6). Ugly doesn't cut it anymore, and CGI is absurd. Talk alJOut nelworking topics including protocols, design, Help is in sight for your site. Find design solutions for your administration, wireless, wlreel, storage, backup, certiflcatlons, projects and get leleas for IJullellng an Interactive Web site. trends, and new technologies </p><p>JAVA SECURITY We've come a long way from the old Oak tree. Lots of bad guys out there-the good guys need help. Hang out and discuss Java in whatever flavOi you choose Discuss computer amlnelwork security issues here. Just don't let J2SE, J2EE, J2ME, Jakarta, anel so on. anyone else know the answers l </p><p>MACOSX TECHNOLOGY IN ACTION All about the Zen of OS X. Cool things. Fun things. OS X is IJOtil the present and tl18 future for Mac apps. Make It's after 11Ours. It's time to play. Whetl18r you're into LEGO@ suggestions, offer up ideas, or boast alJout your new hardware MINDSTORMSTM or tUllling an old pe into a DVR, this is where technology turns Into fun. </p><p>OPEN SOURCE WINDOWS Source code is good; understanding (open) source is better. No defenestration here. Discuss open source technologies ami relatecl topics such as Ask questions alJOut all aspects of Windows programming, get PHP, MySOL, Linux, Perl, Apache, PytllOll, ami more. help on Microsoft technologies coverecl in Apress IJOoks, 01 proviele feedlJack on any Apress Wlnelows book. </p><p>HOW TO PARTICIPATE: Go to the Apress Forums site at http://forums.apress.com/. Cllck the New User link. </p> </div> </article> </div> </div> </div> <script type="text/javascript" async crossorigin="anonymous" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8519364510543070"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script> var docId = '286cd49c3b124d70beb8a3f89396a3e3'; var endPage = 1; var totalPage = 102; var pfLoading = false; window.addEventListener('scroll', function () { if (pfLoading) return; var $now = $('.article-imgview .pf').eq(endPage - 1); if (document.documentElement.scrollTop + $(window).height() > $now.offset().top) { pfLoading = true; endPage++; if (endPage > totalPage) return; var imgEle = new Image(); var imgsrc = "//data.docslib.org/img/286cd49c3b124d70beb8a3f89396a3e3-" + endPage + (endPage > 3 ? ".jpg" : ".webp"); imgEle.src = imgsrc; var $imgLoad = $('<div class="pf" id="pf' + endPage + '"><img src="/loading.gif"></div>'); $('.article-imgview').append($imgLoad); imgEle.addEventListener('load', function () { $imgLoad.find('img').attr('src', imgsrc); pfLoading = false }); if (endPage < 7) { adcall('pf' + endPage); } } }, { passive: true }); </script> <script> var sc_project = 11552861; var sc_invisible = 1; var sc_security = "b956b151"; </script> <script src="https://www.statcounter.com/counter/counter.js" async></script> </html>