~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/db.py

  • Committer: Matt Giuca
  • Date: 2009-01-19 04:57:52 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: matt.giuca@gmail.com-20090119045752-3hbb1yego8ynrqmu
ivle.database: Added Worksheet.get_by_name method.
tutorial: Replaced calls to get_worksheet_mtime with Worksheet.get_by_name.
    Also replaced all usage of the time module with datetime (so as to be
    compatible with Storm).
ivle.db: Removed get_worksheet_mtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
655
655
 
656
656
    # WORKSHEET/PROBLEM ASSOCIATION AND MARKS CALCULATION
657
657
 
658
 
    def get_worksheet_mtime(self, subject, worksheet, dry=False):
659
 
        """
660
 
        For a given subject/worksheet name, gets the time the worksheet was
661
 
        last updated in the DB, if any.
662
 
        This can be used to check if there is a newer version on disk.
663
 
        Returns the timestamp as a time.struct_time, or None if the worksheet
664
 
        is not found or has no stored mtime.
665
 
        """
666
 
        try:
667
 
            r = self.get_single(
668
 
                {"subject": subject, "identifier": worksheet},
669
 
                "worksheet", ["mtime"], ["subject", "identifier"],
670
 
                dry=dry)
671
 
        except DBException:
672
 
            # Assume the worksheet is not in the DB
673
 
            return None
674
 
        if dry:
675
 
            return r
676
 
        if r["mtime"] is None:
677
 
            return None
678
 
        return time.strptime(r["mtime"], TIMESTAMP_FORMAT)
679
 
 
680
658
    def create_worksheet(self, subject, worksheet, problems=None,
681
659
        assessable=None):
682
660
        """
924
902
            return query
925
903
        return self.db.query(query).dictresult()
926
904
 
 
905
    # PROJECT GROUPS
 
906
 
927
907
    def get_offering_info(self, projectsetid, dry=False):
928
908
        """Takes information from projectset and returns useful information 
929
909
        about the subject and semester. Returns as a dictionary.