[Zope-dev] Catalog performance

2003-09-18 Thread zhimin
John Barratt wrote:

 If you can't use catalog metadata as Seb suggests (eg. you are actually
 accessing many attributes, large values, etc.) and if indeeed memory is
 the problem (which seems likely) then you can ghostify the objects that
 were ghosts to begin with, and it will save memory (unless all those
 objects are already in cache).

 The problem with this strategy though is that doc.getObject() method
 used in your code activates the object and hence you won't know if it
 was a ghost already or not.  To get around this you can shortcut this
 method and do something like :

 docs = container.portal_catalog(meta_type='Document', ...)
 for doc in docs:
  obj = doc.aq_parent.unrestrictedTraverse(doc.getPath())
  was_ghost = obj._p_changed is None
  value = obj.attr
  if was_ghost:obj._p_deactivate()

Just my 2 cents observation...
I ran this code and monitored the page Cache extreme detail in ZMI 
ControlPanel  DebugInfo.
With this method, the object was not loaded. However the intermediate
objects that the unrestrictedTraverse() passed by were loaded into memory.
e.g. If doc.getPath() is '/x/y/z/myobject', myobject was not loaded but x,
y, and z were loaded into memory.

I also tried the method suggested by Seb. This did not load myobject as
well as x, y, and z into memory:
http://mail.zope.org/pipermail/zope-dev/2003-September/020450.html

The information on deactivating object into ghost state is very helpful.
Thanks!

cheers,
zhi min




___
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] Will restrictedTraverse() load every obj into memory?

2003-09-17 Thread zhimin
Hello,

I have a function that returns the object when given a path.

def path2Object(path):
obj = context,restrictedTraverse(path)
return obj

My concern is whether restrictedTraverse(path) will load into memory every
object it traverses through and thus increase memory usage, especially if
it is run very frequently and with different path each time.
e.g. if my path is '/x/y/z/myobj',  will object x, y, and z also get loaded
when the object I really want is myobj? What's the state of x,y,z after
calling restrictedTraverse(path) - loaded or ghost?

If intermediate objects (like x, y, z above) get loaded, is there anyway to
ghostify them to reduce memory usage?
...or is there a memory-economic way to get object by path?

Many thanks!


cheers,
Zhi Min




___
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 )