Re: [Zope-dev] Zope 2.7 memory behaviour

2004-03-23 Thread Stefan Doerig
Dieter Maurer wrote:

Apparently, your application is leaking HTTPRequest instances.

Are you storing acquisition wrapped objects in the REQUEST object?
No, I don't think so, but I might be wrong. I mail you the test template 
I'm accessing.

### BEGIN mon-clear
dtml-var standard_html_header
dtml-var REQUEST
dtml-var standard_html_footer
### END mon-clear
### BEGIN standard_html_header
html
head
title/title
/head
body
standard_html_header
### END standard_html_header
### BEGIN standard_html_footer
standard_html_footer
/body
/html
### END standard_html_footer
That's all. The reference count looks like this after a while

Class   March 23, 2004 9:46 am  March 23, 2004 10:24 am Delta
Acquisition.ImplicitAcquirerWrapper 68  8793+8725
ZPublisher.HTTPRequest.HTTPRequest  17  2198+2181
ZServer.HTTPResponse.ZServerHTTPResponse10  2191+2181
ZPublisher.BaseRequest.RequestContainer 7   2188+2181
BTW: Flushing the cache does not decrease the reference count.



Stef



--
-
addr://Rathausgasse 31, CH-5001 Aarau  fon://++41 62 823 9355
http://www.terreactive.com fax://++41 62 823 9356
-
terreActive AG   Wir sichern Ihren Erfolg
-
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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: ...but I want to access 'a particular tuple' in that context!

2004-03-23 Thread Tres Seaver
Jamie Heilman wrote:
Try this in a PythonScript:

d = {1:2}
for t in d.iteritems():
  pass
Annoyingly, it raises Unauthorized: You are not allowed to access 'a
particular tuple' in this context
Is there a reason for this, or is it just part of
AccessControl/RestrictedPython that hasn't been fleshed out yet?
The 'iteritems' method of a dictionary returns an object of type 
'dictionary-iterator';  AccessControl.ZopeGuards makes no container 
assertions about that type, although it *does* permit calling the 
'iteritems' method which returns an instance of it.

I find it interesting that that module wraps 'iterkeys' and 'itervalues' 
in its 'get_iter' checker, but allows unrestricted access to 'iteritems'.

The following patch will make your use case work (it would need to be 
prettied up for Python  2.3):

--- lib/python/AccessControl/ZopeGuards.py  16 Jan 2004 18:18:51 
- 1.18
+++ lib/python/AccessControl/ZopeGuards.py  23 Mar 2004 16:41:19 -
@@ -161,6 +161,8 @@
 'iterkeys': get_iter,  'itervalues':get_iter,
 'pop':get_dict_pop, 'popitem':1, 'setdefault':1, 'update':1, 
'values':1}

+ContainerAssertions[type({}.iteritems())] = 1
+
 ContainerAssertions[type([])] = {
 'append':1, 'count':1, 'extend':1, 'index':1, 'insert':1,
 'pop':get_list_pop, 'remove':1, 'reverse':1, 'sort':1}


Tres.
--
===
Tres Seaver[EMAIL PROTECTED]
Zope Corporation  Zope Dealers   http://www.zope.com
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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] Problem with editing dtml in textarea

2004-03-23 Thread pieter claassen
For some reason if I do the following:

textarea name=col1 rows=30 cols=120 dtml-var
expr=_.getitem('1_col',0) html_quote/textarea

I can edit the html but all dtml is interpreted.

I am trying to build a dtml page with which I can edit other pages:
1. Any recommendations on how to do this?
2. How do then overwrite the previous page with the edited code?

Thanks,
Pieter


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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: How to create a product with all_meta_types and the

2004-03-23 Thread sureshvv
Maybe you can use the:

invokeFactory(id=xx, type=xx) method.

