[Zope] HELP: CST and python scripts

Aseem Mohanty aseem@neurobehavioralsystems.com
Mon, 22 Jul 2002 23:33:44 -0700


oh crap. i had a script that put in all form data into the session for 
error-tracking and I was inserting a file object in a file upload form 
to it too.

so how do I check if the object is a file or not in thte python script?

currently I do:

for key in form.keys:
    try:
        x = key.filename
    except AttributeError:
        data.set(...)

that seems to be the dumb way to go... is there any better way to do do it.
TIA
AM

Chris McDonough wrote:

>Are you attempting to store a reference to an open file (a "real"
>on-disk file) or to the REQUEST somewhere in your scripts?  If you
>clear all existing session objects from your session_data_mgr, close
>your browser, reopen it again, and then run *only* the lines that
>you have below via the Python Script's "Test" tab, do you get the
>same error?
>
>----- Original Message -----
>From: "Aseem Mohanty" <aseem@neurobehavioralsystems.com>
>To: <zope@zope.org>
>Sent: Monday, July 22, 2002 10:04 AM
>Subject: [Zope] HELP: CST and python scripts
>
>
>>Hi,
>>
>>I am doing the following in a PyScript:
>>
>>data = context.session_data_mgr.getSessionData()
>>data.set('upload_ok',1)
>>
>>and I get the following error (w/ traceback)
>>
>>Error Type: UnpickleableError
>>Error Value: Cannot pickle objects
>>
>>Traceback (innermost last):
>>  File F:\KANDIN~1\lib\python\ZPublisher\Publish.py, line 150, in
>>
>publish_module
>
>>  File F:\KANDIN~1\lib\python\ZPublisher\Publish.py, line 114, in
>>
>publish
>
>>  File F:\KANDIN~1\lib\python\Zope\__init__.py, line 158, in
>>
>zpublisher_exception_hook
>
>>    (Object: user_views)
>>  File F:\KANDIN~1\lib\python\ZPublisher\Publish.py, line 102, in
>>
>publish
>
>>  File F:\KANDIN~1\lib\python\Zope\__init__.py, line 172, in
>>
>commit
>
>>  File
>>
>f:\kandinsky\lib\python\Products\TransactionAgents\__init__.py, line
>54, in new_commit
>
>>  File F:\KANDIN~1\lib\python\ZODB\Transaction.py, line 233, in
>>
>commit
>
>>  File F:\KANDIN~1\lib\python\ZODB\Connection.py, line 345, in
>>
>commit
>
>>    (Info: (('Products.CoreSessionTracking.SessionData',
>>
>'SessionData'), '\x00\x00\x00\x00\x00\x00\x00\x1f', ''))
>
>>UnpickleableError: (see above)
>>
>>
>>What am I doing wrong?? Is it impossible to do what I want?? If it
>>
>cant
>
>>pickle it how is it handling it in when I do CST stuff in DTML??
>>
>>I cant really move to the default Zope sessions right now because
>>
>of
>
>>quite a bit of legacy stuff. Hopefully I will be able to find the
>>
>time
>
>>to do it later on.
>>
>>TIA
>>AM
>>
>>--
>>==================================================================
>> Aseem Mohanty
>> Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706
>> (R) 510 7696011 (M) 510 3014871 (O) 510 5279231
>>==================================================================
>> "I saw `cout' being shifted "Hello world" times to the left and
>>  stopped right there!!"                        -- Steve Gonedes
>>==================================================================
>>
>>
>>
>>
>>_______________________________________________
>>Zope maillist  -  Zope@zope.org
>>http://lists.zope.org/mailman/listinfo/zope
>>**   No cross posts or HTML encoding!  **
>>(Related lists -
>> http://lists.zope.org/mailman/listinfo/zope-announce
>> http://lists.zope.org/mailman/listinfo/zope-dev )
>>
>
>
>

-- 
==================================================================
 Aseem Mohanty							   
 Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 
 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231		  	
==================================================================								  	
 "I saw `cout' being shifted "Hello world" times to the left and  
  stopped right there!!"                        -- Steve Gonedes  
==================================================================