DSM

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Problem with constructTransientObjectContainer

    6 answers - 2068 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have an external method that is trying to create a Transient Container in a 'temp_folder', as follows:
    def BuildGarbageCollector(self):
    folder = self.restrictedTraverse('Coz/TempImages') # Coz/TempImages already exists
    folder.constructTContainer(self, id='GarbageCollector', timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')
    and I get the following error:
    Traceback (innermost last):
    Module ZPublisher.Publish, line 115, in publish
    Module ZPublisher.mapply, line 88, in mapply
    Module ZPublisher.Publish, line 41, in call_object
    Module FS.DTMLMethod, line 144, in __call__
    - <DTMLMethod at /Coz/WUI/tst>
    - URL:
    - Physical Path: /Coz/WUI/tst
    Module DocumentTemplate.DT_String, line 476, in __call__
    Module DocumentTemplate.DT_Let, line 75, in render
    Module DocumentTemplate.DT_Util, line 196, in eval
    - __traceback_info__: document_id
    Module <string>, line 1, in <expression>
    Module , line 232, in __call__
    - __traceback_info__: (('tst',), {}, None)
    Module /apps/zope/Extensions/cozumo.py, line 212, in ProcessControl
    Module <string>, line 1, in ?
    Module /apps/zope/Extensions/cozumo.py, line 219, in subtst
    Module /apps/zope/Extensions/cozumo.py, line 2473, in BuildGarbageCollector
    AttributeError: constructTContainer
    If I change the external method as follows (remove the reference to 'folder'):
    constructTContainer(self, id='GarbageCollector', timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')
    There is no error, but the TC is created in the wrong folder. I can manually (thru the ZMI) add a TC to the TempImages folder, but I can't create one programmatically.
    Can anyone point me in the right direction?!
    Thanks,
    Jonathan
    Zope maillist - Zope (AT) zope (DOT) org
    ** No cross posts or HTML encoding! **
    (Related lists -
    )
  • No.1 | | 2424 bytes | |

    folder.manage_addProducts
    ['Transience'].constructTContainer might work (assuming
    "constructTContainer" is the right constructor name, I
    didn't check).
    - C

    Jun 20, 2006, at 9:39 AM, Jonathan wrote:

    I have an external method that is trying to create a Transient
    Container in a 'temp_folder', as follows:

    def BuildGarbageCollector(self):
    folder = self.restrictedTraverse('Coz/TempImages')
    # Coz/TempImages already exists
    folder.constructTContainer(self,
    id='GarbageCollector', timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')
    --
    and I get the following error:

    Traceback (innermost last):
    Module ZPublisher.Publish, line 115, in publish
    Module ZPublisher.mapply, line 88, in mapply
    Module ZPublisher.Publish, line 41, in call_object
    Module FS.DTMLMethod, line 144, in __call__
    - <DTMLMethod at /Coz/WUI/tst>
    - URL:
    - Physical Path: /Coz/WUI/tst
    Module DocumentTemplate.DT_String, line 476, in __call__
    Module DocumentTemplate.DT_Let, line 75, in render
    Module DocumentTemplate.DT_Util, line 196, in eval
    - __traceback_info__: document_id
    Module <string>, line 1, in <expression>
    Module , line 232, in __call__
    - __traceback_info__: (('tst',), {}, None)
    Module /apps/zope/Extensions/cozumo.py, line 212, in ProcessControl
    Module <string>, line 1, in ?
    Module /apps/zope/Extensions/cozumo.py, line 219, in subtst
    Module /apps/zope/Extensions/cozumo.py, line 2473, in
    BuildGarbageCollector
    AttributeError: constructTContainer
    --
    If I change the external method as follows (remove the reference to
    'folder'):
    constructTContainer(self,
    id='GarbageCollector', timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')
    There is no error, but the TC is created in the wrong folder. I
    can manually (thru the ZMI) add a TC to the TempImages folder, but
    I can't create one programmatically.

    Can anyone point me in the right direction?!

    Thanks,

    Jonathan

    Zope maillist - Zope (AT) zope (DOT) org

    ** No cross posts or HTML encoding! **
    (Related lists -
    )

    Zope maillist - Zope (AT) zope (DOT) org

    ** No cross posts or HTML encoding! **
    (Related lists -

    )
  • No.2 | | 1118 bytes | |

    Message
    From: "Chris McDonough" <chrism (AT) plope (DOT) com>
    folder.manage_addProducts ['Transience'].constructTContainer
    might work (assuming "constructTContainer" is the right
    constructor name, I didn't check).

    Chris, thanks for the idea - I tried it, but it generated the error:
    BadRequest: ('Empty or invalid id specified', <Folder at /Coz/WUI>)

    After looking at the Transience.py source I found the answer: Instead of
    passing 'self' as the first parameter I passed the folder object instead.
    The worked because constructTContainer does:
    (id, ob)

    So the final solution was:

    folder = self.restrictedTraverse('Coz/TempImages')
    constructTContainer(folder, 'GarbageCollector',
    timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')

    Thanks again for the help, it got me thinking in the right direction!

    Jonathan

    Zope maillist - Zope (AT) zope (DOT) org

    ** No cross posts or HTML encoding! **
    (Related lists -

    )
  • No.3 | | 428 bytes | |

    Jonathan wrote:

    folder = self.restrictedTraverse('Coz/TempImages')
    constructTContainer(folder, 'GarbageCollector',
    timeout_mins=10, limit=0,
    delNotification=BASEFLDER+'DeleteTempImage')

    Be careful, I see a lot of hints in there that make me nervous. I'm of
    the opinion that if you think you need to use a TC, you're probably
    doing something wrong

    Chris
  • No.4 | | 1943 bytes | |

    Message
    From: "Chris Withers" <chris (AT) simplistix (DOT) co.uk>
    To: "Jonathan" <dev101 (AT) magma (DOT) ca>
    Cc: "Chris McDonough" <chrism (AT) plope (DOT) com>; <zope (AT) zope (DOT) org>
    Sent: Wednesday, June 21, 2006 6:25 AM
    Subject: Re: [Zope] Problem with constructTContainer -
    Resolved

    Jonathan wrote:
    >>

    >folder = self.restrictedTraverse('Coz/TempImages')
    >constructTContainer(folder, 'GarbageCollector',
    >timeout_mins=10, limit=0,
    >delNotification=BASEFLDER+'DeleteTempImage')
    >

    Be careful, I see a lot of hints in there that make me nervous. I'm of the
    opinion that if you think you need to use a TC, you're probably doing
    something wrong

    The use case: the zodb contains small image objects which need to have a
    custom overlay (done with PIL) before being presented to the user. Each
    overlay is unique. Each customized image is only shown to a single user
    once, then it is discarded. In order to eliminate many writes to the zodb
    (disk), I have decided to put the customized images into a temporary folder
    (RAM). In order to delete the customized images I have created a TC to act
    as a 'GarbageCollector'. Whenever a customized image is written to the
    temporary folder, an entry containing the image object id is placed in the
    TC. When the TC 'times-out' an entry a script (external method) acquires
    the object id from the TC entry and deletes the customized image from the
    temporary folder.

    This seems to be working so far ;-)

    What 'hints' are making you nervous? Is there a 'better' way to do this?

    Jonathan

    Zope maillist - Zope (AT) zope (DOT) org

    ** No cross posts or HTML encoding! **
    (Related lists -

    )
  • No.5 | | 273 bytes | |

    Hi Jonathan
    user once, then it is discarded. In order to eliminate many writes to
    the zodb (disk), I have decided to put the customized images into a
    temporary folder (RAM).
    Can't you just put the images in the TC and let them expire by themselves?
  • No.6 | | 942 bytes | |

    Message
    From: "Jean Jordaan" <jean (AT) upfrontsystems (DOT) co.za>
    To: <zope (AT) zope (DOT) org>
    Sent: Thursday, June 22, 2006 11:32 AM
    Subject: Re: [Zope] Problem with constructTContainer -
    Resolved

    Hi Jonathan
    >
    >user once, then it is discarded. In order to eliminate many writes to
    >the zodb (disk), I have decided to put the customized images into a
    >temporary folder (RAM).
    >

    Can't you just put the images in the TC and let them expire by
    themselves?

    I need to be able to allow client browsers to access the images via an html
    <img src=""tag.

    I didn't know how to construct a url to get at the image objects within a
    TC (can this be done?)

    Thanks,

    Jonathan

    Zope maillist - Zope (AT) zope (DOT) org

    ** No cross posts or HTML encoding! **
    (Related lists -

    )

Re: Problem with constructTransientObjectContainer


max 4000 letters.
Your nickname that display:
In order to stop the spam: 2 + 1 =
QUESTION ON "DSM"

EMSDN.COM