You are not logged in Log in Join
You are here: Home » Download Zope Products » Content Management Framework » CMF Documentation » Developing for CMF » Using the Calendar tag product with CMF » View Document

Log in
Name

Password

 

Using the Calendar tag product with CMF

explains how to install the calendar tag product. I'll probably try to add some more info about usage.

Using Calendar tag with the CMFCalendar

This document describes basic installation of the calendar tag product within a CMFSite. The installation instructions assume that you have CMF 1.1 or above installed and have added a CMFSite


Pre-Installation

  • Download the calendar tag product from calendarTag and install it in the Products directory of Zope. Note: if the link does not work go to zope.org and search for calendar.

  • Go the calendar tag product directory and edit calendarTag.py. Change the start variable to set the width of the table to 100%. width="100%%". This is not absolutely necessary but I found this very useful because it allows you size the calendar within another table instead of letting the table tag do the sizing for you.

  • Restart your Zope instance so that the calendar tag product is loaded into Zope.


    Installation

  • If you are using CMF 1.1, download the updated CMFCalendar (version 0.2). This is *not* included with CMF 1.1. Install this in place of your existing CMFCalendar product (in the lib/python/Products directory). Restart Zope.

    The CMFCalendar object is now usable. If you look in the folder portal_skins, you will now see a folder named calendar.

  • In the root of your CMFSite installation, create a calendarDisplay folder.

  • Switch to the newly created calendarDisplay folder.

  • Add a DTML method named 'calendar' to the calendarDisplay folder and paste in the DTML calendar.dtml.

  • Add a Script (Python) object named 'dateMunger' to the calendarDisplay folder and paste in the Python code dateMunger.py

  • Add a Script (Python) object named 'monthRange' to the calendarDisplay folder and browse to your CMFCalendar/Extensions folder to add the monthRange.py file as the source for this object. See notes at the bottom.


    Test your Installation

  • Select the calendar.dtml object and click on the View tab. You should be able to see a calendar.

  • Open the generic folder in portal_skins.

  • Select the index_html DTML method and click on the Customize button.

  • Delete all the code in index_html and type in the following :

    <dtml-with calendarDisplay>
    <dtml-var calendar>
    </dtml-with>


  • Click on the View tab. If you see the calendar then your installation is working. The reason to use the 'dtml-with' syntax is to resolve the calendarDisplay in the Zope namespace.

    Notes

    1. If you want you can paste the monthRange code into Zope directly but it needs modifications. In the Zope management interface, you must add 'dt' as a parameter to the function and paste in the following code :

    from DateTime import DateTime
    month_len =((0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
    (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31))
    """
    Return a pair of DateTime values representing the
    earliest and latest times in the month in which 'dt'
    falls.
    """
    y, m, d = dt.year(), dt.month(), dt.day()
    first = DateTime( y, m, 1 )
    last = first - 1 + month_len[ dt.isLeapYear() ][ m ]
    return first.earliestTime(), last.latestTime()


    The reason to modify the code is to get around the inability to get to the DateTime._month_len attribute because of the Zope engines restrictions.

    2. The monthRange.py code that is in 0.2 CMFCalendar was not formatted properly when I downloaded it. It has carriage returns in it and Zope wants only line feeds. If you have a dos2unix command you can get rid of the carriage returns or you can run this short Python program which will do it as well :

    infile = open('monthRange.py')
    outfile = open('monthRange2.py', 'w+b')
    lines = infile.readlines()
    for i in range(len(lines)):
        line = lines[i][:-1] + '\n'
        outfile.write(line)
    infile.close()
    outfile.close()