[Zope] Newbie: Build Object Names

Dieter Maurer dieter@handshake.de
Mon, 17 Jul 2000 10:23:34 +0200 (CEST)


Terry Babbey writes:
 > I find I am really struggling trying to learn the syntax and variables for
 > the various commands. Would an understanding of Python help me to understand
 > the Zope
 > commands better and is there good documentation for Python that does not
 > expect the reader to have a large background knowledge?
I do not think that an understanding of Python will help you much
with DTML (of cause, it would not harm but help, but not too much).

In DTML, you only have to do with Python expressions:
you see them enclosed in "...".

Python expressions are a small part of Python (which is small by itself!).
You have:

  the usual arithmetic operators: +, -, *, /, %

  strings: enclosed in '...', '''...''' or "...", """..."""
          (the two latter forms will not work in DTML!)

  lists: [], [1,2,3], ['a','b','c','d']
           with methods "append(element)" and "insert(where,element)"
	   (and some more)

  tuples: (), (1,), (1,2,3,), ('a','b')
          with '+' as concatenation and [i] for subscription

  dictionaries: {}, { 1: 'a'}, { 'a' : 'AAA', 'b' : 'BBB',}
          i.e. sets of key/value pairs.
	  They support "[key]" for subscription.
	  They have methods "update(dict)" and "clear()",
	  "get(key,default=None)".


  functions: called by "function(argumentlist)", e.g.
          "int('0')", "sql_method(user='dieter',city='St. Ingbert')
	  Arguments can be positional or keyword.
	  Arguments can have default values and then be omitted
	  in function calls.

  instances (of classes):
          with the infix '.' operator for attribute/method
	  access: e.g. "[].append(1)", "[].insert(0,'a')",
	  "object.id".

	  Functions of instances are called methods.
	  They have as implicit (on call) first
	  argument the object they belong to.

  exceptions:
          raised with "raise" and catched
	  with
	    try: 
	      protected code
	    except:
	      exception handling

	  uncaught exceptions produce the tracebacks you
	  sometimes see in Zope error pages.


Strings, lists, and tuples together are called sequences.
They are '+' as concatenation, '*' as repetition and '[i]' as
subscription. You can use the infix operator 'in' to test
for containment. The "len" function can be used to determine
the number of elements.


Like all object oriented systems, Python relies heavily on
object classes and extension modules. They are much more
voluminous and complex than Python itself.

One such framework (set of intertwined modules and classes)
is Zope. It, itself, is far more complex than the complete
Python. Especially, its namespace handling and the powerfull
acquisition adds significantly to the complexity.
If you need them, you must get aquainted with the methods of
the various Zope objects (folders, images, DTML methods, DTML
documents, ...), too.
The namespace object "_" provides much of the interface to
Python. Look at its documentation in the DTML guide.


In general, you do not need all arguements of DTML tags
or Zope objects. You should have a rough feeling, what
is there and go into details when you need it.


Dieter