Re: [Zope-dev] brain.getObject and traversal

2005-04-01 Thread Chris Withers
Florent Guillaume wrote:
Well of course no, but I never had to check a getObject() against 
Unauthorized. Maybe it's because I only use it in a CMF setting where 
unaccessible objects are filtered anyway.
Maybe,  but CMF isn't the only use of Zope ;-)
OTOH you're a bit excessive in your Whole array of possible distinct 
errors.
Not really. I want to know the difference between:
- unauthorized: my object has problems and probably needs its 
permissions fixing

- not found: I want to know why an object is indexed that doesn't exist 
and fix that

- other random error: damn, big problems with catalog, need to post to lists
In all three cases, knowing the type of error and getting a sensible 
traceback in my logs is infinitely more useful than a random...

AttributeError: None has no attribute x
...error at some point in the future, which may be no-where near the 
actual catalog search.

cheers,
Chris
--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] brain.getObject and traversal

2005-04-01 Thread Florent Guillaume
Florent Guillaume  [EMAIL PROTECTED] wrote:
  Unauthorized in getObject is out of the question, that would be new 
  behaviour.
  
  Well, in 2.8, new behaviour is expected, right?
  I really passionately believe that we should not be returnining None in 
  Zope 2.8, and since 2.8 hasn't quite hit beta yet I'm very keen to see 
  it fixed asap.
  
  Any objections?
 
 I'm ok for 2.8. I'll look at it.

Is everyone ok with returning
 - the object if it can be accessed
 - raise Unauthorized if it can't be accessed
 - raise NotFound if it's not there
and never return None ?

I'll change that before tomorrow, for 2.8a2.

(I'll change NotFound in Traversal.py to a real exception instead of a
string too, I thought we'd killed those.)

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: [Zope2.8a2] ...to be released by tomorrow....

2005-04-01 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

yuppie wrote:

 Andreas Jung wrote:
 
 I am planning to make the release tomorrow (Saturday afternoon (German
 time :-)). So please make
 your final fixes very soon or cry out loud STOP if there are any show
 stoppers.
 
 I'd really like to see http://www.zope.org/Collectors/Zope/1460 resolved
 before the release:
 
 1.) AFAICS this bug is easy to fix.
 
 2.) It makes at least CMFDefault sites unusable, deterring CMF users
 from testing Zope 2.8.
 
 I could merge the fix from the 2.7 branch myself, but I hate to check in
 code I don't understand completely. Maybe Tres or Jim can have a look at
 this? Or at least review the checkin if I do it myself?

Jim and I fixed this last week:

  http://svn.zope.org/Zope/?rev=29712sortby=dateview=rev

I will resolve the issue.


Tres
- --
===
Tres Seaver[EMAIL PROTECTED]
Zope Corporation  Zope Dealers   http://www.zope.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCTWYcGqWXf00rNCgRAmJ7AJ9Z9pwnCROMi52HPj/Zu/PCrP6Z7gCfYpOy
js/ESXDFYzn4mdoiLKiXGz4=
=q4fr
-END PGP SIGNATURE-

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


[Zope-dev] Re: brain.getObject and traversal

2005-04-01 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Florent Guillaume wrote:
 Florent Guillaume  [EMAIL PROTECTED] wrote:
 
Unauthorized in getObject is out of the question, that would be new 
behaviour.

Well, in 2.8, new behaviour is expected, right?
I really passionately believe that we should not be returnining None in 
Zope 2.8, and since 2.8 hasn't quite hit beta yet I'm very keen to see 
it fixed asap.

Any objections?

I'm ok for 2.8. I'll look at it.
 
 
 Is everyone ok with returning
  - the object if it can be accessed
  - raise Unauthorized if it can't be accessed
  - raise NotFound if it's not there
 and never return None ?
 
 I'll change that before tomorrow, for 2.8a2.
 
 (I'll change NotFound in Traversal.py to a real exception instead of a
 string too, I thought we'd killed those.)

We really need to follow a deprecation-style model here:  the risk of
breaking major third party components is pretty high.

Could we use a module-scope global, settable from zope.conf, to indicate
which strategy to use?  It should (for 2.8) default to raising, but we
need to be prepared for an onslaught of breakage reports.

The CHANGELOG should highlight the change, and include the zope.conf
snippet required to restore the old behavior.  We could add a
deprecation warning (if that entry is activated), that the old-style
option would be removed in 2.10.


Tres.
- --
===
Tres Seaver[EMAIL PROTECTED]
Zope Corporation  Zope Dealers   http://www.zope.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCTWhlGqWXf00rNCgRAsZ8AKChKf3YvASZ1jmJGeeN4Y3PN9/0rACbBRgi
nGNOyVocQywRINr8FnyNTHg=
=cUAs
-END PGP SIGNATURE-
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] post publishing hook

