My esteemed colleague invited me to participate in this blog, in the hopes that more new users don’t get burned by Zope.
I have been using Zope professionally for 3 years, and built a custom CMS on it for a technology publication (http://www.ebizq.net/). Zope allows you to rapidly (almost instantly) build a complex data-driven website, with nothing more than a web browser.
Now, the problem with instant website development is a lot like going out with your buddies in college. You may think you’re the most eloquent genius on the planet, but when you look at photos 2 years later, you wonder why exactly you decided to sleep in the bathtub with the giant stuffed gorilla.
My point is, that if you’re not careful with Zope you will get burned. However, the only way to learn how to be careful, is to get burned along the way. Severely.
So below are a few gotchas that I ran into face first along my travels with Zope. May these hard leaned lessons ease yours.
1) Ignore the Zope Book, don’t use DTML
All the examples are in DTML, which just stinks. Use Page Templates, they’re more understandable, and you can preview the basic idea in most WYSIWYG editors.
2) Always specify parameters to ZSQL Methods
call ZSQL methods by using python (tal:content=”python:context.mySQLmethod(user_id=request.get(’user_id’))” for example in page templates). Will save you hours when trying figure out why a SQL method returns the entire database (don’t do this: tal:content=”context/mySQLmethod”). Granted when you feel like you know what you’re doing, you will be tempted to take that shortcut, but it’s impossible to tell that that method expects a user_id, and you will forget at some point.
3) Pass objects to Page Templates via the options mechanism, don’t stuff everything into the REQUEST object
Prevent others from hunting through python scripts trying to find miscellaneous request.set methods. You will also forget at some point just what that page template expects.
4) Don’t bother with METAL
It’s just a headache, filling slots and defining them, plus it’s so much harder to read. It’s easier to be creative with acquisition:
/site index_html as a Page Template, use tal:content=”context/body”
/site/section body as either a Page Template or Python Script (but not DTML, see 1), then simply call www.site.com/section/ and your body will be rendered in the template.
5) Don’t put any site code in the root
It will only cause headaches as you will have a hard time trying to figure out why some goofball object is being acquired.
6) Put each site in it’s own folder under the root
/sitea/
/siteb/, etc… It will make things easier. If you have a few sites that share some common elements, make a folder and put both sites in there
/sites/sitea/
/sites/siteb/
If you have a method like showUsers, put that in /sites/
Guest Post by Jim Kuttergroup.com
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment