'Get property of Single DocType. Cache locally by default
:param doctype: DocType of the single object whose value is requested
:param fieldname: `fieldname` of the property whose value is requested
Example:
# Get the default value of the company from the Global Defaults doctype.
company = frappe.db.get_single_value(\'Global Defaults\', \'default_company\')'

def get_single_value(self, doctype, fieldname, cache=False):

    value = self.value_cache.setdefault(doctype, {}).get(fieldname)
    if value:
        return value
    val = self.sql(u'select    value    from\n DCTB  DCTB  DCTB tabSingles    where    doctype=%s    and    field=%s', (doctype, fieldname))
    val = (val[0][0] if val else None)
    if ((val == u'0') or (val == u'1')):
        val = int(val)
    self.value_cache[doctype][fieldname] = val
    return val