Garito [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Max
 I understand what you explain but what about if I install a new product?
 Rewrite the factory?
 I think is not a good solution don't you think?

 Thanks!!

 - Original Message - 
 From: Max M [EMAIL PROTECTED]
 To: Garito [EMAIL PROTECTED]
 Cc: Lista Oficial de Zope [EMAIL PROTECTED]
 Sent: Friday, March 12, 2004 10:34 AM
 Subject: Re: [Zope-dev] How to create a product with all_meta_types and
the


  Garito wrote:
 
   Hi Chris!
  
   Want I want exactly is to create a product's object by his name
   programmatically not by the construction form
   Is this posible?
 
 
  You cannot know the name of the constructor function, unless you read
  the source.
 
  The constructors added to Zope during the product initialisation can be
  both forms and actual function methods. There is no way of knowing
  which. And there can be more than two.
 
  So you would need to write a factory function based on the info you can
  get from the source. Ie. in an external method. Something like::
 
 
  def portal_factory(self, parent, portal_type, id='', title='',):
 
   Adds the content. A factory function.
 
   # generate a general id
   if id == '':
   id = self.ZopeTime().strftime(portal_type + '_%Y%m%d_%H%M%S')
 
   zope_factory = parent.manage_addProduct
 
   # add the content
   if 'Document' == portal_type:
   zope_factory['Document'].manage_addDocumentAction(id)
 
   elif 'Some Type' == portal_type:
   zope_factory['Some Type'].manage_addSomeTypeAction(id)
 
   else:
   raise 'Error adding portal_type'
 
   # get the newly added content
   obj = getattr(parent, id)
   # Add the title
   obj.title = title
 
   return obj
 
 
  -- 
 
  hilsen/regards Max M, Denmark
 
  http://www.mxm.dk/
  IT's Mad Science
 


 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 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 maillist  -  [EMAIL PROTECTED]
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] Problem with editing dtml in textarea

2004-03-23 Thread J Cameron Cooper
pieter claassen wrote:

For some reason if I do the following:

textarea name=col1 rows=30 cols=120 dtml-var
expr=_.getitem('1_col',0) html_quote/textarea
I can edit the html but all dtml is interpreted.

It has not been told to do otherwise.

I am trying to build a dtml page with which I can edit other pages:
1. Any recommendations on how to do this?
2. How do then overwrite the previous page with the edited code?
I could look up the proper API calls, but instead I will point out 
something more helpful in the long run: if the ZMI can do it, so can 
you. It's a big heap of examples. Go take a look.

Or look at the methods on the DTML objects and try to figure out the 
appropriate ones.

This list, btw, is for devlopment of Zope, and not with Zope. That's 
more appropriate on the main list.

   --jcc



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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] Zope2.7.0rc2 AttributeError: 'NoneType' object has noattribute 'setHeader'

2004-03-23 Thread Christophe Tronche
Hello all.

Has this problem been solved ?
I'm stuck in the very same problem after having switched from python 2.6.2 to 
2.6.4, both using the same python2.2.3. Pure Zope, no Product other than my 
own (where not a single line of code has been modified) and no funny name 
like Tony's SYS or whatever.

The problem occurs when trying to interpret 
App/dtml/manage_page_header.dtml and /OFS/dtml/main.dtml in a management tab.

Any idea someone ?

Regards,
Ch. Tronche

Thanks again for the reply Dieter,

On 6 Feb 2004, at 21:14, Dieter Maurer wrote:

 REQUEST.RESPONSE is set up in
 ZServer.HTTPServer.zhttp_handler.continue_request.
 It should be impossible that is is None.



Agreed.

 Maybe, we have a memory corruption.
 I have seen objects magically becoming None in
 Python versions with memory corruption problems (Python 2.1.1).

 -- 
 Dieter


Could be memory perhaps, but this is python2.3.3.

 Christian Heimes wrote:
 [...]

 And the next one:

 Python2.3.3/Zope2.70rc2/Plone2rc5.

 Exception Type
 AttributeError
 Exception Value
 'str' object has no attribute 'RESPONSE'

 [...]
 Module Products.CMFPhoto.Photo, line 510, in clearCache
 AttributeError: 'str' object has no attribute 'RESPONSE'

 The relevant code line is self.REQUEST.RESPONSE.setHeader(). The error
 occured at object creation.

 Something really bad is going on!

 Christian



