Re: [Zope-dev] find unused objects: hopefully the last misunderstanding...

2002-08-30 Thread THerp


*  Starting at root, check all objects  if they are referenced,
*  and produce a list of those which are not, for cleanup purposes.

* Packing the database cleans up in this manner.

Oh well. Third try:
I know about the 'pack database' button. Garbage collection of this
kind is not my problem.

I have lots of scripts, dtml methods etc. everywhere which are
perfectly well-known to the ZODB, nothing wrong with that, but which
are simply not used by me anymore. No usage from other scripts nor
methods nor documents. And these buggers I'd like to find.

Finally unmistakeable?

Tobias Herp


___
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] find unused objects: hopefully the last misunderstanding...

2002-08-30 Thread Jens Vagelpohl

extremely expensive. you would have to...

- assemble a list of all objects IDs in the ZODB

and then...

- parse all contents of all objects and check against that ID list.

you would probably need a little counter for every single ID that gets 
incremented upon finding its ID referenced, and all those that are left 
over with the counter at 0 in the end would probably be candidates for 
removal.

this schema will fall down the moment your object IDs are not unique 
across the whole ZODB. besides, every object is potentially different 
in how you access and read its contents.

if your whole intent is to have a cleaner ZODB and there is no 
pressing reason to do this cleanup, i would just forget about it.

jens

On Friday, Aug 30, 2002, at 07:48 US/Eastern, [EMAIL PROTECTED] wrote:


 *  Starting at root, check all objects  if they are referenced,
 *  and produce a list of those which are not, for cleanup purposes.

 * Packing the database cleans up in this manner.

 Oh well. Third try:
 I know about the 'pack database' button. Garbage collection of this
 kind is not my problem.

 I have lots of scripts, dtml methods etc. everywhere which are
 perfectly well-known to the ZODB, nothing wrong with that, but which
 are simply not used by me anymore. No usage from other scripts nor
 methods nor documents. And these buggers I'd like to find.

 Finally unmistakeable?

 Tobias Herp


___
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] find unused objects: hopefully the last misunderstanding...:o)

2002-08-30 Thread Steve Alexander

[EMAIL PROTECTED] wrote:
 *  I have lots of scripts, dtml methods etc. everywhere which are
 *  perfectly well-known to the ZODB, nothing wrong with that, but which
 *  are simply not used by me anymore. No usage from other scripts nor
 *  methods nor documents. And these buggers I'd like to find.
 
 * There is no easy way to find such things.
 
 * Especially given acquisition, and the dynamic nature of Zope.
 
 Finally we got it :o)
 
 Ok, the reason for me posting this question was the difficult nature.
 So I take your answer as a 'no' to my original question if anyone has
 already written such a script.
 
 Maybe this would be a good thing to accompany future Zope versions.
 There could be a tab which shows all objects which are called
 explicitely by the actual one in a sortable list.
 
 By the way: is this the correct mailing list for such suggestions?
 If not, which one is it?

You forgot to post my suggestions:


You can use Zope Find to get a list of them, and then manually audit 
them. You could instrument such methods to output logging, and check the 
logs every so often to see what is typically being used.

You could use Zope Find to see if the name of particular methods is used 
within other methods.

--
Steve Alexander


___
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] find unused objects: hopefully the last misunderstanding...

2002-08-30 Thread Jean Jordaan

[EMAIL PROTECTED] wrote:
 I have lots of scripts, dtml methods etc. everywhere which are
 perfectly well-known to the ZODB, nothing wrong with that, but which
 are simply not used by me anymore. No usage from other scripts nor
 methods nor documents. And these buggers I'd like to find.

They're impossible to find :))  Take for example the 'index_html' of
a folder: nothing else in my Zope app refers to it. But whenever
someone browses to http://my.zopeserver.com/folder they see that
'index_html'. No automatic method can guess what objects have become
irrelevant.

If you want to find everything that isn't refered to by another Zope
object, you could use 'sitecopy' to make a filesystem copy of everything
in your ZODB, 'ls -R' to get a list of filenames, and
'grep -r filename *' for each filename in the list. If the grep returns
nothing, nothing refers to that object.

You could do the same kind of thing ('ls -R' and 'grep') from the Zope
Management Interface using Jerome Alet's zshell.

-- 
Jean Jordaan
Upfront Systems http://www.upfrontsystems.co.za


___
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] find unused objects: hopefully the last misunderstanding... :o)

2002-08-30 Thread THerp


*  I have lots of scripts, dtml methods etc. everywhere which are
*  perfectly well-known to the ZODB, nothing wrong with that, but which
*  are simply not used by me anymore. No usage from other scripts nor
*  methods nor documents. And these buggers I'd like to find.

* There is no easy way to find such things.

* Especially given acquisition, and the dynamic nature of Zope.

Finally we got it :o)

Ok, the reason for me posting this question was the difficult nature.
So I take your answer as a 'no' to my original question if anyone has
already written such a script.

Maybe this would be a good thing to accompany future Zope versions.
There could be a tab which shows all objects which are called
explicitely by the actual one in a sortable list.

By the way: is this the correct mailing list for such suggestions?
If not, which one is it?

Thanks,

Tobias


___
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] find unused objects: hopefully the last misunderstanding... :o)

2002-08-30 Thread THerp


