'Determing if input is a valid dbref.
Args:
dbref (str or int): A possible dbref.
reqhash (bool, optional): If the "#" is required for this
to be considered a valid hash.
Returns:
dbref (int or None): The integer part of the dbref.
Notes:
Valid forms of dbref (database reference number) are
either a string \'#N\' or an integer N.'

def dbref(self, dbref, reqhash=True):

    if (reqhash and (not (isinstance(dbref, basestring) and dbref.startswith('#')))):
        return None
    if isinstance(dbref, basestring):
        dbref = dbref.lstrip('#')
    try:
        if (int(dbref) < 0):
            return None
    except Exception:
        return None
    return dbref
