[Zope] New Zope user...how to create lists...and what happens to files

Michel Pelletier michel@digicool.com
Thu, 27 May 1999 09:51:09 -0400


> -----Original Message-----
> From: steve@hosys.com [mailto:steve@hosys.com]
> Sent: Wednesday, May 26, 1999 11:41 PM
> To: zope@zope.org
> Subject: [Zope] New Zope user...how to create lists...and what happens
> to files
> 

<snip>

> 
> --------------------------------------------------------------
> --------------
> --------
> doAddPosting (this is the document that takes the variables from the
> AddPosting
> document, creates a new "applicant record" and stuffs the 
> data into the new
> rec,
> and calls index_html which displays the updated list
> --------------------------------------------------------------
> --------------
> --------
> 
> <!-- Create an instance of an Applicant Object and set it's
> variables/relations to -->
> <!--#var submit_date-->
> <!--#var applicant_id-->
> <!--#var synopsis-->
> <!--#var resume-->
> <!--#var submitter-->

BTW, here your not actually creating anything, just rendering variable
passed into this method.

> 
> <!--Clear?-->

Well here is where you have great freedom.  You can use a ZSQL method to
insert your applicant into a table, or you can use a ZClass and
instanciate an 'applicant' object.  You could also use an external
method to write the information out to disk so you can use it in another
system (however if that other system supported SQL it would be
preferable to use SQL) or you can use ZTables, a commercial product from
Digital Creations.

Of these I would recommend ZTables first, and SQL second.  I would not
recommend instanciating a ZClass because they are not designed to hold
vast quantities of relational like information, they are good at
abstracting out new Zope objects.  Writing to a filesystem is a pretty
ugly hack.

  Assuming you want to go the cheaper way (unless you pay more for your
SQL server than ZTables costs (BTW, when you buy ZTables you get the
source code, it's just not open and you can't redistribute it in any
way)) then you probably will install a SQL server, create a Database
Connection to that server, and then write a ZSQL method an 'INSERT' SQL
operation in it.  Then you can just call the method at this point.  Note
that your method must be looking for the above variables (in it's
Arguments field) and that the above arguments should be valid, otherwise
it will fail with an exception, so you may want to sanity check all your
variables in some <!--#if--><!--#/else--> blocks.

<!--#if "not submitter"-->
	<h1>You got a name, right?</h1>
<!--#else-->
	<!--#call thisIsMyZQLMethodThatInsertsAnApplicant-->
<!--#/if-->

> 
> <!--#var index_html-->
> 

Why are you calling this here?  It looks like you just want it to show
the user information in a table, when you showed the information above.
Perhaps you should factor this out and make the display of all users or
a range of users a different component, and keep your component that
adds records a simple component that just adds records.  Overburdening
one system with two functions is a recipie for bad design.

Also, I wouldn't call a method in this context index_html, index_html
has the special feature of being the default method called of an object
(like a folder) if you don't specify one.  Unless you plan on making
this method also the default method, *and* you want to call it here,
then go for it, otherwise I'd call it something like showTabulatedUsers
or such.

-Michel

> 
> --------------------------------------------------------------
> --------------
> ---------
> index_html  should build a table from a list pf recoreds (instances)
> --------------------------------------------------------------
> --------------
> ---------
> 
> 
>