o aU@sPddlmZddlmZmZGdddeZGdddeZGdd d eZd S) ) HttpResponse) get_templateselect_templatec@s eZdZdS)ContentNotRenderedErrorN)__name__ __module__ __qualname__r r :/usr/lib/python3/dist-packages/django/template/response.pyrsrcseZdZgdZ  dfdd ZddZddZd d Zed d Z d dZ ddZ eddZ fddZ efddZejddZZS)SimpleTemplateResponse) template_name context_data_post_render_callbacksNcs>||_||_||_g|_d|_tjd||||dd|_dS)N)charsetheadersF)r rusingr_requestsuper__init__ _is_rendered)selftemplatecontext content_typestatusrrr __class__r r r s zSimpleTemplateResponse.__init__cCs6|j}|js td|jD] }||vr||=q|S)z Raise an exception if trying to pickle an unrendered response. Pickle only rendered data, not the data used to construct the response. z?The response content must be rendered before it can be pickled.)__dict__copyrrrendering_attrs)robj_dictattrr r r __getstate__-s  z#SimpleTemplateResponse.__getstate__cCs8t|ttfrt||jdSt|trt||jdS|S)z=Accept a template object, path-to-template, or list of paths.)r) isinstancelisttuplerrstrr)rrr r r resolve_template<s  z'SimpleTemplateResponse.resolve_templatecCs|SNr )rrr r r resolve_contextEsz&SimpleTemplateResponse.resolve_contextcCs&||j}||j}|||jS)a@Return the freshly rendered content for the template and context described by the TemplateResponse. This *does not* set the final content of the response. To set the response content, you must either call render(), or set the content explicitly using the value of this property. )r)r r+rrenderr)rrrr r r rendered_contentHs z'SimpleTemplateResponse.rendered_contentcCs"|jr ||dS|j|dS)zAdd a new post-rendering callback. If the response has already been rendered, invoke the callback immediately. N)rrappend)rcallbackr r r add_post_render_callbackUs z/SimpleTemplateResponse.add_post_render_callbackcCs6|}|js|j|_|jD] }||}|dur|}q |S)zRender (thereby finalizing) the content of the response. If the content has already been rendered, this is a no-op. Return the baked response instance. N)rr-contentr)rretval post_callback newretvalr r r r,`s zSimpleTemplateResponse.rendercCs|jSr*)rrr r r is_renderedpsz"SimpleTemplateResponse.is_renderedcs|jstdtS)NzEThe response content must be rendered before it can be iterated over.)rrr__iter__r5rr r r7ts  zSimpleTemplateResponse.__iter__cs|jstdtjS)Nz@The response content must be rendered before it can be accessed.)rrrr1r5rr r r1{s zSimpleTemplateResponse.contentcCstj||d|_dS)z!Set the content for the response.TN)rr1fsetr)rvaluer r r r1s NNNNNN)rrr r!rr$r)r+propertyr-r0r,r6r7r1setter __classcell__r r rr r s&       r cs.eZdZejdgZ  dfdd ZZS)TemplateResponserNc s$tj|||||||d||_dS)N)r)rrr) rrequestrrrrrrrrr r rs zTemplateResponse.__init__r:)rrr r r!rr=r r rr r>s  r>N) django.httprloaderrr Exceptionrr r>r r r r s