[Zope-dev] unsliceable object

Leonardo Rochael Almeida leo@hiper.com.br
Wed, 29 Aug 2001 16:00:53 -0300


On Wed, Aug 29, 2001 at 05:19:40PM +0200, Homan Els wrote:
> Hi,
> 
> Does somebody know why, I am getting an error on this function (inside a
> zope-product):
> 
> [sniped code below]
> 
> The error message is:
> 
>              Error Type: TypeError
>              Error Value: unsliceable object
> 

It looks much more like a python error than a Zope error per se. Besides,
without a traceback or at least a line number where the error ocurred, it is
really hard do divine where the error could have happened.

But let me give you some hints about your code below

>  def CreateProcessDirs(self,proposalid,runid):
>          for i in self.objectValues():
>               id=i.id
>               if callable( id ):
>                  id = id()
>               RequestDir=os.path.join(dir,proposalid,runid,'process',id)

here, instead of the loop above, you could just have said

           for id in self.objectIds():
                RequestDir=os.path.join(dir,proposalid,runid,'process',id)

besides objectIds and objectValues, there is also objectItems, which  you
can use like:

for id, object in self.objectValues():
    ... do something with id and/or object ...

>          if os.path.exists(RequestDir):
>             print 'pathname ( file or directory) exist',path
>          else:
>           os.system('mkdir -p '+RequestDir)

here you could use python's own makedirs, to obtain the 'mkdir -p' effect,
like:

            os.makedirs(RequestDir)

that would also make your code more portable, as Windows mkdir doesn't like
-p much...

>           print "Make Directory: ",RequestDir
>       return i


None of those tips should solve your problem, however. In any case, try to
look at the html source of the page that had the error to give-us a
traceback so that we can help you better. 

    Regards, leo