# Path: canary/dtuple.py
# class TupleDescriptor:
# class DatabaseTuple:
#   def __init__(self, desc):
#   def __len__(self):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, desc, data):
#   def __str__(self):
#   def __repr__(self):
#   def __cmp__(self, other):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, key):
#   def __setitem__(self, key, value):
#   def __len__(self):
#   def __getslice__(self, i, j):
#   def __setslice__(self, i, j, list):
#   def _keys_(self):
#   def _has_key_(self, key):
#   def _items_(self):
#   def _count_(self, item):
#   def _index_(self, item):
#   def _getvalue_(self,name):
#   def asMapping(self):
#   def asTuple(self):
#   def asList(self):


import logging
import logging.handlers
import os
import pprint
import traceback
import MySQLdb
import PyLucene
import quixote.config
import canary.db_model
import canary.gazeteer
import canary.source_catalog
            import memcache
from canary import dtuple
    
    
    def load (self, context):
        # Can't load a new one; it hasn't been saved yet.
        if self.uid == -1:
            return

        # Is it already loaded?  Convenience check for client calls
        # don't need to verify loads from the cache.
        if context.config.use_cache:
            try:
                if getattr(self, self.CACHE_CHECK_FIELD):
                    # Already loaded
                    return
            except AttributeError:
                # Note already loaded, so continue
                pass
        
        self.load_from_db(context)


    def load_from_db (self, context):
        cursor = context.get_cursor()
        cursor.execute("""SELECT * FROM """ + self.TABLE_NAME + """
            WHERE uid = %s
            """, self.uid)
        fields = [d[0] for d in cursor.description]
        desc = dtuple.TupleDescriptor([[f] for f in fields])
        row = cursor.fetchone()
        if row:

# Path: canary/dtuple.py
# class TupleDescriptor:
# class DatabaseTuple:
#   def __init__(self, desc):
#   def __len__(self):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, desc, data):
#   def __str__(self):
#   def __repr__(self):
#   def __cmp__(self, other):
#   def __getattr__(self, name):
#   def __setattr__(self, name, value):
#   def __getitem__(self, key):
#   def __setitem__(self, key, value):
#   def __len__(self):
#   def __getslice__(self, i, j):
#   def __setslice__(self, i, j, list):
#   def _keys_(self):
#   def _has_key_(self, key):
#   def _items_(self):
#   def _count_(self, item):
#   def _index_(self, item):
#   def _getvalue_(self,name):
#   def asMapping(self):
#   def asTuple(self):
#   def asList(self):


# Path: canary/context.py
import logging
import logging.handlers
import os
import pprint
import traceback
import MySQLdb
import PyLucene
import quixote.config
import canary.db_model
import canary.gazeteer
import canary.source_catalog
            import memcache
from canary import dtuple

    
    
    def load (self, context):
        # Can't load a new one; it hasn't been saved yet.
        if self.uid == -1:
            return

        # Is it already loaded?  Convenience check for client calls
        # don't need to verify loads from the cache.
        if context.config.use_cache:
            try:
                if getattr(self, self.CACHE_CHECK_FIELD):
                    # Already loaded
                    return
            except AttributeError:
                # Note already loaded, so continue
                pass
        
        self.load_from_db(context)


    def load_from_db (self, context):
        cursor = context.get_cursor()
        cursor.execute("""SELECT * FROM """ + self.TABLE_NAME + """
            WHERE uid = %s
            """, self.uid)
        fields = [d[0] for d in cursor.description]
        desc = dtuple.TupleDescriptor([[f] for f in fields])
        row = cursor.fetchone()
        if row:

            row = dtuple.DatabaseTuple(desc, row)