[Zope-dev] Object to string

Jason Spisak webmaster@mtear.com
Tue, 30 Mar 1999 07:48:01 -0500


Damn it didn't work.  I if I post again on this subject I get a free set
of steak knives. ;-)

I tried appending PARENTS[-1]. to the counter property to tell it that
the counter property I want is a property of the root folder.  But when
I try to save the changes to the DTML, it chokes.  Here's the code and
the traceback:

<!--# call "manage_addFolder(unique_id,unique_id,0,0,REQUEST)"-->
<!--# call
"manage_changeProperties(PARENTS[-1].counter=PARENTS[-1].counter+1)"-->
<!--# call
"manage_changeProperties(unique_id=_.str(PARENTS[-1].counter))"--> 

The counter property is type:int and set to 0.


<!--
Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line 877, in publish_module
  File lib/python/ZPublisher/Publish.py, line 590, in publish
    (Info: /staff/test/manage_edit)
  File lib/python/OFS/DTMLMethod.py, line 237, in manage_edit
    (Object: test)
  File lib/python/DocumentTemplate/DT_String.py, line 360, in munge
    (Object: test)
  File lib/python/DocumentTemplate/DT_String.py, line 376, in cook
    (Object: test)
  File lib/python/DocumentTemplate/DT_String.py, line 227, in parse
    (Object: test)
  File lib/python/DocumentTemplate/DT_Var.py, line 306, in __init__
  File lib/python/DocumentTemplate/DT_Util.py, line 290, in name_param
    (Info: ({'':
'&quot;manage_changeProperties(PARENTS[-1].counter=PARENTS[-1].counter+1)&quot;'},
'call', 1, 'name'))
ValueError: unpack sequence of wrong size

-->

Unpack sequence of wrong size?  Hmm, any suggestions?

All the best,

Jason Spisak
webmaster@mtear.com

Shaw, Howard wrote:
> 
> Actually, he's talking about simple folder property manipulation (ok,
> its not so simple), the Counter product is intended for visible counters
> incremented by webpage access.
> 
> However, if a Counter is added to the folder as 'countob', and marked to
> NOT check ips, then it can be handled thusly... (or should be able to,
> anyhow.)
> 
> <!--#call "countob.incrementCount(None)"-->
> <!--#var "countob.getCount()"-->
> 
> The parameter on the first line is normally '_', and can be passed in if
> you like. Not passing it in when the countob is marked to check ips will
> generate a traceback.
> 
> The only real reason I can think of for using a Counter object instead
> of the folder properties is to be able to use acquisition to make the
> names globally unique; but the same thing can be done by prepending
> PARENTS[-1]. to Pavlos' technique.
> 
> Also, if you use the counter object, you will have to set the "How many
> hits before saving to the database?" line to 0.
> 
> Pavlos' method was not recently added, but has been usable for a
> considerable period of time, and has the added advantage of not needing
> a Product added to support it.
> 
> Howard C. Shaw III
> Programmer/SysAdmin
> St. Thomas High School
> 
> > ----------
> > From:         Jason Spisak[SMTP:webmaster@mtear.com]
> > Sent:         Monday, March 29, 1999 6:12 PM
> > To:   Pavlos Christoforou; zope-dev@zope.org
> > Subject:      Re: [Zope-dev] Object to string
> >
> > Pavlos:
> >
> > I had forgotten about the recent addition of the counter object to our
> > arsenal of Zopeist tools. Shame on me.  Thanks for the heads-up!
> >
> > Jason Spisak
> > webmaster@mtear.com
> >
> > >
> > > On Mon, 29 Mar 1999, Jason Spisak wrote:
> > >
> > > > Oh, to follow up on my last post about turning an object to a
> > string
> > > > without leaving DTML, I have tried:
> > > >
> > > > <!--#var "str(_['ZopeTime'])"-->
> > > > <!--#var "str(ZopeTime)"-->
> > > >
> > > > All help welcome!
> > >
> > > <!--# var "_.str(ZopeTime())"--> will return a string representation
> > of
> > > the object.
> > >
> > > Alternatively you can generate unique object ids by adding a counter
> > > property to your containing folder (or root folder) and modify it
> > > everytime you generate a new object. For instance::
> > >
> > > <!--# call "manage_addFolder(unique_id,unique_id,0,0,REQUEST)"-->
> > > <!--# call "manage_changeProperties(counter=counter+1)"-->
> > > <!--# call
> > > "manage_changeProperties(unique_id='MyFolder'+_.str(counter))"-->
> > >
> > > Pavlos
> >
> > --
> > Jason Spisak
> > webmaster@mtear.com
> >
> > _______________________________________________
> > Zope-Dev maillist  -  Zope-Dev@zope.org
> > http://www.zope.org/mailman/listinfo/zope-dev
> >
> > (For non-developer, user-level issues, use the companion list,
> > zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
> >

-- 
Jason Spisak
webmaster@mtear.com