[Zope] Continuation of my Trials and Tribulations with creating a ZClass Product

Bill Hewitt wphewitt at comcast.net
Mon Aug 25 22:21:11 EDT 2003


First off, thanks to everyone for answers to problems I had trouble
explaining.....  This has been extremely painful to understand so far.

Anyway, the query code I have below works up to the return....
It returns the correct stylesheet, but I need to know how to insert a
standard template in the Style Sheet ZClass (based on DTMLDocument) so I
dont have to edit/add the view every time I create an instance.
(manage_clone, manage_add, DTMLFile ?????) Looking into DTMLDocument, I
see how to do it in python, but I dont understand how to apply that to
python script.....

Can someone show me an example of how to do this?

WPH

My code so far is below:

---------
---------
Python code used to create the Style Sheet Instance
---------

# Add a new instance of the Style Sheet ZClass
request = context.REQUEST
from DateTime import DateTime
ts=DateTime().strftime('%Y%m%d%H%M%S')
id=str(ts)
instance = container.StyleSheet.createInObjectManager(id, request)


##################################################################
### I would assume I need to add the Style Sheet document_src here
##################################################################


# *****************************************************************
# Perform any initialization of the new instance here.
# For example, to update a property sheet named "Basic" from the
# form values, uncomment the following line of code:
instance.propertysheets.Base.manage_editProperties(request)
instance.propertysheets.Custom.manage_editProperties(request)
instance.propertysheets.a.manage_editProperties(request)
instance.propertysheets.body.manage_editProperties(request)
instance.propertysheets.h1.manage_editProperties(request)
instance.propertysheets.h2.manage_editProperties(request)
instance.propertysheets.h3.manage_editProperties(request)
instance.propertysheets.h4.manage_editProperties(request)
instance.propertysheets.h5.manage_editProperties(request)
instance.propertysheets.p.manage_editProperties(request)

# *****************************************************************

if redirect:
    # redirect to the management view of the instance's container
    request.RESPONSE.redirect(instance.aq_parent.absolute_url() +
'/manage_main')
else:
    # If we aren't supposed to redirect (ie, we are called from a
script)
    # then just return the ZClass instance to the caller
    return instance


---------
---------
Python Code used for the building the public view....
----------

DATE=DateTime().dd()
MONTH=DateTime().Month()
DAY=DateTime().Day()
YEAR=DateTime().year()

## Build a Date/Time Output to Match variations on "title" String
Formats in Style Sheet Properties
DAYMONTHDATEYEAR="%s %s %s %s" % (DAY, MONTH, DATE, YEAR)
MONTHDATEYEAR=" %s %s %s" % (MONTH, DATE, YEAR)
DAYMONTHYEAR="%s %s  %s" % (DAY, MONTH, YEAR)
DAYMONTHDATE="%s%s%s " % (DAY, MONTH, DATE)
DAYDATEYEAR="%s  %s %s" % (DAY, DATE, YEAR)
MONTHDATE=" %s %s " % (MONTH, DATE)
DAYMONTH="%s %s  " % (DAY, MONTH)
DAYDATE="%s  %s " % (DAY, DATE)
DATEYEAR="  %s %s" % (DATE, YEAR)
DAYYEAR="%s   %s" % (DAY, YEAR)
MONTHYEAR=" %s  %s" % (MONTH, YEAR)
MONTHKEY=" %s  " % (MONTH)
DATEKEY="  %s " % (DATE)
DAYKEY="%s   " % (DAY)
YEARKEY="   %s" % (YEAR)
DEFAULT="DEFAULT"


## Look for Day Year (ie - Monday 2003) in Style Sheet (a DTML Document
subclass)
## NOTE THAT StyleBook is a container (subclass of Folder)
for stylesheet in container.StyleBook.objectValues(['Style Sheet']):
 if stylesheet.title == DAYYEAR:
         return stylesheet()

#### Here I am returning the proper stylesheet instance - :)
#### But how do I template the document_src in the Style Sheet ZClass 
#### to keep from having to rewrite it for every instance I create?
#### (like the default view in DTML Document) 




More information about the Zope mailing list