Hi,
I am trying to set up api with django-piston handler method. But the
code is not very stable. Sometimes web request (site/api/locations/
aggregated/) can get the data, sometimes it crashes with "maximum
recursion depth exceeded while calling a Python object" error. I am
wondering if anybody can shed some light on this.
Django: 1.2.1
piston: 0.2.2
python: 2.6.5
The models:
class Service(models.Model):
serviceid = models.AutoField(primary_key=True,
verbose_name="Service ID")
.....
locationid = models.ForeignKey('Location',db_column='locationid',
related_name='services',verbose_name="Location",
help_text="required") .......
class Location(models.Model):
locationid = models.AutoField(primary_key=True,
verbose_name="Location ID")
name = models.CharField(max_length=255,null=False, blank=False,
help_text="required",verbose_name="Location Name" )
locationtypeid = models.ForeignKey('Locationtype',
db_column='locationtypeid',
help_text="required",verbose_name="Location Type")
.....
(I only included the relevant fields in this post)
handler.py:
class LocationAggregateHandler(BaseHandler):
allowed_methods = ('GET',)
fields = ('locationid',....'
'locationtypeid',
('services',
('serviceid',....,
'locationid',
)
),
)
model = Location
@classmethod
def locationtypeid(cls, sfk):
return sfk.locationtypeid.locationtypeid
def read(self, name=None):
return self.model.objects.all()
My guess is the locationid field within the services subclass. It
might confuse the emitters.py code and trigger the infinite recursive
loop. But then why sometimes it works?
Thanks for your help.
Wayne
And this is the excerpt of the debugging output:
RuntimeError at /api/locations/aggregated/
maximum recursion depth exceeded while calling a Python object
Request Method: GET
Request URL:
Django Version: 1.2.1
Exception Type: RuntimeError
Exception Value:
maximum recursion depth exceeded while calling a Python object
Exception Location: /opt/python2.6/lib/python2.6/site-packages/django/
db/models/fields/subclassing.py in inner, line 53
Python Executable: /usr/bin/python
Python Version: 2.6.5
Python Path: ['/opt/python2.6/lib/python2.6/site-packages/
setuptools-0.6c9-py2.6.egg', '/opt/python2.6/lib/python2.6/site-
packages/django_piston-0.2.2-py2.6.egg', '/opt/python2.6/lib/python2.6/
site-packages/cx_Oracle-5.0.3-py2.6-linux-i686.egg', '/opt/python2.6/
lib/python26.zip', '/opt/python2.6/lib/python2.6', '/opt/python2.6/lib/
python2.6/plat-linux2', '/opt/python2.6/lib/python2.6/lib-tk', '/opt/
python2.6/lib/python2.6/lib-old', '/opt/python2.6/lib/python2.6/lib-
dynload', '/opt/python2.6/lib/python2.6/site-packages', ...]
Server time: Fri, 4 Jun 2010 09:35:10 -0400
Traceback Switch to copy-and-paste view
* /opt/python2.6/lib/python2.6/site-packages/django/core/handlers/
base.py in get_response
93. # Apply view middleware
94. for middleware_method in self._view_middleware:
95. response = middleware_method(request, callback,
callback_args, callback_kwargs)
96. if response:
97. return response
98.
99. try:
100. response = callback(request, *callback_args,
**callback_kwargs) ...
101. except Exception, e:
102. # If the view raised an exception, run it through
exception
103. # middleware, and if the exception middleware returns a
104. # response, use that. Otherwise, reraise the exception.
105. for middleware_method in self._exception_middleware:
106. response = middleware_method(request, e)
? Local vars
Variable Value
callback
<piston.resource.Resource object at 0x9b5586c>
callback_args
()
callback_kwargs
{'emitter_format': 'json'}
e
RuntimeError('maximum recursion depth exceeded while calling a
Python object',)
exc_info
(<type 'exceptions.RuntimeError'>, RuntimeError('maximum
recursion depth exceeded while calling a Python object',), <traceback
object at 0xb2140f4>)
exceptions
<module 'django.core.exceptions' from '/opt/python2.6/lib/
python2.6/site-packages/django/core/exceptions.pyc'>
middleware_method
<bound method RemoteUserMiddleware.process_request of
<django.contrib.auth.middleware.RemoteUserMiddleware object at
0x963744c>>
receivers
[(<function _rollback_on_exception at 0x97153e4>, None)]
request
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:
{}, META:{'DOCUMENT_ROOT': '/var/www/html', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'HTTP_KEEP_ALIVE':
'115', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)',
'PATH_INFO': u'/api/locations/aggregated/', 'PATH_TRANSLATED':
'QUERY_STRING': '', 'REMOTE_ADDR': '76.106.61.190', 'REMOTE_PORT':
'2469', 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/api/locations/
aggregated/', 'SCRIPT_FILENAME': 'SCRIPT_NAME': u'', 'SCRIPT_URI':
'SCRIPT_URL': '/api/locations/aggregated/', 'SERVER_ADDR':
'192.168.100.71', 'SERVER_ADMIN': 'root@localhost', 'SERVER_NAME':
'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.3 (Red Hat) Server at Port
80</address>\n', 'SERVER_SOFTWARE': 'Apache/2.2.3 (Red Hat)',
'mod_wsgi.application_group': '', 'mod_wsgi.callable_object':
'application', 'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80', 'mod_wsgi.process_group':
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 2),
'wsgi.errors': <mod_wsgi.Log object at 0xc43aa70>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter
object at 0x99ac2f0>, 'wsgi.input': <mod_wsgi.Input object at
0xc43a688>, 'wsgi.multiprocess': True, 'wsgi.multithread': True,
'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1,
1)}>
resolver
<RegexURLResolver Explore_Maps.urls (None:None) ^/>
response
None
self
<django.core.handlers.wsgi.WSGIHandler object at 0xa6ec22cc>
settings
<django.conf.LazySettings object at 0x94b8b4c>
urlconf
'Explore_Maps.urls'
urlresolvers
<module 'django.core.urlresolvers' from '/opt/python2.6/lib/
python2.6/site-packages/django/core/urlresolvers.pyc'>
* /opt/python2.6/lib/python2.6/site-packages/django/views/
decorators/vary.py in inner_func
15. def index(request):
16. ...
17.
18. Note that the header names are not case-sensitive.
19. """
20. def decorator(func):
21. def inner_func(*args, **kwargs):
22. response = func(*args, **kwargs) ...
23. patch_vary_headers(response, headers)
24. return response
25. return wraps(func, assigned=available_attrs(func))
(inner_func)
26. return decorator
27.
28. def vary_on_cookie(func):
? Local vars
Variable Value
args
(<piston.resource.Resource object at 0x9b5586c>, <WSGIRequest
GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{}, META:
{'DOCUMENT_ROOT': '/var/www/html', 'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'HTTP_KEEP_ALIVE':
'115', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)',
'PATH_INFO': u'/api/locations/aggregated/',
'PATH_TRANSLATED':'QUERY_STRING': '', 'REMOTE_ADDR': '76.106.61.190',
'REMOTE_PORT': '2469', 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/api/
locations/aggregated/', 'SCRIPT_FILENAME': 'SCRIPT_NAME': u'',
'SCRIPT_URI': 'SCRIPT_URL': '/api/locations/aggregated/',
'SERVER_ADDR': '192.168.100.71', 'SERVER_ADMIN': 'root@localhost',
'SERVER_NAME': 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.3 (Red Hat) Server at Port
80</address>\n', 'SERVER_SOFTWARE': 'Apache/2.2.3 (Red Hat)',
'mod_wsgi.application_group': '', 'mod_wsgi.callable_object':
'application', 'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80', 'mod_wsgi.process_group':
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 2),
'wsgi.errors': <mod_wsgi.Log object at 0xc43aa70>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter
object at 0x99ac2f0>, 'wsgi.input': <mod_wsgi.Input object at
0xc43a688>, 'wsgi.multiprocess': True, 'wsgi.multithread': True,
'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1,
1)}>)
func
<function __call__ at 0x9b508b4>
headers
('Authorization',)
kwargs
{'emitter_format': 'json'}
* build/bdist.linux-i686/egg/piston/resource.py in __call__
165. """
166. Decide whether or not we want a generator here,
167. or we just want to buffer up the entire result
168. before sending it to the client. Won't matter for
169. smaller datasets, but larger will have an impact.
170. """
171. if self.stream: stream = srl.stream_render(request)
172. else: stream = srl.render(request) ...
173.
174. resp = HttpResponse(stream, mimetype=ct)
175.
176. resp.streaming = self.stream
177.
178. return resp
? Local vars
Variable Value
anonymous
False
args
()
ct
'application/json; charset=utf-8'
em_format
'json'
emitter
<class 'piston.emitters.JSONEmitter'>
handler
<Explore_Maps.api.handler.LocationAggregateHandler object at
0x9b556ec>
kwargs
{}
meth
<bound method LocationAggregateHandler.read of
<Explore_Maps.api.handler.LocationAggregateHandler object at
0x9b556ec>>
request
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:
{}, META:{'DOCUMENT_ROOT': '/var/www/html', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'HTTP_KEEP_ALIVE':
'115', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)',
'PATH_INFO': u'/api/locations/aggregated/', 'PATH_TRANSLATED':
'QUERY_STRING': '', 'REMOTE_ADDR': '76.106.61.190', 'REMOTE_PORT':
'2469', 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/api/locations/
aggregated/', 'SCRIPT_FILENAME': 'SCRIPT_NAME': u'', 'SCRIPT_URI':
'SCRIPT_URL': '/api/locations/aggregated/', 'SERVER_ADDR':
'192.168.100.71', 'SERVER_ADMIN': 'root@localhost', 'SERVER_NAME':
'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.3 (Red Hat) Server at Port
80</address>\n', 'SERVER_SOFTWARE': 'Apache/2.2.3 (Red Hat)',
'mod_wsgi.application_group': '', 'mod_wsgi.callable_object':
'application', 'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80', 'mod_wsgi.process_group':
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 2),
'wsgi.errors': <mod_wsgi.Log object at 0xc43aa70>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter
object at 0x99ac2f0>, 'wsgi.input': <mod_wsgi.Input object at
0xc43a688>, 'wsgi.multiprocess': True, 'wsgi.multithread': True,
'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1,
1)}>
result
[<Location: Ryan Hall>, <Location: Mulledy Building>, <Location:
Gervase Building>, <Location: McSherry Building>, <Location: Village
C>, <Location: Lauinger Library>, <Location: Village A>, <Location:
New South>, <Location: McDonough Gymnasium>, <Location: Heating and
Cooling Plant>, <Location: Observatory>, <Location: Yates Field
House>, <Location: Poulton Hall>, <Location: University Press>,
<Location: Reed Alumni Residence>, <Location: Alumni Square (Village
B)>, <Location: Robert and Bernice Wagner Alumni House>, <Location:
Institute of Diplomacy>, <Location: Academic Administration>,
<Location: Academic Administration>, '...(remaining elements
truncated)...']
rm
'GET'
self
<piston.resource.Resource object at 0x9b5586c>
srl
<piston.emitters.JSONEmitter object at 0x122f5d8c>
* build/bdist.linux-i686/egg/piston/emitters.py in render
360.
361. class JSONEmitter(Emitter):
362. """
363. JSON emitter, understands timestamps.
364. """
365. def render(self, request):
366. cb = request.GET.get('callback')
367. seria = simplejson.dumps(self.construct(),
cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4) ...
368.
369. # Callback
370. if cb:
371. return '%s(%s)' % (cb, seria)
372.
373. return seria
? Local vars
Variable Value
cb
None
request
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:
{}, META:{'DOCUMENT_ROOT': '/var/www/html', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'HTTP_KEEP_ALIVE':
'115', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)',
'PATH_INFO': u'/api/locations/aggregated/', 'PATH_TRANSLATED':
'QUERY_STRING': '', 'REMOTE_ADDR': '76.106.61.190', 'REMOTE_PORT':
'2469', 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/api/locations/
aggregated/', 'SCRIPT_FILENAME': 'SCRIPT_NAME': u'', 'SCRIPT_URI':
'SCRIPT_URL': '/api/locations/aggregated/', 'SERVER_ADDR':
'192.168.100.71', 'SERVER_ADMIN': 'root@localhost', 'SERVER_NAME':
'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.3 (Red Hat) Server at Port
80</address>\n', 'SERVER_SOFTWARE': 'Apache/2.2.3 (Red Hat)',
'mod_wsgi.application_group': '', 'mod_wsgi.callable_object':
'application', 'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80', 'mod_wsgi.process_group':
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 2),
'wsgi.errors': <mod_wsgi.Log object at 0xc43aa70>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter
object at 0x99ac2f0>, 'wsgi.input': <mod_wsgi.Input object at
0xc43a688>, 'wsgi.multiprocess': True, 'wsgi.multithread': True,
'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1,
1)}>
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
* build/bdist.linux-i686/egg/piston/emitters.py in construct
269. def _dict(data):
270. """
271. Dictionaries.
272. """
273. return dict([ (k, _any(v)) for k, v in data.iteritems() ])
274.
275. # Kickstart the seralizin'.
276. return _any(self.data, self.fields) ...
277.
278. def in_typemapper(self, model, anonymous):
279. for klass, (km, is_anon) in self.typemapper.iteritems():
280. if model is km and is_anon is anonymous:
281. return klass
282.
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_dict
<function _dict at 0xb2027d4>
_fk
<function _fk at 0xb202844>
_list
<function _list at 0xb2028ec>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_qs
<function _qs at 0xb2029cc>
_related
<function _related at 0xb20217c>
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
* build/bdist.linux-i686/egg/piston/emitters.py in _any
84. def _any(thing, fields=()):
85. """
86. Dispatch, all types are routed through here.
87. """
88. ret = None
89.
90. if isinstance(thing, QuerySet):
91. ret = _qs(thing, fields=fields) ...
92. elif isinstance(thing, (tuple, list)):
93. ret = _list(thing)
94. elif isinstance(thing, dict):
95. ret = _dict(thing)
96. elif isinstance(thing, decimal.Decimal):
97. ret = str(thing)
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_dict
<function _dict at 0xb2027d4>
_list
<function _list at 0xb2028ec>
_model
<function _model at 0xb2021b4>
_qs
<function _qs at 0xb2029cc>
fields
('locationid', 'name', 'code', 'description', 'datebuilt',
'history', 'sortorder', 'longitude', 'latitude', 'mainimageurl',
'videoimagestring', 'videostring', 'imagetag', 'physicaladdress',
'city', 'state', 'zipcode', 'country', 'locationtypeid', ('services',
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')))
ret
None
thing
[<Location: Ryan Hall>, <Location: Mulledy Building>, <Location:
Gervase Building>, <Location: McSherry Building>, <Location: Village
C>, <Location: Lauinger Library>, <Location: Village A>, <Location:
New South>, <Location: McDonough Gymnasium>, <Location: Heating and
Cooling Plant>, <Location: Observatory>, <Location: Yates Field
House>, <Location: Poulton Hall>, <Location: University Press>,
<Location: Reed Alumni Residence>, <Location: Alumni Square (Village
B)>, <Location: Robert and Bernice Wagner Alumni House>, <Location:
Institute of Diplomacy>, <Location: Academic Administration>,
<Location: Academic Administration>, '...(remaining elements
truncated)...']
* build/bdist.linux-i686/egg/piston/emitters.py in _qs
254.
255. return ret
256.
257. def _qs(data, fields=()):
258. """
259. Querysets.
260. """
261. return [ _any(v, fields) for v in data ] ...
262.
263. def _list(data):
264. """
265. Lists.
266. """
267. return [ _any(v) for v in data ]
? Local vars
Variable Value
_[1]
[]
_any
<function _any at 0xa7c1ae4>
data
[<Location: Ryan Hall>, <Location: Mulledy Building>, <Location:
Gervase Building>, <Location: McSherry Building>, <Location: Village
C>, <Location: Lauinger Library>, <Location: Village A>, <Location:
New South>, <Location: McDonough Gymnasium>, <Location: Heating and
Cooling Plant>, <Location: Observatory>, <Location: Yates Field
House>, <Location: Poulton Hall>, <Location: University Press>,
<Location: Reed Alumni Residence>, <Location: Alumni Square (Village
B)>, <Location: Robert and Bernice Wagner Alumni House>, <Location:
Institute of Diplomacy>, <Location: Academic Administration>,
<Location: Academic Administration>, '...(remaining elements
truncated)...']
fields
('locationid', 'name', 'code', 'description', 'datebuilt',
'history', 'sortorder', 'longitude', 'latitude', 'mainimageurl',
'videoimagestring', 'videostring', 'imagetag', 'physicaladdress',
'city', 'state', 'zipcode', 'country', 'locationtypeid', ('services',
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')))
v
<Location: Ryan Hall>
* build/bdist.linux-i686/egg/piston/emitters.py in _any
92. elif isinstance(thing, (tuple, list)):
93. ret = _list(thing)
94. elif isinstance(thing, dict):
95. ret = _dict(thing)
96. elif isinstance(thing, decimal.Decimal):
97. ret = str(thing)
98. elif isinstance(thing, Model):
99. ret = _model(thing, fields=fields) ...
100. elif isinstance(thing, HttpResponse):
101. raise HttpStatusCode(thing)
102. elif inspect.isfunction(thing):
103. if not inspect.getargspec(thing)[0]:
104. ret = _any(thing())
105. elif hasattr(thing, '__emittable__'):
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_dict
<function _dict at 0xb2027d4>
_list
<function _list at 0xb2028ec>
_model
<function _model at 0xb2021b4>
_qs
<function _qs at 0xb2029cc>
fields
('locationid', 'name', 'code', 'description', 'datebuilt',
'history', 'sortorder', 'longitude', 'latitude', 'mainimageurl',
'videoimagestring', 'videostring', 'imagetag', 'physicaladdress',
'city', 'state', 'zipcode', 'country', 'locationtypeid', ('services',
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')))
ret
None
thing
<Location: Ryan Hall>
* build/bdist.linux-i686/egg/piston/emitters.py in _model
194.
195. if isinstance(maybe_field, (list, tuple)):
196. model, fields = maybe_field
197. inst = getattr(data, model, None)
198.
199. if inst:
200. if hasattr(inst, 'all'):
201. ret[model] = _related(inst, fields) ...
202. elif callable(inst):
203. if len(inspect.getargspec(inst)[0]) == 1:
204. ret[model] = _any(inst(), fields)
205. else:
206. ret[model] = _model(inst, fields)
207.
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_fk
<function _fk at 0xb202844>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_related
<function _related at 0xb20217c>
data
<Location: Ryan Hall>
f
<django.db.models.fields.CharField object at 0x98706ec>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
get_absolute_uri
False
get_fields
set(['locationid', 'locationtypeid', ('services', ('serviceid',
'name', 'acronym', 'subtitle', 'servicetypeid', 'locationid',
'sortorder', 'room', 'mailingaddress', 'boxnumber', 'city', 'state',
'zipcode', 'country', 'phonenumber', 'faxnumber', 'email',
'description', 'website'))])
handler
<class 'Explore_Maps.api.handler.LocationAggregateHandler'>
inst
<django.db.models.fields.related.RelatedManager object at
0x122f5cec>
maybe
31
maybe_field
('services', ('serviceid', 'name', 'acronym', 'subtitle',
'servicetypeid', 'locationid', 'sortorder', 'room', 'mailingaddress',
'boxnumber', 'city', 'state', 'zipcode', 'country', 'phonenumber',
'faxnumber', 'email', 'description', 'website'))
met_fields
{'locationtypeid': <bound method HandlerMetaClass.locationtypeid
of <class 'Explore_Maps.api.handler.LocationAggregateHandler'>>}
model
'services'
p
'country'
ret
{'city': u'', 'code': u'J07', 'country': u'United States',
'datebuilt': u'1904', 'description': u'', 'history': u'', 'imagetag':
u'DC:coverage=RyanHall', 'latitude': '38.90685000', 'locationid': 31,
'locationtypeid': 1, 'longitude': '-77.07321600', 'mainimageurl':
u'
http://farm5.static.flickr.com/4072/4386018957_f2bd1fd13b_m.jpg',
'name': u'Ryan Hall', 'physicaladdress': u'', 'sortorder': 0, 'state':
u'', 'videoimagestring': u'', 'videostring': u'', 'zipcode': u''}
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
v
<function <lambda> at 0x9e76684>
* build/bdist.linux-i686/egg/piston/emitters.py in _related
117. """
118. return _any(getattr(data,
field.name))
119.
120. def _related(data, fields=()):
121. """
122. Foreign keys.
123. """
124. return [ _model(m, fields) for m in data.iterator() ] ...
125.
126. def _m2m(data, field, fields=()):
127. """
128. Many to many (re-route to `_model`.)
129. """
130. return [ _model(m, fields) for m in getattr(data,
field.name).iterator() ]
? Local vars
Variable Value
_[1]
[]
_model
<function _model at 0xb2021b4>
data
<django.db.models.fields.related.RelatedManager object at
0x122f5cec>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
m
<Service: Woodstock Theological Center>
* build/bdist.linux-i686/egg/piston/emitters.py in _model
176. if f.serialize and not any([ p in met_fields for p in
[ f.attname,
f.name ]]):
177. if not f.rel:
178. if f.attname in get_fields:
179. ret[f.attname] = _any(v(f))
180. get_fields.remove(f.attname)
181. else:
182. if f.attname[:-3] in get_fields:
183. ret[
f.name] = _fk(data, f) ...
184. get_fields.remove(
f.name)
185.
186. for mf in data._meta.many_to_many:
187. if mf.serialize and mf.attname not in met_fields:
188. if mf.attname in get_fields:
189. ret[
mf.name] = _m2m(data, mf)
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_fk
<function _fk at 0xb202844>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_related
<function _related at 0xb20217c>
data
<Service: Woodstock Theological Center>
f
<django.db.models.fields.related.ForeignKey object at 0x9874a2c>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
get_absolute_uri
False
get_fields
set(['boxnumber', 'city', 'country', 'description', 'email',
'faxnumber', 'locationid', 'mailingaddress', 'phonenumber', 'room',
'serviceid', 'sortorder', 'state', 'website', 'zipcode'])
handler
<class 'Explore_Maps.api.handler.ServiceAggregateHandler'>
met_fields
{}
p
'locationid'
ret
{'acronym': u'', 'name': u'Woodstock Theological Center',
'servicetypeid': {'_state': u'<django.db.models.base.ModelState object
at 0xa74874c>', 'name': u'Academics and research', 'servicetypeid': 1,
'sortorder': 1}, 'subtitle': u''}
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
v
<function <lambda> at 0x9e76b1c>
* build/bdist.linux-i686/egg/piston/emitters.py in _fk
111.
112. return ret
113.
114. def _fk(data, field):
115. """
116. Foreign keys.
117. """
118. return _any(getattr(data,
field.name)) ...
119.
120. def _related(data, fields=()):
121. """
122. Foreign keys.
123. """
124. return [ _model(m, fields) for m in data.iterator() ]
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
data
<Service: Woodstock Theological Center>
field
<django.db.models.fields.related.ForeignKey object at 0x9874a2c>
* build/bdist.linux-i686/egg/piston/emitters.py in _any
92. elif isinstance(thing, (tuple, list)):
93. ret = _list(thing)
94. elif isinstance(thing, dict):
95. ret = _dict(thing)
96. elif isinstance(thing, decimal.Decimal):
97. ret = str(thing)
98. elif isinstance(thing, Model):
99. ret = _model(thing, fields=fields) ...
100. elif isinstance(thing, HttpResponse):
101. raise HttpStatusCode(thing)
102. elif inspect.isfunction(thing):
103. if not inspect.getargspec(thing)[0]:
104. ret = _any(thing())
105. elif hasattr(thing, '__emittable__'):
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_dict
<function _dict at 0xb2027d4>
_list
<function _list at 0xb2028ec>
_model
<function _model at 0xb2021b4>
_qs
<function _qs at 0xb2029cc>
fields
()
ret
None
thing
<Location: Ryan Hall>
* build/bdist.linux-i686/egg/piston/emitters.py in _model
194.
195. if isinstance(maybe_field, (list, tuple)):
196. model, fields = maybe_field
197. inst = getattr(data, model, None)
198.
199. if inst:
200. if hasattr(inst, 'all'):
201. ret[model] = _related(inst, fields) ...
202. elif callable(inst):
203. if len(inspect.getargspec(inst)[0]) == 1:
204. ret[model] = _any(inst(), fields)
205. else:
206. ret[model] = _model(inst, fields)
207.
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_fk
<function _fk at 0xb202844>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_related
<function _related at 0xb20217c>
data
<Location: Ryan Hall>
exclude
'id'
exclude_fields
set(['id'])
f
<django.db.models.fields.CharField object at 0x98706ec>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
get_absolute_uri
False
get_fields
set(['locationid', 'locationtypeid', ('services', ('serviceid',
'name', 'acronym', 'subtitle', 'servicetypeid', 'locationid',
'sortorder', 'room', 'mailingaddress', 'boxnumber', 'city', 'state',
'zipcode', 'country', 'phonenumber', 'faxnumber', 'email',
'description', 'website'))])
handler
<class 'Explore_Maps.api.handler.LocationAggregateHandler'>
inst
<django.db.models.fields.related.RelatedManager object at
0xa748b8c>
mapped
<class 'Explore_Maps.api.handler.LocationAggregateHandler'>
maybe
31
maybe_field
('services', ('serviceid', 'name', 'acronym', 'subtitle',
'servicetypeid', 'locationid', 'sortorder', 'room', 'mailingaddress',
'boxnumber', 'city', 'state', 'zipcode', 'country', 'phonenumber',
'faxnumber', 'email', 'description', 'website'))
met_fields
{'locationtypeid': <bound method HandlerMetaClass.locationtypeid
of <class 'Explore_Maps.api.handler.LocationAggregateHandler'>>}
model
'services'
p
'country'
ret
{'city': u'', 'code': u'J07', 'country': u'United States',
'datebuilt': u'1904', 'description': u'', 'history': u'', 'imagetag':
u'DC:coverage=RyanHall', 'latitude': '38.90685000', 'locationid': 31,
'locationtypeid': 1, 'longitude': '-77.07321600', 'mainimageurl':
u'
http://farm5.static.flickr.com/4072/4386018957_f2bd1fd13b_m.jpg',
'name': u'Ryan Hall', 'physicaladdress': u'', 'sortorder': 0, 'state':
u'', 'videoimagestring': u'', 'videostring': u'', 'zipcode': u''}
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
v
<function <lambda> at 0x9e76d14>
* build/bdist.linux-i686/egg/piston/emitters.py in _related
117. """
118. return _any(getattr(data,
field.name))
119.
120. def _related(data, fields=()):
121. """
122. Foreign keys.
123. """
124. return [ _model(m, fields) for m in data.iterator() ] ...
125.
126. def _m2m(data, field, fields=()):
127. """
128. Many to many (re-route to `_model`.)
129. """
130. return [ _model(m, fields) for m in getattr(data,
field.name).iterator() ]
? Local vars
Variable Value
_[1]
[]
_model
<function _model at 0xb2021b4>
data
<django.db.models.fields.related.RelatedManager object at
0xa748b8c>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
m
<Service: Woodstock Theological Center>
* build/bdist.linux-i686/egg/piston/emitters.py in _model
176. if f.serialize and not any([ p in met_fields for p in
[ f.attname,
f.name ]]):
177. if not f.rel:
178. if f.attname in get_fields:
179. ret[f.attname] = _any(v(f))
180. get_fields.remove(f.attname)
181. else:
182. if f.attname[:-3] in get_fields:
183. ret[
f.name] = _fk(data, f) ...
184. get_fields.remove(
f.name)
185.
186. for mf in data._meta.many_to_many:
187. if mf.serialize and mf.attname not in met_fields:
188. if mf.attname in get_fields:
189. ret[
mf.name] = _m2m(data, mf)
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_fk
<function _fk at 0xb202844>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_related
<function _related at 0xb20217c>
data
<Service: Woodstock Theological Center>
f
<django.db.models.fields.related.ForeignKey object at 0x9874a2c>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
get_absolute_uri
False
get_fields
set(['boxnumber', 'city', 'country', 'description', 'email',
'faxnumber', 'locationid', 'mailingaddress', 'phonenumber', 'room',
'serviceid', 'sortorder', 'state', 'website', 'zipcode'])
handler
<class 'Explore_Maps.api.handler.ServiceAggregateHandler'>
met_fields
{}
p
'locationid'
ret
{'acronym': u'', 'name': u'Woodstock Theological Center',
'servicetypeid': {'_state': u'<django.db.models.base.ModelState object
at 0x122c3f4c>', 'name': u'Academics and research', 'servicetypeid':
1, 'sortorder': 1}, 'subtitle': u''}
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
v
<function <lambda> at 0xb2221b4>
* build/bdist.linux-i686/egg/piston/emitters.py in _fk
111.
112. return ret
113.
114. def _fk(data, field):
115. """
116. Foreign keys.
117. """
118. return _any(getattr(data,
field.name)) ...
119.
120. def _related(data, fields=()):
121. """
122. Foreign keys.
123. """
124. return [ _model(m, fields) for m in data.iterator() ]
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
data
<Service: Woodstock Theological Center>
field
<django.db.models.fields.related.ForeignKey object at 0x9874a2c>
* build/bdist.linux-i686/egg/piston/emitters.py in _any
92. elif isinstance(thing, (tuple, list)):
93. ret = _list(thing)
94. elif isinstance(thing, dict):
95. ret = _dict(thing)
96. elif isinstance(thing, decimal.Decimal):
97. ret = str(thing)
98. elif isinstance(thing, Model):
99. ret = _model(thing, fields=fields) ...
100. elif isinstance(thing, HttpResponse):
101. raise HttpStatusCode(thing)
102. elif inspect.isfunction(thing):
103. if not inspect.getargspec(thing)[0]:
104. ret = _any(thing())
105. elif hasattr(thing, '__emittable__'):
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_dict
<function _dict at 0xb2027d4>
_list
<function _list at 0xb2028ec>
_model
<function _model at 0xb2021b4>
_qs
<function _qs at 0xb2029cc>
fields
()
ret
None
thing
<Location: Ryan Hall>
* build/bdist.linux-i686/egg/piston/emitters.py in _model
194.
195. if isinstance(maybe_field, (list, tuple)):
196. model, fields = maybe_field
197. inst = getattr(data, model, None)
198.
199. if inst:
200. if hasattr(inst, 'all'):
201. ret[model] = _related(inst, fields) ...
202. elif callable(inst):
203. if len(inspect.getargspec(inst)[0]) == 1:
204. ret[model] = _any(inst(), fields)
205. else:
206. ret[model] = _model(inst, fields)
207.
? Local vars
Variable Value
_any
<function _any at 0xa7c1ae4>
_fk
<function _fk at 0xb202844>
_m2m
<function _m2m at 0xb2020d4>
_model
<function _model at 0xb2021b4>
_related
<function _related at 0xb20217c>
data
<Location: Ryan Hall>
exclude
'id'
exclude_fields
set(['id'])
f
<django.db.models.fields.CharField object at 0x98706ec>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
get_absolute_uri
False
get_fields
set(['locationid', 'locationtypeid', ('services', ('serviceid',
'name', 'acronym', 'subtitle', 'servicetypeid', 'locationid',
'sortorder', 'room', 'mailingaddress', 'boxnumber', 'city', 'state',
'zipcode', 'country', 'phonenumber', 'faxnumber', 'email',
'description', 'website'))])
handler
<class 'Explore_Maps.api.handler.LocationAggregateHandler'>
inst
<django.db.models.fields.related.RelatedManager object at
0x96376cc>
mapped
<class 'Explore_Maps.api.handler.LocationAggregateHandler'>
maybe
31
maybe_field
('services', ('serviceid', 'name', 'acronym', 'subtitle',
'servicetypeid', 'locationid', 'sortorder', 'room', 'mailingaddress',
'boxnumber', 'city', 'state', 'zipcode', 'country', 'phonenumber',
'faxnumber', 'email', 'description', 'website'))
met_fields
{'locationtypeid': <bound method HandlerMetaClass.locationtypeid
of <class 'Explore_Maps.api.handler.LocationAggregateHandler'>>}
model
'services'
p
'country'
ret
{'city': u'', 'code': u'J07', 'country': u'United States',
'datebuilt': u'1904', 'description': u'', 'history': u'', 'imagetag':
u'DC:coverage=RyanHall', 'latitude': '38.90685000', 'locationid': 31,
'locationtypeid': 1, 'longitude': '-77.07321600', 'mainimageurl':
u'
http://farm5.static.flickr.com/4072/4386018957_f2bd1fd13b_m.jpg',
'name': u'Ryan Hall', 'physicaladdress': u'', 'sortorder': 0, 'state':
u'', 'videoimagestring': u'', 'videostring': u'', 'zipcode': u''}
self
<piston.emitters.JSONEmitter object at 0x122f5d8c>
v
<function <lambda> at 0xb222a04>
* build/bdist.linux-i686/egg/piston/emitters.py in _related
117. """
118. return _any(getattr(data,
field.name))
119.
120. def _related(data, fields=()):
121. """
122. Foreign keys.
123. """
124. return [ _model(m, fields) for m in data.iterator() ] ...
125.
126. def _m2m(data, field, fields=()):
127. """
128. Many to many (re-route to `_model`.)
129. """
130. return [ _model(m, fields) for m in getattr(data,
field.name).iterator() ]
? Local vars
Variable Value
_[1]
[]
_model
<function _model at 0xb2021b4>
data
<django.db.models.fields.related.RelatedManager object at
0x96376cc>
fields
('serviceid', 'name', 'acronym', 'subtitle', 'servicetypeid',
'locationid', 'sortorder', 'room', 'mailingaddress', 'boxnumber',
'city', 'state', 'zipcode', 'country', 'phonenumber', 'faxnumber',
'email', 'description', 'website')
m
<Service: Woodstock Theological Center>
* build/bdist.linux-i686/egg/piston/emitters.py in _model