[Zope] Kaivo Document Library customisation?

Casey Duncan casey@zope.com
Mon, 9 Sep 2002 11:07:51 -0400


On Monday 09 September 2002 10:21 am, Richard Hewison wrote:
> I've been able to customise a fair amount of the standard Kaivo Documen=
t
> Library product to meet our own needs, but have now hit the limit of my
> current knowledge and understanding. The author of the product (Casey
> Duncan) has kindly dropped a few suggestions to me in the past, but I
> still don't understand how to achieve what he has suggested.
>=20
> What I'm trying to do is automate an email to be sent to the author of
> a submitted document 6 months afterwards to say "Please re-visit your
> document".
[snip]
>=20
> Casey's suggestion was to create a dtml method within the Document
> Library that queries the library for old documents and then sends the
> author an email. You then use the OS command line utility 'wget' in a
> script to execute the dtml method periodically via a cron job on the
> server.
>=20
> We could get the email sent from outside of Zope, but it is probably
> neater for everything to be done inside and just use 'wget' to run the
> method automatically.

This is what I had in mind with my suggestion.
=20
> The bare minimum info we need from the document library Document Store
> object (which is called 'Documents') is 'email', 'review_date',
> 'filename' and 'title' for each and every document file (word, excel or
> pdf file) inside it. Trouble is, I don't understand enough about how th=
e
> DL product works. I know that the 'Documents' Document store object
> isn't a normal folder but I have no idea where to start on examining it
> and getting the info out!

DocumentStore is like a combo of BTreeFolder and ZCatalog. It stores the=20
documents and also indexes them. You probably do not need to change it=20
though. What you probably want to do, is send emails to every author whos=
e=20
document has not been updated for the last 6 months. To do this, create a=
=20
python script in the DL like:

# Create a dictionary mapping email addrs to documents needing update
emails =3D {}
for record in container.Documents.query(
    bobobase_modification_time=3Dcontainer.ZopeTime()-180,
    bobobase_modification_time_usage=3D'range:max'):
    doc =3D record.getObject()
    if doc is None:
        continue
    if not emails.has_key(doc.creator_email):
        emails[doc.creator_email] =3D [doc]
    else:
        emails[doc.creator_email].append(doc)

# Send the emails
for email, docs in emails.items():
    container.send_update_email(None, context.REQUEST, email=3Demail, doc=
s=3Ddocs)

return 'sent messages to:\n' + '\n'.join(emails.keys())

This script calls a dtml method named "send_update_email" which expects a=
n=20
email address "email" and a list of documents "docs". It should create an=
d=20
email that links to these documents and includes and relevant info that y=
ou=20
like.

The python scripts finds all of the documents that have not been updated =
for 6=20
months. Then it sorts them by email address (stored in the contrived=20
"creator_email" attribute, substitute your name) so that only one email i=
s=20
sent to each author. That way if one author has 50 documents, he gets one=
=20
email with 50 links in it rather than 50 emails with one link.=20

This python script can be called from wget. Or just run manually using th=
e=20
test tab. It returns a list of all the email addresses that were mailed.

hth,

Casey