PKx¾š8/JJddturbojson/__init__.pyfrom turbojson import jsonsupport JsonSupport = jsonsupport.JsonSupport __all__ = ["JsonSupport"] PK[ 9±Ë%¹¹turbojson/jsonify.py"""JSON encoding functions using RuleDispatch.""" import datetime try: import decimal except ImportError: # Python 2.3 decimal = None import dispatch from simplejson import JSONEncoder from turbojson.prioritized_methods import PriorityDisambiguated try: from turbogears import config except ImportError: class config(object): _default = object() def get(cls, key, default=_default): if default is cls._default: raise KeyError(key) return default get = classmethod(get) # Global options descent_bases = True # Specific encoding functions def jsonify(obj): """Generic function for converting objects to JSON. Specific functions should return a string or an object that can be serialized with JSON, i.e., it is made up of only lists, dictionaries (with string keys), and strings, ints, and floats. """ raise NotImplementedError jsonify = dispatch.generic(PriorityDisambiguated)(jsonify) def jsonify_datetime(obj): """JSONify datetime and date objects.""" return str(obj) jsonify_datetime = jsonify.when( "isinstance(obj, (datetime.datetime, datetime.date))", prio=-1)( jsonify_datetime) def jsonify_decimal(obj): """JSONify decimal objects.""" return float(obj) if decimal: jsonify_decimal = jsonify.when( "isinstance(obj, decimal.Decimal)", prio=-1)(jsonify_decimal) def jsonify_explicit(obj): """JSONify objects with explicit JSONification method.""" return obj.__json__() jsonify_explicit = jsonify.when( "hasattr(obj, '__json__')", prio=-1)(jsonify_explicit) # SQLObject support try: from sqlobject import SQLObject def is_sqlobject(obj): return (isinstance(obj, SQLObject) and hasattr(obj.__class__, 'sqlmeta')) def jsonify_sqlobject(obj): """JSONify SQLObjects.""" result = {} result['id'] = obj.id keys = [] sm = obj.__class__.sqlmeta try: while sm is not None: # we need to exclude the ID-keys, as for some reason # this won't work for subclassed items keys.extend([key for key in sm.columns.keys() if key[-2:] != 'ID']) if descent_bases: sm = sm.__base__ else: sm = None except AttributeError: # this happens if we descent to pass for name in keys: result[name] = getattr(obj, name) return result jsonify_sqlobject = jsonify.when( "is_sqlobject(obj) and not hasattr(obj, '__json__')", prio=-1)( jsonify_sqlobject) try: SelectResultsClass = SQLObject.SelectResultsClass except AttributeError: pass else: def jsonify_select_results(obj): """JSONify SQLObject.SelectResults.""" return list(obj) jsonify_select_results = jsonify.when( "isinstance(obj, SelectResultsClass)", prio=-1)( jsonify_select_results) except ImportError: pass # SQLAlchemy support try: import sqlalchemy try: import sqlalchemy.ext.selectresults from sqlalchemy.util import OrderedProperties except ImportError: # SQLAlchemy >= 0.5 def is_saobject(obj): return hasattr(obj, '_sa_class_manager') def jsonify_saobject(obj): """JSONify SQLAlchemy objects.""" props = {} for key in obj.__dict__: if not key.startswith('_sa_'): props[key] = getattr(obj, key) return props jsonify_saobject = jsonify.when( "is_saobject(obj) and not hasattr(obj, '__json__')", prio=-1)( jsonify_saobject) else: # SQLAlchemy < 0.5 def is_saobject(obj): return (hasattr(obj, 'c') and isinstance(obj.c, OrderedProperties)) def jsonify_saobject(obj): """JSONify SQLAlchemy objects.""" props = {} for key in obj.c.keys(): props[key] = getattr(obj, key) return props jsonify_saobject = jsonify.when( "is_saobject(obj) and not hasattr(obj, '__json__')", prio=-1)( jsonify_saobject) try: from sqlalchemy.orm.attributes import InstrumentedList except ImportError: # SQLAlchemy >= 0.4 pass # normal lists are used here else: # SQLAlchemy < 0.4 def jsonify_instrumented_list(obj): """JSONify SQLAlchemy instrumented lists.""" return list(obj) jsonify_instrumented_list = jsonify.when( "isinstance(obj, InstrumentedList)", prio=-1)( jsonify_instrumented_list) except ImportError: pass # JSON Encoder class class GenericJSON(JSONEncoder): def __init__(self, **opts): opt = opts.pop('descent_bases', None) if opt is not None: global descent_bases descent_bases = opt super(GenericJSON, self).__init__(**opts) def default(self, obj): return jsonify(obj) _instance = GenericJSON() # General encoding functions def encode(obj): """Return a JSON string representation of a Python object.""" return _instance.encode(obj) def encode_iter(obj): """Encode object, yielding each string representation as available.""" return _instance.iterencode(obj) PK-£9† Ïyyturbojson/jsonsupport.py"""Template support for JSON""" from turbojson import jsonify class JsonSupport(object): encoding = 'utf-8' def __init__(self, extra_vars_func=None, options=None): opts = {} for option in options: if not option.startswith('json.'): continue opt = option[5:] if opt == 'encoding': self.encoding = options[option] or self.encoding else: if opt == 'assume_encoding': opt = 'encoding' opts[opt] = options[option] self.encoder = jsonify.GenericJSON(**opts) def render(self, info, format=None, fragment=False, template=None): """Renders data in the desired format. @param info: the data itself @type info: dict @param format: not used @type format: string @param fragment: not used @type fragment: bool @param template: not used @type template: string """ [info.pop(item) for item in info.copy() if (item.startswith("tg_") and item != "tg_flash")] output = self.encoder.encode(info) if isinstance(output, unicode): output = output.encode(self.encoding) return output def get_content_type(self, *args, **kw): # deprecated (not needed any more for TG > 1.0.4.4) return 'application/json' PKž9Šû£^^ turbojson/prioritized_methods.py""""prioritized_methods This is an extension to RuleDispatch to prioritize methods in order to avoid AmbiguousMethods situations. Copied from ToscaWidgets, thanks to Alberto Valverde Gonzalez. """ import sys from dispatch import strategy, functions from dispatch.interfaces import ICriterion, IDispatchPredicate, AmbiguousMethod from peak.util.decorators import decorate_assignment, frameinfo, decorate_class __all__ = ['PriorityDisambiguated', 'default_rule', 'generic'] try: set except NameError: # Python 2.3 from sets import Set as set default_rule = strategy.default def _prioritized_safe_methods(grouped_cases): """Yield methods in 'grouped_cases', strict version. Yield all methods in 'grouped_cases' including those in groups with more than one case (AmbiguousMethods) in the priority specified by the priority defined when decorating the method. Priorities must be distinct within a group of ambiguous methods or else an AmbiguousMethod will be raised. """ for group in grouped_cases: if len(group) > len(set([meth._prio for sig, meth in group])): yield AmbiguousMethod(group) break elif len(group) > 1: methods = [(-meth._prio, meth) for sig, meth in group] methods.sort() for prio, meth in methods: yield meth else: yield group[0][1] def _prioritized_all_methods(grouped_cases): """Yield methods in 'grouped_cases', loose version. Yield all methods in 'grouped_cases' including those in groups with more than one case (AmbiguousMethods) in the priority specified by the priority defined when decorating the method. """ for group in grouped_cases: methods = [(-meth._prio, meth) for sig, meth in group] methods.sort() for prio, meth in methods: yield meth class PriorityDisambiguated(functions.GenericFunction): """GenericFunction with additional priority parameter. Remimplementation of dispatch.functions.GenericFunction allowing the case decorators to specify a priority for ordering and disambiguation purposes. """ def combine(self, cases): """Combine method using priority-ordering generators. Same as GenericFunction.combine but replaces strategy.safe_methods and strategy.all_methods with priority-ordering generators. """ strict = [strategy.ordered_signatures, _prioritized_safe_methods] loose = [strategy.ordered_signatures, _prioritized_all_methods] cases = strategy.separate_qualifiers(cases, around=strict, before=loose, primary=strict, after=loose) primary = strategy.method_chain(cases.get('primary', [])) if cases.get('after') or cases.get('before'): befores = strategy.method_list(cases.get('before', [])) afters = strategy.method_list(list(cases.get('after', []))[::-1]) def chain(*args, **kw): for tmp in befores(*args, **kw): pass # toss return values result = primary(*args, **kw) for tmp in afters(*args, **kw): pass # toss return values return result else: chain = primary if cases.get('around'): chain = strategy.method_chain(list(cases['around']) + [chain]) return chain def around(self, cond, prio=0): """Add function as an 'around' method with 'cond' as a guard. If 'cond' is parseable, it will be parsed using the caller's frame locals and globals. """ return self._decorate(cond, 'around', prio=prio) def before(self, cond, prio=0): """Add function as a 'before' method with 'cond' as a guard. If 'cond' is parseable, it will be parsed using the caller's frame locals and globals. """ return self._decorate(cond, 'before', prio=prio) def after(self, cond, prio=0): """Add function as an 'after' method with 'cond' as a guard. If 'cond' is parseable, it will be parsed using the caller's frame locals and globals. """ return self._decorate(cond, 'after', prio=prio) def when(self, cond, prio=0): """Add following function to this generic one, with 'cond' as a guard. If 'cond' is parseable, it will be parsed using the caller's frame locals and globals. """ return self._decorate(cond, 'primary', prio=prio) def _decorate(self, cond, qualifier=None, frame=None, depth=2, prio=0): """Decorate method with priority parameter. Analogous to AbstractGeneric._decorate but accepts a priority parameter to attach as an attribute to the decorated method to aid in disambiguation/ordering. """ frame = frame or sys._getframe(depth) rule = cond cond = self.parseRule(cond, frame=frame) or cond def registerMethod(frm, name, value, old_locals): kind, module, locals_, globals_ = frameinfo(frm) if qualifier is None: func = value else: func = qualifier, value if kind == 'class': # 'when()' in class body; defer adding the method def registerClassSpecificMethod(cls): req = strategy.Signature( [(strategy.Argument(0), ICriterion(cls))]) self.addMethod(req & cond, func, prio=prio) return cls decorate_class(registerClassSpecificMethod, frame=frm) else: self.addMethod(cond, func, prio=prio) if old_locals.get(name) in (self, self.delegate): return self.delegate return value return decorate_assignment(registerMethod, frame=frame) def addMethod(self, predicate, function, qualifier=None, prio=0): if isinstance(function, tuple): function[1]._prio = prio else: function._prio = prio if qualifier is not None: function = qualifier, function for signature in IDispatchPredicate(predicate): self[signature] = function PKÈ 9™Þü))turbojson/__init__.pyc;ò ô£Hc@s#dklZeiZdgZdS((s jsonsupports JsonSupportN(s turbojsons jsonsupports JsonSupports__all__(s jsonsupports JsonSupports__all__((s+build\bdist.win32\egg\turbojson\__init__.pys?s  PKÈ 9Ê#ôáÓÓturbojson/jsonify.pyc;ò ~ °Hc@sûdZdkZy dkZWnej o eZnXdkZdklZdkl Z ydk l Z Wn)ej ode fd„ƒYZ nXe ad„Zeie ƒeƒZd„Zeid d d ƒeƒZd „Zeoeid d d ƒeƒZnd„Zeidd d ƒeƒZy…dklZd„Zd„Zeidd d ƒeƒZy eiZWnej on&Xd„Zeidd d ƒeƒZWnej onXyâdkZydkZdklZWn@ej o4d„Z d„Z!eidd d ƒe!ƒZ!nzXd„Z d„Z!eidd d ƒe!ƒZ!ydk"l#Z#Wnej on&Xd„Z$eidd d ƒe$ƒZ$Wnej onXdefd „ƒYZ%e%ƒZ&d!„Z'd"„Z(dS(#s+JSON encoding functions using RuleDispatch.N(s JSONEncoder(sPriorityDisambiguated(sconfigsconfigcBs)tZeƒZed„ZeeƒZRS(NcCs(||ijot|ƒ‚n|SdS(N(sdefaultsclss_defaultsKeyErrorskey(sclsskeysdefault((s*build\bdist.win32\egg\turbojson\jsonify.pysgets(s__name__s __module__sobjects_defaultsgets classmethod(((s*build\bdist.win32\egg\turbojson\jsonify.pysconfigs  cCs t‚dS(sÿGeneric function for converting objects to JSON. Specific functions should return a string or an object that can be serialized with JSON, i.e., it is made up of only lists, dictionaries (with string keys), and strings, ints, and floats. N(sNotImplementedError(sobj((s*build\bdist.win32\egg\turbojson\jsonify.pysjsonify!scCst|ƒSdS(s"JSONify datetime and date objects.N(sstrsobj(sobj((s*build\bdist.win32\egg\turbojson\jsonify.pysjsonify_datetime-ss3isinstance(obj, (datetime.datetime, datetime.date))sprioiÿÿÿÿcCst|ƒSdS(sJSONify decimal objects.N(sfloatsobj(sobj((s*build\bdist.win32\egg\turbojson\jsonify.pysjsonify_decimal5ss isinstance(obj, decimal.Decimal)cCs|iƒSdS(s3JSONify objects with explicit JSONification method.N(sobjs__json__(sobj((s*build\bdist.win32\egg\turbojson\jsonify.pysjsonify_explicit=sshasattr(obj, '__json__')(s SQLObjectcCs$t|tƒot|idƒSdS(Nssqlmeta(s isinstancesobjs SQLObjectshasattrs __class__(sobj((s*build\bdist.win32\egg\turbojson\jsonify.pys is_sqlobjectIscCsæh}|i|d= 0) and (number < 10)")(lambda s, x: 0) self.demo_func.when("(number >= 10) and (number < 20)")(lambda s, x: 10) self.demo_func.when("(number >= 20) and (number < 30)")(lambda s, x: 20) self.assertEqual(self.demo_func(3), 0) self.assertEqual(self.demo_func(13), 10) self.assertEqual(self.demo_func(23), 20) def test_non_prioritized_ambiguous(self): """Non-prioritized ambiguous methods are processed fine""" self.demo_func.when("(number >= 0) and (number <= 10)")(lambda s, x: 0) self.demo_func.when("(number >= 10) and (number < 20)")(lambda s, x: 10) self.demo_func.when("(number >= 20) and (number < 30)")(lambda s, x: 20) self.assertEqual(self.demo_func(3), 0) self.assertRaises(dispatch.AmbiguousMethod, self.demo_func, 10) self.assertEqual(self.demo_func(13), 10) self.assertEqual(self.demo_func(23), 20) def test_no_applicable_methods(self): """NoApplicableMethods is raised when it should""" self.demo_func.when("(number >= 0) and (number < 10)")(lambda s, x: 0) self.demo_func.when("(number >= 10) and (number < 20)")(lambda s, x: 10) self.demo_func.when("(number >= 20) and (number < 30)")(lambda s, x: 20) self.assertRaises(dispatch.NoApplicableMethods, self.demo_func, -1) #self.assertRaises(dispatch.NoApplicableMethods, self.demo_func, 33) # Fails with RuleDispatch pre r2240 def test_prioritized_ambiguous(self): """Prioritized ambiguous methods are processed fine""" self.demo_func.when("(number >= 0) and (number <= 10)",prio=1)( lambda s,x: 0 ) self.demo_func.when("(number >= 10) and (number < 20)")(lambda s, x: 10) self.demo_func.when("(number >= 20) and (number < 30)")(lambda s, x: 20) self.assertEqual(self.demo_func(3), 0) self.assertEqual(self.demo_func(10), 0) self.assertEqual(self.demo_func(13), 10) self.assertEqual(self.demo_func(23), 20) self.assertRaises(dispatch.NoApplicableMethods, self.demo_func, -1) #self.assertRaises(dispatch.NoApplicableMethods, self.demo_func, 33) # Fails with RuleDispatch pre r2240 def test_before(self): """Priority is respected when decorating with before""" def between_0_30(self, number): return number between_0_30 = self.demo_func.when( "(number >= 0) and (number < 30)")(between_0_30) def before_between_2_4(self, number): self.counter = number before_between_2_4 = self.demo_func.before( "(number >= 2) and (number < 4)")(before_between_2_4) def before_between_0_30_1(self, number): self.counter += number before_between_0_30_1 = self.demo_func.before( "(number >= 0) and (number < 30)", prio=1)(before_between_0_30_1) def before_between_0_30_2(self, number): self.counter *= number before_between_0_30_2 = self.demo_func.before( "(number >= 0) and (number < 30)")(before_between_0_30_2) self.assertEqual(self.demo_func(3), 3) self.assertEqual(self.counter, 18) PKÈ 9Šõ.turbojson/tests/__init__.pyc;ò ô£Hc@sdS(N((((s1build\bdist.win32\egg\turbojson\tests\__init__.pys?sPKÈ 9Iøf¨   turbojson/tests/test_jsonify.pyc;ò ô£Hc@sÎdklZdefd„ƒYZdefd„ƒYZdefd„ƒYZd„ZeiidƒeƒZd „Zd „Z d „Z d „Z d „Z d„Z d„Zd„Zd„Zd„ZdS((sjsonifysFoocBstZd„ZRS(NcCs ||_dS(N(sbarsself(sselfsbar((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys__init__s(s__name__s __module__s__init__(((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pysFoossBarcBstZd„Zd„ZRS(NcCs ||_dS(N(sbarsself(sselfsbar((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys__init__ scCsd|iSdS(Nsbar-%s(sselfsbar(sself((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys__json__ s(s__name__s __module__s__init__s__json__(((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pysBars sBazcBstZRS(N(s__name__s __module__(((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pysBazscCsd|iSdS(Nsfoo-%s(sobjsbar(sobj((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys jsonify_foossisinstance(obj, Foo)cCs9ddddg}ti|ƒ}|djpt‚dS(Nsaisbis["a", 1, "b", 2](sdsjsonifysencodesencodedsAssertionError(sencodedsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys test_listscCsNtdƒ}ti|ƒ}diti|ƒƒti|ƒjpt‚dS(Nis(srangesdsjsonifys encode_itersencodedsjoinsencodesAssertionError(sencodedsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_list_iters cCs?hdd<dd<}ti|ƒ}|djpt‚dS(Nsaisbis{"a": 1, "b": 2}(sdsjsonifysencodesencodedsAssertionError(sencodedsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_dictionary!scCs3tdƒ}ti|ƒ}|djpt‚dS(Nsbazs "foo-baz"(sFoosasjsonifysencodesencodedsAssertionError(sasencoded((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_specificjson&s cCs<tdƒ}|g}ti|ƒ}|djpt‚dS(Nsbazs ["foo-baz"](sFoosasdsjsonifysencodesencodedsAssertionError(sasencodedsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_specific_in_list+s  cCsBtdƒ}hd|<}ti|ƒ}|djpt‚dS(Nsbazsas{"a": "foo-baz"}(sFoosasdsjsonifysencodesencodedsAssertionError(sasencodedsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_specific_in_dict1s cCsXtƒ}yti|ƒ}Wn!tj o}|ii}nX|djpt ‚dS(NsNoApplicableMethods( sBazsbsjsonifysencodesencodeds Exceptionses __class__s__name__sAssertionError(sbsesencoded((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_nospecificjson7s  cCs3tdƒ}ti|ƒ}|djpt‚dS(Nsbqs"bar-bq"(sBarsbsjsonifysencodesencodedsAssertionError(sencodedsb((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_exlicitjson?s cCs<tdƒ}|g}ti|ƒ}|djpt‚dS(Nsbqs ["bar-bq"](sBarsbsdsjsonifysencodesencodedsAssertionError(sencodedsbsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_exlicitjson_in_listDs  cCsBtdƒ}hd|<}ti|ƒ}|djpt‚dS(Nsbqsbs{"b": "bar-bq"}(sBarsbsdsjsonifysencodesencodedsAssertionError(sencodedsbsd((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pystest_exlicitjson_in_dictJs N(s turbojsonsjsonifysobjectsFoosBarsBazs jsonify_fooswhens test_liststest_list_iterstest_dictionarystest_specificjsonstest_specific_in_liststest_specific_in_dictstest_nospecificjsonstest_exlicitjsonstest_exlicitjson_in_liststest_exlicitjson_in_dict(stest_nospecificjsonsBarstest_list_iterstest_exlicitjson_in_dictsjsonifysBazstest_specific_in_dictstest_specificjsonstest_exlicitjsonstest_exlicitjson_in_lists test_liststest_specific_in_liststest_dictionarys jsonify_foosFoo((s5build\bdist.win32\egg\turbojson\tests\test_jsonify.pys?s           PKÈ 9zBÈQãã"turbojson/tests/test_sqlobject.pyc;ò »cHc@sadklZyÿy dkZWndkZnXdklZlZlZlZdk l Z edƒe_ defd„ƒYZ e i ƒdefd„ƒYZei ƒd e fd „ƒYZei ƒd efd „ƒYZei ƒd efd„ƒYZei ƒWn*ej odklZedƒn&Xd„Zd„Zd„Zd„ZdS((sjsonifyN(ssqlhubsconnectionForURIs SQLObjects StringCol(sInheritableSQLObjectssqlite:/:memory:sPersoncBs/tZeƒZedddeƒZeƒZRS(Nslengthisdefault(s__name__s __module__s StringColsfnamesNonesmislname(((s7build\bdist.win32\egg\turbojson\tests\test_sqlobject.pysPerson s sExplicitPersoncBstZeƒZd„ZRS(NcCshdtSQLAlchemy or PySqlite not installed - cannot run these tests.cCsHtƒ}|itƒidƒ}ti|ƒ}|djpt ‚dS(Nis{"id": 1, "val": "bob"}( screate_sessionsssquerysTest1sgetstsjsonifysencodesencodedsAssertionError(ssstsencoded((s8build\bdist.win32\egg\turbojson\tests\test_sqlalchemy.pys test_saobj4s cCsKtƒ}|itƒidƒ}ti|iƒ}|djpt ‚dS(NisQ[{"test1id": 1, "id": 1, "val": "fred"}, {"test1id": 1, "id": 2, "val": "alice"}]( screate_sessionsssquerysTest1sgetstsjsonifysencodestest2ssencodedsAssertionError(ssstsencoded((s8build\bdist.win32\egg\turbojson\tests\test_sqlalchemy.pys test_salist:s cCsHtƒ}|itƒidƒ}ti|ƒ}|djpt ‚dS(Nis+{"id": 1, "val": "bob", "customized": true}( screate_sessionsssquerysTest3sgetstsjsonifysencodesencodedsAssertionError(ssstsencoded((s8build\bdist.win32\egg\turbojson\tests\test_sqlalchemy.pystest_explicit_saobjAs (!s turbojsonsjsonifyssqlite3s pysqlite2s sqlalchemysMetaDatasTablesColumns ForeignKeysIntegersStringssqlalchemy.ormscreate_sessionsmappersrelationsmetadatasTruestest1stest2stest3s create_allsobjectsTest2sTest1sTest3sinsertsexecutes ImportErrorswarningsswarns test_saobjs test_saliststest_explicit_saobj(stest1stest3stest2s test_salistsrelationsStrings ForeignKeyssqlite3sIntegers test_saobjsmetadatasColumnswarnscreate_sessionsTest1smappersTest3sTest2s pysqlite2sjsonifystest_explicit_saobjsTablesMetaData((s8build\bdist.win32\egg\turbojson\tests\test_sqlalchemy.pys?sF   +      " %..)   PKÈ 9Ÿ‰ Íîî,turbojson/tests/test_prioritized_methods.pyc;ò `±Hc@s=dklZdkZdklZdefd„ƒYZdS((sTestCaseN(sPriorityDisambiguatedsTestPriorityDisambiguatedcBs\tZd„Zd„ZeieƒeƒZd„Zd„Zd„Z d„Z d„Z RS(NcCs|iiƒd|_dS(Ni(sselfs demo_funcsclearscounter(sself((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pyssetUps cCsdS(N((sselfsnumber((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys demo_func scCsš|iidƒd„ƒ|iidƒd„ƒ|iidƒd„ƒ|i|idƒdƒ|i|id ƒd ƒ|i|id ƒd ƒd S(s(Non-ambiguous methods are processed fines(number >= 0) and (number < 10)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysss (number >= 10) and (number < 20)cCsdS(Ni ((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysss (number >= 20) and (number < 30)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pyssiii i iiN(sselfs demo_funcswhens assertEqual(sself((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pystest_no_ambiguousscCs³|iidƒd„ƒ|iidƒd„ƒ|iidƒd„ƒ|i|idƒdƒ|iti|id ƒ|i|id ƒd ƒ|i|id ƒd ƒd S(s4Non-prioritized ambiguous methods are processed fines (number >= 0) and (number <= 10)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysss (number >= 10) and (number < 20)cCsdS(Ni ((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysss (number >= 20) and (number < 30)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pyssiii i iiN(sselfs demo_funcswhens assertEquals assertRaisessdispatchsAmbiguousMethod(sself((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pystest_non_prioritized_ambiguousscCsh|iidƒd„ƒ|iidƒd„ƒ|iidƒd„ƒ|iti|idƒdS( s,NoApplicableMethods is raised when it shoulds(number >= 0) and (number < 10)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys'ss (number >= 10) and (number < 20)cCsdS(Ni ((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys(ss (number >= 20) and (number < 30)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys)siÿÿÿÿN(sselfs demo_funcswhens assertRaisessdispatchsNoApplicableMethods(sself((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pystest_no_applicable_methods%s cCsÒ|iidddƒd„ƒ|iidƒd„ƒ|iidƒd„ƒ|i|id ƒd ƒ|i|id ƒd ƒ|i|id ƒd ƒ|i|id ƒdƒ|iti|idƒdS(s0Prioritized ambiguous methods are processed fines (number >= 0) and (number <= 10)sprioicCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys1ss (number >= 10) and (number < 20)cCsdS(Ni ((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys3ss (number >= 20) and (number < 30)cCsdS(Ni((sssx((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys4siii i iiiÿÿÿÿN(sselfs demo_funcswhens assertEquals assertRaisessdispatchsNoApplicableMethods(sself((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pystest_prioritized_ambiguous.scCsºd„}|iidƒ|ƒ}d„}|iidƒ|ƒ}d„}|iidddƒ|ƒ}d„}|iidƒ|ƒ}|i|id ƒd ƒ|i|i d ƒd S( s1Priority is respected when decorating with beforecCs|SdS(N(snumber(sselfsnumber((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys between_0_30@ss(number >= 0) and (number < 30)cCs ||_dS(N(snumbersselfscounter(sselfsnumber((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysbefore_between_2_4Ess(number >= 2) and (number < 4)cCs|i|7_dS(N(sselfscountersnumber(sselfsnumber((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysbefore_between_0_30_1JssprioicCs|i|9_dS(N(sselfscountersnumber(sselfsnumber((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysbefore_between_0_30_2OsiiN( s between_0_30sselfs demo_funcswhensbefore_between_2_4sbeforesbefore_between_0_30_1sbefore_between_0_30_2s assertEqualscounter(sselfsbefore_between_0_30_1sbefore_between_2_4s between_0_30sbefore_between_0_30_2((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys test_before=s    ( s__name__s __module__ssetUps demo_funcsdispatchsgenericsPriorityDisambiguatedstest_no_ambiguousstest_non_prioritized_ambiguousstest_no_applicable_methodsstest_prioritized_ambiguouss test_before(((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pysTestPriorityDisambiguateds   (sunittestsTestCasesdispatchsturbojson.prioritized_methodssPriorityDisambiguatedsTestPriorityDisambiguated(sTestCasesTestPriorityDisambiguatedsPriorityDisambiguatedsdispatch((sAbuild\bdist.win32\egg\turbojson\tests\test_prioritized_methods.pys?s   PKÈ 9¦ú­îîîEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TurboJson Version: 1.1.4 Summary: Python template plugin that supports JSON Home-page: http://docs.turbogears.org/TurboJson Author: TurboGears project Author-email: turbogears@googlegroups.com License: MIT Download-URL: http://pypi.python.org/pypi/TurboJson Description: UNKNOWN Keywords: python.templating.engines,turbogears Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: TurboGears Classifier: Environment :: Web Environment :: Buffet Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: Software Development :: Libraries :: Python Modules PKÈ 9v$ÖN))EGG-INFO/SOURCES.txtREADME.txt release_howto.txt setup.cfg setup.py TurboJson.egg-info/PKG-INFO TurboJson.egg-info/SOURCES.txt TurboJson.egg-info/dependency_links.txt TurboJson.egg-info/entry_points.txt TurboJson.egg-info/not-zip-safe TurboJson.egg-info/requires.txt TurboJson.egg-info/top_level.txt turbojson/__init__.py turbojson/jsonify.py turbojson/jsonsupport.py turbojson/prioritized_methods.py turbojson/tests/__init__.py turbojson/tests/test_jsonify.py turbojson/tests/test_prioritized_methods.py turbojson/tests/test_sqlalchemy.py turbojson/tests/test_sqlobject.pyPKÈ 9“×2EGG-INFO/dependency_links.txt PKÈ 9F ­jQQEGG-INFO/entry_points.txt [python.templating.engines] json = turbojson.jsonsupport:JsonSupport PKocÎ8“×2EGG-INFO/not-zip-safe PKÈ 9w)vãGGEGG-INFO/requires.txtDecoratorTools >= 1.4 RuleDispatch >= 0.5a0.dev-r2303 simplejson >= 1.3PKÈ 9þÊ_ EGG-INFO/top_level.txtturbojson PKx¾š8/JJdd¶turbojson/__init__.pyPK[ 9±Ë%¹¹¶—turbojson/jsonify.pyPK-£9† Ïyy¶‚turbojson/jsonsupport.pyPKž9Šû£^^ ¶1turbojson/prioritized_methods.pyPKÈ 9™Þü))¶Í5turbojson/__init__.pycPKÈ 9Ê#ôáÓÓ¶*7turbojson/jsonify.pycPKÈ 9†gõ2ŽŽ¶0Vturbojson/jsonsupport.pycPKÈ 9•]ÞË{${$!¶õ^turbojson/prioritized_methods.pycPKx¾š8€Œ¥¶¯ƒturbojson/tests/__init__.pyPKx¾š8\ê9ʹ¶êƒturbojson/tests/test_jsonify.pyPKqŽÚ8óñPµµ!¶àŠturbojson/tests/test_sqlobject.pyPKs¥Ó8±ßÊ22"¶Ô“turbojson/tests/test_sqlalchemy.pyPK:9~o„&¬¬+¶Fœturbojson/tests/test_prioritized_methods.pyPKÈ 9Šõ.¶;«turbojson/tests/__init__.pycPKÈ 9Iøf¨   ¶ö«turbojson/tests/test_jsonify.pycPKÈ 9zBÈQãã"¶=Âturbojson/tests/test_sqlobject.pycPKÈ 9¢Õ3œÍÍ#¶`Õturbojson/tests/test_sqlalchemy.pycPKÈ 9Ÿ‰ Íîî,¶nåturbojson/tests/test_prioritized_methods.pycPKÈ 9¦ú­îîEGG-INFO/PKG-INFOPKÈ 9v$ÖN))¶ÃEGG-INFO/SOURCES.txtPKÈ 9“×2¶EGG-INFO/dependency_links.txtPKÈ 9F ­jQQ¶ZEGG-INFO/entry_points.txtPKocÎ8“×2¶âEGG-INFO/not-zip-safePKÈ 9w)vãGG¶ EGG-INFO/requires.txtPKÈ 9þÊ_ ¶ EGG-INFO/top_level.txtPK4Î