def __init__(self, year=None, month=None, day=None, attr=None, indent=None, db_tbl_col=None, db_func=None):
        CalendarTable.__init__(self, year=year, month=month, day=day, attr=attr,
                                indent=indent, db_tbl_col=db_tbl_col, db_func=db_func)
        self.head = [[]]
        days = []
        # first half of lists
        cur_day = self.day
        cur_mon = self.month
        while len(days) < 4:
            days = [self.day_div(d=cur_day, m=cur_mon)] + days
            self.head[0] = [datetime.datetime(year=self.year, month=cur_mon, day=cur_day).strftime('%A')] + self.head[0]
            cur_day -= 1
            if cur_day < 1:
                cur_day = self.last_day(self.prev_month())
                cur_mon = self.prev_month()

        # second half of lists
        cur_day = self.day+1
        while len(days) < 7:
            if cur_day > self.last_day():
                cur_day = 1
                cur_mon = self.next_month()
            days += [self.day_div(d=cur_day, m=cur_mon)]
            self.head[0] += [datetime.datetime(year=self.year, month=cur_mon, day=cur_day).strftime('%A')]
            cur_day += 1

        self.body = [days]
    def __init__(self, year=None, month=None, attr=None, indent=None, db_tbl_col=None, db_func=None):
        """
        SUMMARY:
            This class represents a month calendar built with a table Elem.
            The table header is always the day of the week that the body dates
            fall on.

            The first week of each month begins on some weekday. This day is first
            determined with the datetime.now() method. The number of days
            in the month is also variable, ranging from 28 to 31. The end date is
            determined by incrementing a number from 28 until datetime raises a
            ValueError for a date that does not exist. This is done in the
            last_day() method.

            For each key and value in db_tbl_col, where key is table name and value
            is column name, are specified the method checks the db for day_ids
            that match the given dates in the calendar. It then checks if
            any of db_tbl_col's rows contain a matching day_id. If so the column in
            that record is appended to the proper day's div in the table.

        FIELDS:
            The 'attr' and 'indent' args are identical to that of their parent
            class.

            The 'year' and 'month' args specify which month to show. If no year or
            month is passed the current month is shown. Year must be an int,
            however month can be either the name of the month as a string or an
            int representing the number of the month.

            The 'db_tbl' should a dict that matches table names to column names
            in the db that will be loaded into the month. The tables must have
            a day_id column for every element in the db table. If 'db_tbl_col' is
            None nothing is added to each day.

            The 'db_func' passes a function to perform on each 'db_tbl_col' day
            item before adding it to the td of the table Elem. If it is None raw
            text from the table is added to the calendar.
        """
        CalendarTable.__init__(self, year=year, month=month, attr=attr, indent=indent,
                                db_tbl_col=db_tbl_col, db_func=db_func)

        start_day = datetime(self.year, self.month, 1).weekday()
        end_day = self.last_day() + (start_day - 1)

        self.head = [[h3(self.month_str(self.month).title())],
                                   ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
                                    'Friday', 'Saturday', 'Sunday']]
        d = db()
        for week in xrange(0, end_day, 7):
            self.body.append([])
            for day in range(week, week + 7):
                true_day = day - (start_day - 1)  # Day is off by start_day-1
                # --- (First Week) ---
                if day < start_day:
                    self.body[0].append(None)
                elif day < 7:
                    self.body[0].append(self.day_div(true_day))

                # --- (2nd - Last Weeks) ---
                elif day < end_day:
                    self.body[-1].append(self.day_div(true_day))
                else:
                    break