The problem I'm having is that these are all stock Zope products from a 
Zope2.7.0rc2 release. The traceback is coming from the Zope core.

Traceback (innermost last):
...
   Module Shared.DC.Scripts.Bindings, line 320, in
__render_with_namespace__
   Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
   Module App.special_dtml, line 175, in _exec
   Module DocumentTemplate.DT_Util, line 201, in eval
- __traceback_info__: RESPONSE
   Module string, line 0, in ?
AttributeError: 'NoneType' object has no attribute 'setHeader'

This also seems different from what Christian is reporting;

 Christian Heimes wrote at 2004-2-6 23:01 +0100:
 And the next one:

 Python2.3.3/Zope2.70rc2/Plone2rc5.


 Exception Type
 AttributeError
 Exception Value
 'str' object has no attribute 'RESPONSE'

 [...]
 Module Products.CMFPhoto.Photo, line 510, in clearCache
 AttributeError: 'str' object has no attribute 'RESPONSE'

 The relevant code line is self.REQUEST.RESPONSE.setHeader(). The error
 occured at object creation.

 Something really bad is going on!

So, I'm still baffled by this.

Many thanks to all those providing more data points. I *think* this is 
a 'Zope' thing and not a 'Tone' thing, but I've been wrong in that area 
before ;)

cheers
tone.
-- 
Dr Tony McDonald, Asst Director, FMSC. 0191 245 4223
Project Manager, FDTL-4 ePortfolios http://www.eportfolios.ac.uk/



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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: ...but I want to access 'a particular tuple' in that context!

2004-03-23 Thread Jamie Heilman
Tres Seaver wrote:
 
 The 'iteritems' method of a dictionary returns an object of type 
 'dictionary-iterator';  AccessControl.ZopeGuards makes no container 
 assertions about that type, although it *does* permit calling the 
 'iteritems' method which returns an instance of it.
 
 I find it interesting that that module wraps 'iterkeys' and 'itervalues' 
 in its 'get_iter' checker, but allows unrestricted access to 'iteritems'.

Yeah I saw that, which is why I asked about it, I couldn't decide if
it was left sort of half-baked on purpose or not.  I assume not, but I
wanted to make sure.
 
 The following patch will make your use case work (it would need to be 
 prettied up for Python  2.3):

OK, but really I'm more interested in having this supported in Zope
proper, I can always use .items() instead of .iteritems() and soak the
associated costs if I have to.  Surely making iteritems use a guarded
interator is the Right thing, yes?

-- 
Jamie Heilman http://audible.transient.net/~jamie/
Most people wouldn't know music if it came up and bit them on the ass.
-Frank Zappa

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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: ...but I want to access 'a particular tuple' inthat context!

2004-03-23 Thread Tim Peters
[Tres Seaver]
 The 'iteritems' method of a dictionary returns an object of type
 'dictionary-iterator';  AccessControl.ZopeGuards makes no container
 assertions about that type, although it *does* permit calling the
 'iteritems' method which returns an instance of it.

 I find it interesting that that module wraps 'iterkeys' and
 'itervalues' in its 'get_iter' checker, but allows unrestricted
 access to 'iteritems'.

[Jamie Heilman]
 Yeah I saw that, which is why I asked about it, I couldn't decide if
 it was left sort of half-baked on purpose or not.  I assume not, but I
 wanted to make sure.

It was deliberate.  iterkeys() and itervalues() reveal objects held by the
dict directly, and so require security checks before handing those objects
out.  iteritems() returns 2-tuples, though, and there's no security
implication there until you do something to extract the contained keys and
values from the 2-tuples.  The security checks in the iteritems() case occur
in all the ways of picking apart the 2-tuples.

 The following patch will make your use case work (it would need to be
 prettied up for Python  2.3):

[a patch that inserted

ContainerAssertions[type({}.iteritems())] = 1
]

Unfortunately,

type({}.iteritems()) is type({}.iterkeys()) is type({}.itervalues())

