[Zope] Re: A few more dumb questions...

Dylan Reinhardt zope at dylanreinhardt.com
Sun Oct 19 17:48:24 EDT 2003


[forwarded to list]

On Fri, 2003-10-17 at 06:43, Ted holden wrote:
> Dylan,

First off, please post to the list if you have questions.  You may have
a question that someone else is better-qualified to answer and I
sometimes take weekends off. :-)


> The method you suggest of using a statement like:
> 
> 	thank_you = DTMLFile('thanks', globals())
> 
> and then returning self.thank_you from the function which loads the three 
> instance variables would work if I were to create a corresponding dtml file.

So far so good.  

> 
> The idea of returning a handle to an existing dtml file rather than trying to 
> code a dtml file in python certainly makes sense in cases in which the 
> desired response is either static or can be expressed in terms of dtml code 
> and available variables.  

Or even in cases where you would like to use new dtml variables.  Ex:

some_dtml = DTMLFile('path/to/file', globals())

def some_method(self, request):
    """docstring"""
    request['new_var'] = 'some_value'
    return some_dtml


> Is the thinking that virtually all desired responses can be expressed that 
> way, and there is never really a reason for having python code create  
> strings with html coding in them and return them?  

Basically.

Templating languages are the proper tool for assembling and returning
markup.  Any non-trivial logic you're going to do in this scenario is
done in Python.  The degree to which you observe this distinction will
determine, to large extent, the maintainability of your system.

But there are gray areas... I usually find <select> controls easier to
render in Python, as they tend to be logic-intensive.  YMMV.


> Another question:  Having a user browse to a web page which involves a python 
> object clearly creates the object.  

Not typically.  Some URLs call object-creating methods, most don't.

> What happens when the user either 
> switches his browser to some other web site or turns off his modem?

If the user isn't making a request, there is nothing for Zope to do.

>   Does 
> that somehow delete the object and, if not, does the developer need to 
> concern himself with garbage collection?

Since objects are not typically generated by usage, there is usually
nothing to collect.  

If you *are* generating new objects with your product, the answer is "it
depends."  In Python, objects are generally collected when they go out
of scope or have zero references.  But Zope's persistence machinery
makes this less certain.  If created objects are persisted, they should
never get collected without some explicit deletion.  Some non-persisted
objects might loiter around until next time you refresh their container
or restart the server.   

It might be helpful to hear more about why you believe you *are*
creating objects & maybe we could guess what's happening with them.


> What exactly is going on with the slash rather than a dot or pointer symbol 
> '->' in the form statement which activates the method directly from the form? 
> I noticed that using a dot '.' didn't work, and I've never seen that sort of 
> a usage in other languages.  In fact, executing class methods using dtml-call 
> statements requires a dot.  

When you're calling a method on the server side, use a dot.  When you're
generating a URL for the client to hit, use a slash.  

> 
> The developers' guide gave an example of executing class methods which looked 
> like this:
<snip>
> 
> The guide doesn't appear to give an example of the usage you described, which 
> is more useful.

What I described was for product code.  If you wanted to return one dtml
method from within another, just call it:

<dtml-var other_method>


> Last dumb question here:  Is Zope powerful enough to handle a large online 
> forum such as FreeRepublic or LibertyPost?

Probably... but you'll want a pretty serious setup to do it well.  Do
some searching on ZEO and "high availability" for past discussion.

HTH,


Dylan




More information about the Zope mailing list