On Mon, 31 Jul 2000, Marko MARKOVIC wrote:
> <dtml-in "showNSDetails(nsref=old_nsref)" start=query_start>
> <dtml-call "REQUEST.set('sdate','%s.%s.%s' %
> (ns_entrydate[8:],ns_entrydate[5:7],ns_entrydate[:4]))">
> <input type="text" name="new_nsentrydate" value="<dtml-var sdate>"
> size="10">
> </dtml-in>
> ns_entrydate is a field of my query.

What is the type of ns_entrydate by the time it is used in this method?

> Error Type: AttributeError
> Error Value: __getslice__
>   File D:\PROGRA~1\INTRAN~1\lib\python\DocumentTemplate\DT_Util.py, line
> 335, in eval
>     (Object: REQUEST.set('sdate','%s.%s.%s' %
> (ns_entrydate[8:],ns_entrydate[5:7],ns_entrydate[:4])))
>     (Info: REQUEST)
>   File <string>, line 0, in ?
>   File D:\PROGRA~1\INTRAN~1\lib\python\DocumentTemplate\DT_Util.py, line
> 174, in careful_getslice
>   File D:\PROGRA~1\INTRAN~1\lib\python\DateTime\DateTime.py, line 922, in
> __getattr__
> AttributeError: (see above)
> what's wrong?  Do you know where i can found information about zope erorrs,
> i want to know what means all these errors that we get?

Well, unfortunately there is no one place you can go to to find
out about zope errors.  In fact, I'm not sure I've seen the zope
error machinery documented anywhere (and documenting it involves
discussing exactly how the dtml interpretation machinery works, which
would be a good document all by itself <grin>). 

I can tell you what is happening in this case, I think.  You will note
that in the part of the traceback I quoted above the last Object listed
is your line that takes slices out of ns_entrydate ([n:m] is called
a 'slice' in Python jargon).  The error received is a 'getslice' error.
So it looks like the zope machinery got an error when it tried to
take a slice of ns_entrydate.

Since Python is an OO language and operators can be defined for any
object (well, more or less), whatever type ns_entrydate is *could*
have defined a slice operator.  It appears, however, that whatever type
it is, it does *not* define one, since __getslice__ is being flagged
as a non-existent attribute, and that is the attribute that the
object's class would have to define, as a function, in order to
implement the slice operator.

>From your code it appears you believe ns_entrydate is a string.  Is
it possible that it is instead some sort of datetime object?  If
so, then you'd have to call a function on it that returns the string
you want to parse, and call the slice operators on the returned
string.  But if it is a DateTime object, you can probably just call
functions to get exactly the strings you want without having
to slice anyway.

I hope this helps.


Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to