[Zope-dev] Zope 2.5.0 Sessions Testing

2002-01-08 Thread Chris Withers

Hi,

Trying to test a URL in a unittest.py test using code as follows:

apply(Site.restrictedTraverse('/folder/cmfsite/skinmethod'),params)

Now, skinmethod uses the new Zope 2.5.0 sessioning:

session=context.REQUEST.SESSION
session.set('key','value')

but the BeforeTraversal hook doesn't seem to kick in when restrictedTraverse is
used :-(

We always get an AttributeError on SESSION.

How should we fix this and go about testing this method properly?

cheers,

Chris

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



Re: [Zope-dev] Zope 2.5.0 Sessions Testing

2002-01-08 Thread Chris McDonough

Your problem is that a REQUEST is not created without the
publisher.  This is a particularly annoying and unsolved
problem when doing tests.  Your options are to use import
Zope; Zope.test('/some/method/name') which has all sorts of
bad side effects, or to dummy up the environment as much as
possible via things like makerequest, etc. enough for the
method to work.  I can't say exactly what's needed for that
in this case, I'd need to mess with it endlessly (luckily
that's your job in this case ;-)

Sorry,

- C

On Tue, 08 Jan 2002 10:16:16 +
 Chris Withers [EMAIL PROTECTED] wrote:
 Hi,
 
 Trying to test a URL in a unittest.py test using code as
 follows:
 
 apply(Site.restrictedTraverse('/folder/cmfsite/skinmethod'),params)
 
 Now, skinmethod uses the new Zope 2.5.0 sessioning:
 
 session=context.REQUEST.SESSION
 session.set('key','value')
 
 but the BeforeTraversal hook doesn't seem to kick in when
 restrictedTraverse is
 used :-(
 
 We always get an AttributeError on SESSION.
 
 How should we fix this and go about testing this method
 properly?
 
 cheers,
 
 Chris
 
 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists - 
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope )


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



Re: [Zope-dev] Zope 2.5.0 Sessions Testing

2002-01-08 Thread Chris Withers

Chris McDonough wrote:
 
 Your problem is that a REQUEST is not created without the
 publisher.  This is a particularly annoying and unsolved
 problem when doing tests.  

Is it solved in Zope 3?

 Your options are to use import
 Zope; Zope.test('/some/method/name') which has all sorts of
 bad side effects, 

Never even knew that existed. Where's it documented? What does it do? What are
the side effects?

 or to dummy up the environment as much as
 possible via things like makerequest, etc. enough for the
 method to work.  I can't say exactly what's needed for that
 in this case, I'd need to mess with it endlessly (luckily
 that's your job in this case ;-)

Well, we're using makerequest, and the following code seems to be keeping the
SESSION stuff working:

session = app.unrestrictedTraverse('/session_data_manager').getSessionData
app.REQUEST.set_lazy('SESSION', session)

Is that the 'right thing' to do?

cheers,

Chris

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



Re: [Zope-dev] Zope 2.5.0 Sessions Testing

2002-01-08 Thread Chris McDonough

 Is it solved in Zope 3?

Zope3 is more modular, so probably.  Though I dont think
it's a goal.

 Never even knew that existed. Where's it documented? What
 does it do? What are
 the side effects?

Zoper.test as a side effect it commits a transaction.
It's documented in the dev guide as ZPublisher.Zope,
sorry.

 Well, we're using makerequest, and the following code
 seems to be keeping the
 SESSION stuff working:
 
 session = app.unrestrictedTraverse('/session_data_manager').getSessionData
 app.REQUEST.set_lazy('SESSION', session)
 
 Is that the 'right thing' to do?

That looks about right...

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