They all return a dictionary-iterator object.  The .next() method of a
dictionary-iterator object is safe to hand out for the iteritems flavor
(again because it returns 2-tuples), but the .next() methods of the others
aren't safe (again because they reveal contained objects directly).

 OK, but really I'm more interested in having this supported in Zope
 proper,

Sure -- I'm sure Tres was just trying to get you unstuck in a hurry.

 I can always use .items() instead of .iteritems() and soak the
 associated costs if I have to.  Surely making iteritems use a guarded
 interator is the Right thing, yes?

The thing going wrong here is subtler than that.  For example, change
iteritems() to itervalues() in your original example, and I bet it still
won't work.  OTOH, if you use list(yourdict.iterkeys()) instead, I bet it
will work.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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] PageTemplateFile vs. Bindings vs. Security

2004-03-23 Thread Shane Hathaway
Jamie Heilman wrote:
Paradoxically, by ignoring Zope's security framework in the context of
on-disk methods this actually improves Zope's overall security.
I can see that.  It's interesting that when security is burdensome, it 
is often less secure overall as a result.  I see this pattern everywhere.

So here's the questions I have for you all... is there a way to
declare appropriate security on the bindings that are screwing me
right now from within my product code so that I can selectively poke
holes to allow container access where needed, or am I to be forcibly
coerced into exposing my object to restricted code?  And two, assuming
I haven't overlooked some detail about why forcing PageTemplateFile to
work within the calling security context is a good thing...  Shouldn't
we fix PageTemplateFile to work like DTMLFile wrt security?  How hard
is it going to be to do that?
There certainly ought to be a way to create an unrestricted 
PageTemplateFile, though it should be an explicit step.

To do this, I would change Products/PageTemplates/Expressions.py.  It 
creates an expression evaluation engine and adds expression types to it. 
 It chooses the unrestricted or the restricted expression types based 
on whether the Zope module exists.  This is a wart.  Instead, I think 
it should create two engines, one restricted and one unrestricted.  Then 
you should be able to tell the PageTemplateFile constructor which engine 
to use.

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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] PageTemplateFile vs. Bindings vs. Security

2004-03-23 Thread Dieter Maurer
Jamie Heilman wrote at 2004-3-22 16:42 -0800:
 ...
So here's the questions I have for you all... is there a way to
declare appropriate security on the bindings that are screwing me
right now from within my product code so that I can selectively poke
holes to allow container access where needed,

One approach (hopefully quite near to your wishes) looks like:

  Protect your object by a role, say Manager.
  This looks like __roles__ = ('Manager',)

  Give your PageTemplateFile the Manager proxy role:
  _proxy_roles = ('Manager',)

  Make your PageTemplateFile unowned: _owner = None.

Instead of Manager, you can use another role that you do not
assign any permissions.


Alternative:
An incredibly long time ago, Evan published a product
XXXPythonScripts. These are PythonScripts without security
checks. Looking at the differences between these two products
may show what is needed to get security unaware PageTemplateFiles.

-- 
Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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] Zope 2.7 memory behaviour

2004-03-23 Thread Dieter Maurer
Stefan Doerig wrote at 2004-3-23 10:31 +0100:
 ...
No, I don't think so, but I might be wrong. I mail you the test template 
I'm accessing.

### BEGIN mon-clear
dtml-var standard_html_header
dtml-var REQUEST
dtml-var standard_html_footer
### END mon-clear


### BEGIN standard_html_header
html
head
title/title
/head
body
standard_html_header
### END standard_html_header


### BEGIN standard_html_footer
standard_html_footer
/body
/html
### END standard_html_footer

That's all. The reference count looks like this after a while

Your test looks quite innocent.

I tried to reproduce it (about 5.000 ab requests against
something similar to your mon-clear) and could not see
any memory leak. Especially, no HTTPRequest or ImplicitAcquirerWrapper
were leaked.

However, you may have an AccessRule (or some other
__before_publishing_traverse__ or __bobo_traverse__ hook)
that leaks requests.

-- 
Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
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 )