Example #1
0
def getRoomDescription(cursor, roomid):
    """
	Gets the room decription from the database.
	"""
    query = Q.GetRoomDescription % {DC.RoomID: roomid}
    res = pgDB.fetchOneValue(cursor, query)
    if not res:
        #FIXME We need an /unstick command that resets peoples location.
        res = "You seem to be stuck. Please contact an"\
        " administrator and tell them that you've gotten somewhere"\
        " you shouldn't be able to get to."
    return res
Example #2
0
def getRoomDescription(cursor, roomid):
	"""
	Gets the room decription from the database.
	"""
	query = Q.GetRoomDescription % {DC.RoomID: roomid}
	res = pgDB.fetchOneValue(cursor, query)
	if not res:
		#FIXME We need an /unstick command that resets peoples location.
		res = "You seem to be stuck. Please contact an"\
		" administrator and tell them that you've gotten somewhere"\
		" you shouldn't be able to get to."
	return res
Example #3
0
def getExits(cursor, roomid):
    query = Q.GetExits % {DC.RoomID: roomid}
    res = pgDB.fetchOneValue(cursor, query)
    try:
        exitDict = misc.getDict(res)
    except TypeError:
        # Area does not exist.
        print "ERROR! User attempted to go to room %s, which, "\
        "seemingly, does not exist." % roomid
    exits = {}
    for exit, data in exitDict.items():
        exits[lower(exit)] = data.split('|')
    return exits
Example #4
0
def getExits(cursor, roomid):
	query = Q.GetExits % {DC.RoomID: roomid}
	res = pgDB.fetchOneValue(cursor, query)
	try:
		 exitDict = misc.getDict(res)
	except TypeError:
		# Area does not exist.
		print "ERROR! User attempted to go to room %s, which, "\
		"seemingly, does not exist." % roomid
	exits = {}
	for exit, data in exitDict.items():
		exits[lower(exit)] = data.split('|')
	return exits
Example #5
0
def getUserData(cursor, userid, field = None):
	"""
	Return either one, some, or all of the fields in the UserData
	table for the given userid.
	"""
	if not field:
		query = Q.GetAllUserData % {DC.UserID: userid}
		res = pgDB.fetchDict(cursor, query)
		return res[0]
	else:
		if type(field) in (ListType, TupleType):
			field = ','.join(field)
			query = Q.GetUserData % (field, userid)
			return pgDB.fetchOne(cursor, query)
		else:
			query = Q.GetUserData % (field, userid)
			return pgDB.fetchOneValue(cursor, query)
Example #6
0
def getUserData(cursor, userid, field=None):
    """
	Return either one, some, or all of the fields in the UserData
	table for the given userid.
	"""
    if not field:
        query = Q.GetAllUserData % {DC.UserID: userid}
        res = pgDB.fetchDict(cursor, query)
        return res[0]
    else:
        if type(field) in (ListType, TupleType):
            field = ','.join(field)
            query = Q.GetUserData % (field, userid)
            return pgDB.fetchOne(cursor, query)
        else:
            query = Q.GetUserData % (field, userid)
            return pgDB.fetchOneValue(cursor, query)
Example #7
0
def getPasswordHash(cursor, userid):
	query = Q.GetPassword % {DC.UserID: userid}
	return pgDB.fetchOneValue(cursor, query)
Example #8
0
def getArea(cursor, roomid):
	query = Q.GetAreaID % {DC.RoomID: roomid}
	return pgDB.fetchOneValue(cursor, query)
Example #9
0
def getThreadID(cursor, userid):
	query = Q.GetThreadID % {DC.UserID: userid}
	return pgDB.fetchOneValue(cursor, query)
Example #10
0
def getLocation(cursor, userid):
	queryDict = {
		DC.UserID: userid,
	}
	query = Q.GetLocation % queryDict
	return pgDB.fetchOneValue(cursor, query)
Example #11
0
def getArea(cursor, roomid):
    query = Q.GetAreaID % {DC.RoomID: roomid}
    return pgDB.fetchOneValue(cursor, query)
Example #12
0
def getThreadID(cursor, userid):
    query = Q.GetThreadID % {DC.UserID: userid}
    return pgDB.fetchOneValue(cursor, query)
Example #13
0
def getUserLocation(cursor, userid):
    queryDict = {
        DC.UserID: userid,
    }
    query = Q.GetUserRoomID % queryDict
    return pgDB.fetchOneValue(cursor, query)
Example #14
0
def getPasswordHash(cursor, userid):
    query = Q.GetPassword % {DC.UserID: userid}
    return pgDB.fetchOneValue(cursor, query)