2005-04-01 Thread Florent Guillaume
I really could use a post publishing hook.
Standard use case: delay indexing at the end of the request to only do 
it once per object even if the object has been modified 4 times.

Today there's the REQUEST._hold() hack with an instance having a 
__del__, but this gets executed outside the main transaction, and 
REQUEST is already dying.

I'd like a post-publishing hook that's called in the initial REQUEST and 
transaction.

Open issues are:
1. what if there's an exception in the hook? I'd say log it but that's all.
2. what if there's a Conflicterror? That's tougher to deal with... The 
transaction has to be retried, without the user being aware of it, so it 
means the hook should probably be called *before* things are sent to the 
browser.

What do you think?
Florent
--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] post publishing hook

2005-04-01 Thread Chris McDonough
When do you think it should be called?  I just had to override
zpublisher_validated_hook to do some stuff that would have been a bit
easier if a different hook existed, but that might be a different use
case...


On Fri, 2005-04-01 at 10:48, Florent Guillaume wrote:
 I really could use a post publishing hook.
 Standard use case: delay indexing at the end of the request to only do 
 it once per object even if the object has been modified 4 times.
 
 Today there's the REQUEST._hold() hack with an instance having a 
 __del__, but this gets executed outside the main transaction, and 
 REQUEST is already dying.
 
 I'd like a post-publishing hook that's called in the initial REQUEST and 
 transaction.
 
 Open issues are:
 1. what if there's an exception in the hook? I'd say log it but that's all.
 2. what if there's a Conflicterror? That's tougher to deal with... The 
 transaction has to be retried, without the user being aware of it, so it 
 means the hook should probably be called *before* things are sent to the 
 browser.
 
 What do you think?
 
 Florent

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


Re: [Zope-dev] post publishing hook

2005-04-01 Thread Florent Guillaume
Chris McDonough  [EMAIL PROTECTED] wrote:
 When do you think it should be called?

I should have answered that clearly:

I'd put it in ZPublisher.publish, like this:


result=mapply(object, request.args, request,
  call_object,1,
  missing_name,
  dont_publish_class,
  request, bind=1)

# INSERT HOOK CALL HERE

if result is not response:
response.setBody(result)

# OR MAYBE HERE but above is probably better

if transactions_manager:
transactions_manager.commit()

Florent


 I just had to override
 zpublisher_validated_hook to do some stuff that would have been a bit
 easier if a different hook existed, but that might be a different use
 case...
 
 
 On Fri, 2005-04-01 at 10:48, Florent Guillaume wrote:
  I really could use a post publishing hook.
  Standard use case: delay indexing at the end of the request to only do 
  it once per object even if the object has been modified 4 times.
  
  Today there's the REQUEST._hold() hack with an instance having a 
  __del__, but this gets executed outside the main transaction, and 
  REQUEST is already dying.
  
  I'd like a post-publishing hook that's called in the initial REQUEST and 
  transaction.
  
  Open issues are:
  1. what if there's an exception in the hook? I'd say log it but that's all.
  2. what if there's a Conflicterror? That's tougher to deal with... The 
  transaction has to be retried, without the user being aware of it, so it 
  means the hook should probably be called *before* things are sent to the 
  browser.
  
  What do you think?
  
  Florent
 
 ___
 Zope-Dev maillist  -  Zope-Dev@zope.org
 http://mail.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope )
 


-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: post publishing hook

2005-04-01 Thread Christian Heimes
Florent Guillaume wrote:
I really could use a post publishing hook.
Standard use case: delay indexing at the end of the request to only do 
it once per object even if the object has been modified 4 times.
Using a post publishing hook for this use case isn't a good idea - IMO. 
The Publisher has nothing to with indexing. It's a completly different 
part of the architecture.

