示例#1
0
def create_cache(
    recid, uid, record="", cache_dirty=False, pending_changes=[], disabled_hp_changes={}, undo_list=[], redo_list=[]
):
    """Create a BibEdit cache file, and return revision and record. This will
    overwrite any existing cache the user has for this record.
    datetime.

    """
    if not record:
        record = get_bibrecord(recid)
        if not record:
            return (None, None)

    record_revision = get_record_last_modification_date(recid)
    if record_revision is None:
        record_revision = datetime.now().timetuple()

    assert_undo_redo_lists_correctness(undo_list, redo_list)

    # Order subfields alphabetically after loading the record
    record_order_subfields(record)

    data = [cache_dirty, record_revision, record, pending_changes, disabled_hp_changes, undo_list, redo_list]
    update_cache(recid, uid, data)
    return record_revision, record
示例#2
0
def create_cache(recid,
                 uid,
                 record='',
                 cache_dirty=False,
                 pending_changes=[],
                 disabled_hp_changes={},
                 undo_list=[],
                 redo_list=[]):
    """Create a BibEdit cache file, and return revision and record. This will
    overwrite any existing cache the user has for this record.
    datetime.

    """
    if not record:
        record = get_bibrecord(recid)
        if not record:
            return (None, None)

    record_revision = get_record_last_modification_date(recid)
    if record_revision is None:
        record_revision = datetime.now().timetuple()

    assert_undo_redo_lists_correctness(undo_list, redo_list)

    # Order subfields alphabetically after loading the record
    record_order_subfields(record)

    data = [
        cache_dirty, record_revision, record, pending_changes,
        disabled_hp_changes, undo_list, redo_list
    ]
    update_cache(recid, uid, data)
    return record_revision, record
示例#3
0
文件: utils.py 项目: mhellmic/b2share
def create_cache_file(recid, uid, record='', cache_dirty=False, pending_changes=[], disabled_hp_changes = {}, undo_list = [], redo_list=[]):
    """Create a BibEdit cache file, and return revision and record. This will
    overwrite any existing cache the user has for this record.
    datetime.

    """
    if not record:
        record = get_bibrecord(recid)
        if not record:
            return

    file_path = '%s.tmp' % _get_file_path(recid, uid)
    record_revision = get_record_last_modification_date(recid)
    if record_revision == None:
        record_revision = datetime.now().timetuple()

    cache_file = open(file_path, 'w')
    assert_undo_redo_lists_correctness(undo_list, redo_list)

    # Order subfields alphabetically after loading the record
    record_order_subfields(record)

    cPickle.dump([cache_dirty, record_revision, record, pending_changes, disabled_hp_changes, undo_list, redo_list], cache_file)
    cache_file.close()
    return record_revision, record
示例#4
0
def latest_record_revision(recid, revision_time):
    """Check if timetuple REVISION_TIME matches latest modification date."""
    latest = get_record_last_modification_date(recid)
    # this can be none if the record is new
    return latest is None or revision_time == latest
示例#5
0
def latest_record_revision(recid, revision_time):
    """Check if timetuple REVISION_TIME matches latest modification date."""
    latest = get_record_last_modification_date(recid)
    # this can be none if the record is new
    return latest is None or revision_time == latest