Пример #1
0
def getResultsforBL(id=None, name=None, number=None):
    """
    Retrieve results using either BL id, name, or number (tried in that order)
    Returns a generator of results
    """
    if id is None:
        if name is None:
            key = 'number'
            val = number
        else:
            key = 'name'
            val = name

        query = {key: val}
        b = Beamline.objects(__raw__=query)

        id = _try0_dict_key(b, 'beamline', key, val, None, 'beamline_id')

        if id is None:
            yield None
            raise StopIteration

    for r in Result.objects(__raw__={'beamline_id': id}):
        yield r
Пример #2
0
def getBeamlineByNumber(num, as_mongo_obj=False):
    """eg. 17id1, 17id2, 16id1"""
    b = Beamline.objects(__raw__={'number': num})
    return _try0_maybe_mongo(b, 'beamline', 'number', num, None,
                             as_mongo_obj=as_mongo_obj)
Пример #3
0
def getBeamlineByID(beamline_id, as_mongo_obj=False):
    """beamline_id is the integer field 'beamline_id'"""
    b = Beamline.objects(__raw__={'beamline_id': beamline_id})
    return _try0_maybe_mongo(b, 'beamline', 'beamline_id', beamline_id, None,
                             as_mongo_obj=as_mongo_obj)
Пример #4
0
def getBeamlineByName(name, as_mongo_obj=False):
    """eg. fmx, xfp, chx..."""
    b = Beamline.objects(__raw__={'name': name})
    return _try0_maybe_mongo(b, 'beamline', 'name', name, None,
                             as_mongo_obj=as_mongo_obj)
Пример #5
0
def createBeamline(bl_name, bl_num):
    bl = Beamline(name=bl_name, number=bl_num)
    bl.save()