handlers.py

Go to the documentation of this file.
00001 from vyperlogix.misc import _utils
00002 from vyperlogix.hash import lists
00003 from vyperlogix.classes.SmartObject import SmartObject
00004 
00005 from vyperlogix.sql.sqlalchemy import SQLAgent
00006 
00007 __copyright__ = """\
00008 (c). Copyright 1990-2008, Vyper Logix Corp., All Rights Reserved.
00009 
00010 Published under Creative Commons License 
00011 (http://creativecommons.org/licenses/by-nc/3.0/) 
00012 restricted to non-commercial educational use only., 
00013 
00014 See also: http://www.VyperLogix.com and http://www.pypi.info for details.
00015 
00016 THE AUTHOR VYPER LOGIX CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO
00017 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
00018 FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
00019 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
00020 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00021 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
00022 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
00023 
00024 USE AT YOUR OWN RISK.
00025 """
00026 
00027 def handle_items(qry,callback=None,asSmartObject=False):
00028     items = []
00029     num_items = qry.count()
00030     num_items_part = num_items / 100
00031     num_items_part = num_items_part if (num_items_part > 0) else num_items
00032     for i in xrange(num_items):
00033         item = SQLAgent.instance_as_SmartObject(qry[i]) if (asSmartObject == True) else qry[i]
00034         items.append(item)
00035         if (i > 0) and ((i % num_items_part) == 0):
00036             print '%d of %d.' % (i,num_items)
00037             if (callable(callback)):
00038                 try:
00039                     callback(items,i,num_items)
00040                 finally:
00041                     items = []
00042     if (len(items) > 0):
00043         if (callable(callback)):
00044             try:
00045                 callback(items,num_items,num_items)
00046             finally:
00047                 items = []
00048     return items
00049 
00050 if (__name__ == '__main__'):
00051     import sys
00052     print >>sys.stdout, __copyright__
00053     print >>sys.stderr, __copyright__
00054 
00055 
00056 

© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."

Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.

122,241 lines of code and growing...