[Zope-CMF] Automatic ID generation -- > Title Got it!

Ignacio Valdes ivaldes@hal-pc.org
Mon, 23 Apr 2001 22:37:26 -0500


Ignacio Valdes wrote:

> Timothy Wilson wrote:
>
> > On Mon, 23 Apr 2001, Ignacio Valdes wrote:
> >
> > > I've tried creating a python script called generateID with the following one line:
> > >
> > > return "%s" (DateTime().timeTime())
> > >
> > > I think this is on the right track, but it returns the same number every time.
> > > Smelling the finish line...
> >
> > Have you tried ZopeTime()?
> >
> > -Tim
>
> Thanks, came across this:
>
> <dtml-call "REQUEST.set('ts', ZopeTime().strftime('%Y%m%d%H%M%S'))">
>
> from a tip on the zope site:
> http://www.zope.org/Members/Bill/Documentation/AutoGenID
>
> But when I stick it into the right place in folder_factories:
>
>        <input type="text" name="id" value="<dtml-var "REQUEST.set('ts',
> ZopeTime().strftime('%Y%m%d%H%M%S'))">" size="50">
>
> It comes back with 'None' in the id field on screen.  Hmm, don't know the right
> syntactic sugar for this.  -- IV
>

I've got it!  I finally had to break down and figure out Python syntax.  Got pretty far
without knowing anything. Generates the id in human-readable number string of date-time
format. You stick the following into folder_factories and enjoy! Here you go:

 <dtml-call "REQUEST.set('ts', ZopeTime().strftime('%Y%m%d%H%M%S'))">
 <dtml-with ts>
 <tr valign="top">
  <td> <br> </td>
  <td colspan="2"> <strong> Folder Name or Resource Title: </strong>
       <input type="text" name="id" value="<dtml-var ts>" size="50">
       <input type="submit" value="Add"> </td>
 </tr>
 </dtml-with>

Yes!

-- IV