You want to bind some actions to the transaction system because you want 
to execute some code at the end of the first phase of the 2 phase 
commit. That's a completly different story than the post publishing 
hook. Hooking into the transaction machinery of ZODB is very easy. Write 
your own DateManager implementing the IDateManager interface and 
register it into the current transaction using get_transaction.register(DM).

For your use case overwrite the tpc_vote() method of the data manager to 
do the indexing at the boundary between the two phases.

Jens Vagenpohl's mail host and Chris McD's blob have example code for you.
Christian
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: brain.getObject and traversal

2005-04-01 Thread Dieter Maurer
Max M wrote at 2005-3-31 14:48 +0200:
 ...
Most of my queries, where I need to wake up objects, has the form::

 brains = catalog(portal_type='Document')
 objects = []
 for brain in brains:
 try:
 obj = brain.getObject()
 if not obj is None:
 objects.append(obj)
 except:
 pass

So it will not break any of my code, and I guess that most do something
similar.

Hopefully not:

   try: ... except: ... is a powerful receipe to hide
   problems and to get low quality code.

   They should be used *very* rarely...

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] brain.getObject and traversal

2005-04-01 Thread Dieter Maurer
Florent Guillaume wrote at 2005-4-1 13:21 +0200:
Florent Guillaume  [EMAIL PROTECTED] wrote:
  Unauthorized in getObject is out of the question, that would be new 
  behaviour.
  
  Well, in 2.8, new behaviour is expected, right?
  I really passionately believe that we should not be returnining None in 
  Zope 2.8, and since 2.8 hasn't quite hit beta yet I'm very keen to see 
  it fixed asap.
  
  Any objections?
 
 I'm ok for 2.8. I'll look at it.

Is everyone ok with returning
 - the object if it can be accessed
 - raise Unauthorized if it can't be accessed
 - raise NotFound if it's not there
and never return None ?

Remapping exceptions is a bad idea.
Usually, valuable information is lost in the process.

If you change the returning None, then you should let
through whatever exception is caused.

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: ZPT: defer expression fix

2005-04-01 Thread Evan Simpson
Christian Heimes wrote:
 * DeferWrapper didn't cache the result of the expression like ordinary 
vars do.
This was intended, though you couldn't know that since I never 
documented this.  Consider the following terrible example:

div tal:define=xis defer:string:x is $x
  p tal:repeat=x python:range(3)
 tal:content=xis/p
/div
This should evaluate to:
div
  px is 0/p
  px is 1/p
  px is 2/p
/div
Why??  I don't remember why I wanted this behavior; it was an 
experiment, and I can't find any code of mine that uses it.

Cheers,
Evan @ 4-am
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: [Zope2.8a2] ...to be released by tomorrow....

2005-04-01 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

yuppie wrote:

 Tres Seaver wrote:
 
 I'd really like to see http://www.zope.org/Collectors/Zope/1460 resolved
 before the release:

 1.) AFAICS this bug is easy to fix.

 2.) It makes at least CMFDefault sites unusable, deterring CMF users
 from testing Zope 2.8.

 I could merge the fix from the 2.7 branch myself, but I hate to check in
 code I don't understand completely. Maybe Tres or Jim can have a look at
 this? Or at least review the checkin if I do it myself?



 Jim and I fixed this last week:

   http://svn.zope.org/Zope/?rev=29712sortby=dateview=rev

 I will resolve the issue.
 
 
 Can't confirm that. I'm afraid you fixed something different. At least
 the changes in ZopeGuards.py didn't make it into the trunk and I see
 still the same errors.
 
 Please test it yourself with the small script in Entry #1 of
 http://www.zope.org/Collectors/Zope/1460 or with a CMF 1.5/HEAD
 CMFDefault site.

Please try the patch I just checked in:

  http://svn.zope.org/Zope/?rev=29821sortby=dateview=rev

There may be additional issues (e.g., Stuart Bishop's checked
__getitem__ use case), but this makes the test script and the CMF work
for me.