Original problem:
 I have lots of scripts, dtml methods etc. everywhere which are
 perfectly well-known to the ZODB, nothing wrong with that, but which
 are simply not used by me anymore. No usage from other scripts nor
 methods nor documents. And these buggers I'd like to find.

@Steve:

 You forgot to post my suggestions:

Sorry, no offense meant. Here they are:

 You can use Zope Find to get a list of them, and then manually audit
 them. You could instrument such methods to output logging, and check the
 logs every so often to see what is typically being used.

 You could use Zope Find to see if the name of particular methods is used
 within other methods.

Well, I simply liked to know if anyone had already done it, so I simply
forgot to add them.

@ Jean:
 They're impossible to find :))  Take for example the 'index_html' of
 a folder: nothing else in my Zope app refers to it. But whenever
 someone browses to http://my.zopeserver.com/folder they see that
 'index_html'. No automatic method can guess what objects have become
 irrelevant.

Well, the search seed could be an optional argument w/default value
'index_html'.

 If you want to find everything that isn't refered to by another Zope
 object, you could use 'sitecopy' to make a filesystem copy of
 everything in your ZODB, 'ls -R' to get a list of filenames, and
 'grep -r filename *' for each filename in the list. If the grep
 returns nothing, nothing refers to that object.

 You could do the same kind of thing ('ls -R' and 'grep') from the
 Zope Management Interface using Jerome Alet's zshell.

Interesting suggestions! Of course, these unfortunately won't handle
the acquisition thing correctly.

To dream a dream:

Consider a tab for folderish objects which allows to search them for
unused scripts/methods/... (after pressing a button because it would
possibly take a while), producing a sortable list of links, with
checkboxes for deletion...

Consider a tab for methods... which allows to parse them and produces
a sortable list of links to the other referenced methods...

Maybe I'll write something like that, but it would be my very first
Zope product.

By the way, new question:
Is this the correct mailing list for such suggestions?
If not, which one is it?

Tobias Herp


___
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] find unused objects: hopefully the last misunderstanding...:o)

2002-08-30 Thread R. David Murray

On Fri, 30 Aug 2002 [EMAIL PROTECTED] wrote:
 Consider a tab for methods... which allows to parse them and produces
 a sortable list of links to the other referenced methods...

Just to make it clear what I'm talking about when I say effectively
impossible, consider the following bit of DTML:

dtml-var somefolder[myvar](_.None,_)

How are you going to figure out which objects that references?  And
this is a *very* simple example, just in DTML.  You should see some
of the indirection gyrations certain of my python code goes through grin.

--RDM


___
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] find unused objects: hopefully the last misunderstanding...:o)

2002-08-30 Thread R. David Murray

On Fri, 30 Aug 2002 [EMAIL PROTECTED] wrote:
 Consider a tab for methods... which allows to parse them and produces
 a sortable list of links to the other referenced methods...

Good luck grin.  You might manage a Quick and Dirty implementation,
but to guarantee you've not missed anything you pretty much have to
run the site as a program, which leads you to the classic computer
science halting problem, I think.  And that still doesn't address
the question of external references.

 By the way, new question:
 Is this the correct mailing list for such suggestions?
 If not, which one is it?

For the original has anyone implemented question, probably 'zope'.
For a discussion of how to implement this (or rather the effective
impossiblity of implementing this reliably) this is probably the
appropriate place.

--RDM


___
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] find unused objects: hopefully the last misunderstanding...:o)

2002-08-30 Thread Oliver Bleutgen

R. David Murray wrote:
 On Fri, 30 Aug 2002 [EMAIL PROTECTED] wrote:
 
Consider a tab for methods... which allows to parse them and produces
a sortable list of links to the other referenced methods...
 
 
 Good luck grin.  You might manage a Quick and Dirty implementation,
 but to guarantee you've not missed anything you pretty much have to
 run the site as a program, which leads you to the classic computer
 science halting problem, I think.  And that still doesn't address
 the question of external references.
 
 
By the way, new question:
Is this the correct mailing list for such suggestions?
If not, which one is it?
 
 
 For the original has anyone implemented question, probably 'zope'.
 For a discussion of how to implement this (or rather the effective
 impossiblity of implementing this reliably) this is probably the
 appropriate place.

Ok, quick and probably dumb idea how one could write a ZLinkBot.

If there is a central part in zope (ZPublisher?) which always runs when 
methods/scripts/etc  are called, one could patch it to also log the path 
of the object which is called (the physical path!).
Then just use a web spider which crawls the whole site, and after that 
compare the list which has been produced by the method above to the list 
of objects in your ZODB.

Everything which hasn't been touched is an orphan.

Could ZPublisher.Publish.call_object() be that central piece of code?


cheers,
oliver






___
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] find unused objects: hopefully the last misunderstanding...:o)

2002-08-30 Thread R. David Murray

On Fri, 30 Aug 2002, Oliver Bleutgen wrote:
 If there is a central part in zope (ZPublisher?) which always runs when
 methods/scripts/etc  are called, one could patch it to also log the path
 of the object which is called (the physical path!).
 Then just use a web spider which crawls the whole site, and after that
 compare the list which has been produced by the method above to the list
 of objects in your ZODB.

 Everything which hasn't been touched is an orphan.

Combine this with a regression test suite that exercised all of
the site's functionality and pages, and you'd have something.

As with Unit Tests, if it isn't tested, it should be deleted grin.

--RDM


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