Rename Page

Occasionally one wants to rename a page to refactor the information space. (My big personal challenge is having a bunch of blog entries with the wrong year in the datestamp!)

Here are the basic requirements:

  • ask for current name, new name

  • make sure new name not already taken (and is valid Wiki Name? not anything in square brackets works)

  • rename page itself

  • adjust any pages which list the old name as a parent (note, a page can have multiple parents, so can't just overwrite the entire property)

  • do backlinks search to replace body text referring to old name

  • (in searching, beware possibility that Wiki Name is really just part of Wiki NameLonger)

My personal needs are simpler (I haven't referred (yet) to a weblog entry, I know the new intended names aren't taken, have stuck with single parent for each page, etc.), with the extra need of wanting it to run as a batch

  • find any page with id starting 'z2001'

  • rename it using 'z2002'

  • edit Parents property for appropriate child pages (I can do a real hack here - instead of finding child for each renamed page, I can just step again through the entire batch of pages, and change any parent values from 2001 to 2002.)

So I should just write/run my own batch process for now. The biggest barrier, perhaps, figuring out the right packaging for the code... looks like a [script](http://www.zope.org/Members/michel/ZB/Scripting Zope.dtml) is the answer.

Mar 22'02

  • can't do regexp from within Script, but can use 'string' module

  • hmm, how many spaces equal a tab in an HTML form editing a Script? After some experimenting, it looks like almost any number works. I use 2.

  • wrote the 2 scripts, got both working. Yippee!!

    • use manage_renameObject

    • discover (doh) that slicing indexes work a little differently than I expected. 'theId[0:5] = "z2001"', it's not 'theId[0:4]'

    • use 'manage_changeProperties(parents=[newParent])'


Edited: |

blog comments powered by Disqus