Tres.
- --
===
Tres Seaver[EMAIL PROTECTED]
Zope Corporation  Zope Dealers   http://www.zope.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCTdtEGqWXf00rNCgRAreSAJ4joVm4DHkIk5uBj6nEGqtH1jza4wCgjYf4
bfHieizFRq1pejtLWQaiN3I=
=d3ni
-END PGP SIGNATURE-
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: [Zope2.8a2] ...to be released by tomorrow....

2005-04-01 Thread Tim Peters
[Tim Peters]
 ...
 All the substantive changes I needed to make were completed last
 night, and the overnight test runs were successful.  I still need to
 write up ZODB NEWS, fiddle the version numbers, make a 3.4a1 release
 tag, and edit the svn:externals in Zope trunk to point at that tag.
 That's all very low risk, so just assume it's been done if I don't say
 anything else later.

Still, explicit is better than implicit:  that's all been done, are
there are no remaining ZODB issues holding up release of Zope 2.8a2.
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: post publishing hook

2005-04-01 Thread Florent Guillaume
Christian Heimes  [EMAIL PROTECTED] wrote:
 Florent Guillaume wrote:
  I really could use a post publishing hook.
  Standard use case: delay indexing at the end of the request to only do 
  it once per object even if the object has been modified 4 times.
 
 Using a post publishing hook for this use case isn't a good idea - IMO. 
 The Publisher has nothing to with indexing. It's a completly different 
 part of the architecture.
 
 You want to bind some actions to the transaction system because you want 
 to execute some code at the end of the first phase of the 2 phase 
 commit. That's a completly different story than the post publishing 
 hook. Hooking into the transaction machinery of ZODB is very easy. Write 
 your own DateManager implementing the IDateManager interface and 
 register it into the current transaction using get_transaction.register(DM).
[note: s/IDateManager/IDataManager/ above]
 
 For your use case overwrite the tpc_vote() method of the data manager to 
 do the indexing at the boundary between the two phases.
 
 Jens Vagenpohl's mail host and Chris McD's blob have example code for you.

Ok, Tres also recommended something like that.

I was a bit concerned that there would be problems in case of conflicts,
or if there was a need to tweak the body returned to the user, but after
reading transaction's code and MailDropHost and re-re-reading
Publisher.py, I'm confident I can do everything I need.

Thanks a lot, this together with events will make things much easier in
our framework.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: brain.getObject and traversal

2005-04-01 Thread Florent Guillaume
Tres Seaver  [EMAIL PROTECTED] wrote:
  Is everyone ok with returning
   - the object if it can be accessed
   - raise Unauthorized if it can't be accessed
   - raise NotFound if it's not there
  and never return None ?
  
  I'll change that before tomorrow, for 2.8a2.
  
  (I'll change NotFound in Traversal.py to a real exception instead of a
  string too, I thought we'd killed those.)
 
 We really need to follow a deprecation-style model here:  the risk of
 breaking major third party components is pretty high.
 
 Could we use a module-scope global, settable from zope.conf, to indicate
 which strategy to use?  It should (for 2.8) default to raising, but we
 need to be prepared for an onslaught of breakage reports.
 
 The CHANGELOG should highlight the change, and include the zope.conf
 snippet required to restore the old behavior.  We could add a
 deprecation warning (if that entry is activated), that the old-style
 option would be removed in 2.10.

Ok, thanks a lot to Tres for having gone ahead and done that. I just
merged his branch. All 5645 tests pass (man, with Zope 3 included that's
way more than before!)

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: [Zope2.8a2] ...to be released by tomorrow....

2005-04-01 Thread Andreas Jung

--On Freitag, 1. April 2005 18:44 Uhr -0500 Tim Peters 
[EMAIL PROTECTED] wrote:

[Tim Peters]
...
All the substantive changes I needed to make were completed last
night, and the overnight test runs were successful.  I still need to
write up ZODB NEWS, fiddle the version numbers, make a 3.4a1 release
tag, and edit the svn:externals in Zope trunk to point at that tag.
That's all very low risk, so just assume it's been done if I don't say
anything else later.
Still, explicit is better than implicit:  that's all been done, are
there are no remaining ZODB issues holding up release of Zope 2.8a2.

Excellent!
Thanks,
Andreas


pgpIUdc1BkvOR.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )