[Zope] Re: Style guide for ZPT?

Tres Seaver tseaver at zope.com
Sat Mar 19 20:30:18 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Winkler wrote:
| Hiya,
|
| I've been asked to come up with some formal coding standards for
| my employer's Zope projects.
|
| For Python code, I just use the relevant PEPs (maybe with a few
| addendums), but I'm wondering if anything similar exists for ZPTs so I
| don't have to completely reinvent the wheel.
|
| Validating as XHTML is a good first step, but that can still leave you
| with random indentation, absurdly long TALES statements, ugly loop
| idioms, use of "tal:replace" vs. use of macros, whether or not "tal:"
| and "metal:" attributes should be on the same line as vanilla XHTML
| attributes, etc.
|
| The first of those is easy to fix with Tidy, but the others are
| necessarily zope-specific.
|
| I seem to recall there was a ZPT style guide for Plone at some point,
| but it's resisting all my best efforts at googling - I get hints that
| something existed but has vanished from the net.  For example:
| http://www.tchezope.org/traducoes/lp/ingles/7
| "Temporarily discontinued, out of date"
|
| If nothing turns up, I'll probably just write my own based on what I
| like and publish it somewhere, maybe on zopewiki.org.  (But not till
| after my impending vacation...)

Here's what I would start with:

~  - No 'metal:' or 'tal:' attributes on the same line as any other
~    attribute (normal HTML, or even in the same namespace).

~  - On a given element, "normal" HTML attributes should come first, then
~    'metal:' attributes, then 'tal:' attributes.

~  - 'tal:' attributes should come in their "execution order", per
~    the TAL spec:

http://www.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4/#oop

~  - 'tal:' attributes with multiple bindings ('tal:define',
~    'tal:attributes') should have each binding on a separate line,
~    with the second and following bindings starting at the same column
~    as the first binding).

~  - Python expressions which can't be fit onto a single line, using
~    the guidelines above, are definitely suspect:  consider moving that
~    logic out into a Python script, and calling it by path expression.

Tres.
- --
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCPNIqGqWXf00rNCgRAuhCAJsE6fJpJjqybEgK427Uh8EzDtL1iQCgna5L
few+dvs62NCXmSIC5tYASXg=
=i0uz
-----END PGP SIGNATURE-----



More information about the Zope mailing list