Repository: plone/Products.CMFPlone

Issue:
Plone 6: rebuilding the catalog does not work
Rebuilding the catalog using the ZMI does not work

See: https://community.plone.org/t/upgrade-plone-6-sites-dx-site-root/14303/16?u=alert


Discussion:
Probably an indexer should be registered for the Plone object
Or a patch in plone.dexterity? In the [content.py](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/content.py#L421) , we could replace the

```
def UID(self):
    # Returns the item's globally unique id.
    return IUUID(self)
```
with
```
def UID(self):
    # Returns the item's globally unique id.
    return IUUID(self, None)
```

But i dont know what are the side effects. Is the throwing of  the TypeError wanted, if no default/alternate value given?


Fun fact, after I rebuilt the catalog, the Plone object is not there...
Do you experienved the same @1letter?

I also see here that the Plone site is not intended to be cataloged:
https://github.com/plone/Products.CMFPlone/blob/7b71338cb699155fdd0a4067df2756cae4346064/Products/CMFPlone/Portal.py#L225

So I am not really sure why this method is called...
I know why, this is actually the portal_catalog trying to catalog itself...
```
(Pdb++) ll
 417         def recordify(self, object):                                                                                                                   
 418             """ turns an object into a record tuple """                                                                                                
 419             record = []                                                                                                                                
 420             # the unique id is always the first element                                                                                                
 421             for x in self.names:                                                                                                                       
 422                 attr = getattr(object, x, MV)                                                                                                          
 423                 if (attr is not MV and safe_callable(attr)):                                                                                           
 424  ->                 attr = attr()                                                                                                                      
 425                 record.append(attr)                                                                                                                    
 426             return tuple(record)                                                                                                                       
(Pdb++) object
<CatalogTool at /Plone/portal_catalog>
(Pdb++) getattr(object, x, MV)
<bound method PloneSite.UID of <PloneSite at /Plone>>
```

Resolving patch:
diff --git a/Products/CMFPlone/CatalogTool.py b/Products/CMFPlone/CatalogTool.py
--- a/Products/CMFPlone/CatalogTool.py
+++ b/Products/CMFPlone/CatalogTool.py
@@ -465,8 +465,11 @@ def clearFindAndRebuild(self):
         idxs = list(self.indexes())
 
         def indexObject(obj, path):
-            if (base_hasattr(obj, 'reindexObject') and
-                    safe_callable(obj.reindexObject)):
+            if (
+                obj != self
+                and base_hasattr(obj, 'reindexObject')
+                and safe_callable(obj.reindexObject)
+            ):
                 try:
                     self.reindexObject(obj, idxs=idxs)
                     # index conversions from plone.app.discussion


Test patch: