[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Using Zope
webmaster at zope.org
webmaster at zope.org
Mon Jun 14 19:29:41 EDT 2004
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx#2-62
To start, you need to write just one line of Python. Go to the
'FileLib' folder and create a 'Script (Python)' in that folder.
Give the script the id 'files' and click *Add and Edit*. Edit the
script to contain the following Python code::
## Script (Python) "files"
% Anonymous User - Nov. 4, 2003 10:52 am:
Thanks. We are learning about TAL and three pages into it we are confronted with Python.
Is there no way of doing this with TAL?
% Anonymous User - Nov. 10, 2003 11:00 pm:
No - there isn't (the short answer, but there are ways, it's just not the point). The point is to separate
the presentation from the actual logic. If you want to do logic in your templates, take a look at DTML. If
you are reading this to build a web application, you *will* need to know Python. It's not easy learning brand
new stuff, especially if you are in completely unfamiliar territory: take a break, plod through the reading
(some things will be explained in time), and if you are still confused join the mailing list and ask some
questions. I've found the best way is to play with it yourself. I admit that takes *a lot* of time, but you
really won't know it otherwise.
% Anonymous User - Nov. 20, 2003 9:35 am:
The ['file'] bit means only return items in the folder which are files (as opposed to dtml methods or
If you typed return container.objectValues() then you'd get everything in the folder, rather than just the
These are referencing the same variable/property/thing just using different syntax. Yes?
It would be nice to know what the ##'s are for.
If this is really a newbie tutorial then it wouldn't do any harm to spoon feed us a bit ;-P
% Anonymous User - Dec. 2, 2003 11:18 pm:
To answer your questions:
correct (but the capitalization is significant);
the lines that begin with # are comments which, in the case of zope's Python Scripts, are actually mildly
significant in ways that will be explained in later chapters. IMHO those lines should be left out of this
example, it's not necessary at this stage and it's just distracting.
% Anonymous User - Jan. 17, 2004 8:30 am:
could you explain the differences between
% ExileJedi - Jan. 18, 2004 3:25 pm:
Looks like objectValues() takes a list of types of things to return, and returns you a list of items that
match those types. The square brackets indicate a Python list, eg ['Fred','Barney','Wilma']. When you call
container.objectValues(['File']), you just want the objects that are considered "File"s. You could call
contain.objectValues(['File','Smurf']) if you also had objects that would be considered the "Smurf" type, as
opposed to the "File" type. If you instead call container.objectValues('File'), you can only get items of the
one "File" type that you have passed; you're passing a string rather than a list.
% Anonymous User - June 13, 2004 6:14 pm:
Starting Zope, you need to know everything at once. And that is *pretty* much. If you start with TAL and ZPT
(page templates), you need python to do this and somethin' else to do that. Even little "Hello World"-Apps
tend to be like 4 to 5 objects in Zope with at least 500 statements with non of them easy to remember. And
each part offers^H^H^H^H^H^H forces you with a new syntax.
% Anonymous User - June 14, 2004 7:29 pm:
I'll be the first to admit that the learning curve of zope is kinda steep at first. Just hang in there
because it does get easier once it all makes sense. Zope is very powerful and you can do many things with
just a few lines of python and a zpt. I can understand how difficult it could be for people with no
experience with web applications.
More information about the ZDP