Skip to content

Rhaptos Software Development

Personal tools
You are here: Home » Documentation » System Administration Documentation » Deleting Content

Deleting Content

Document Actions
Connexions normally doesn't delete content but sometimes has to for legal reasons. Here are instructions for doing so.

SOME_DIRECTORY used to be /home/brentmh/swi/deleted-content but this seems unavailable at the moment. Currently using /home/jccooper/deletions/

Mostly these instructions are for modules and collections. A few points are module-only.

Export and delete

In ZMI or, better, debug console:

  export module/collection to SOME_DIRECTORY as zexp, in ZMI or with content.manage_exportObject(id=x, download=0)
  delete from /plone/content, in ZMI or with content.manage_delObjects(['mXXXXX', 'mYYYYY', 'mZZZZZ'])

CVS (modules only)

  $ mv /var/lib/cvs/xmlpages/mXXXXX SOMEDIRECTORY
  (if homes aren't mounted on the production server, first scp somewhere they are mounted and then delete)

fix catalog

Debug console:

  >>> app.plone.content.catalog.uncatalog_object('/plone/content/mXXXXX/latest')
  (it is something of a bug that deletion doesn't update the catalog--used to work for collections, but no longer)

Could be done in ZMI as catalog refresh, but above is better.

SQL

in test tab of database connection in ZMI, or Postgres command console, or similar:

  delete from moduletags where module_ident in (select module_ident from modules where moduleid in ('mXXXXX', 'mYYYYY', 'mZZZZZ'))
  delete from modules where moduleid in ('mXXXXX', 'mYYYYY', 'mZZZZZ')

Suggest use of console, and also saving a select * of whatever is deleted.

Popularity

Also need to remove the ids from the popularity database. Kyle's magic commands for this follow. Apparently you can't do something simple like just "del ..._hits[id]" because of the Zopeish underscorishness, hence the copying and reassignment.

deletedIds=['m11894', 'm12435', 'm12436', 'm12437']:

hd = app.plone.portal_hitcount._hits
for m in deletedIds:
  hd.pop(m)
app.plone.portal_hitcount._hits = hd


Similarity

Similarity tool has a 'deleteSimilarity' method. Supposedly it works; I'm not certain, though. It is only needed for modules; dunno if it complains if you feed it a collection.


Lenses entries

To find lens entries for a module, do in zopectl debug::

 >>> app.plone.lens_catalog(portal_type="SelectedContent", id='mXXXXX'

If there are any, visit (as a manager) those lenses and delete the offending module. It is possible to write a script to do the last step, but I think it's rare enough to defer.


Sample debug script:


>>> all = [...]
>>> for m in all:
...   content.manage_exportObject(id=m, download=0)
...
>>> content.manage_delObjects(all)
>>>
>>> for m in all:
...   content.catalog.uncatalog_object('/plone/content/%s/latest' % m)
...
>>>
>>> hd = app.plone.portal_hitcount._hits
>>> for o in all:
...   hit = hd[o]
...   o, hit.published, hit.recent, hit.total, hit._daily_average, hit._percentile
...   n = hd.pop(o)
>>> app.plone.portal_hitcount._hits = hd
>>>
>>> sim = app.plone.portal_similarity
>>> for m in all:
...   sim.deleteSimilarity(m)
>>>
>>> import transaction
>>> transaction.commit()

Created by kef
Last modified 2008-07-21 15:58