HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/twisted/web/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/script.cpython-312.pyc
�

Ϫ�f���H�dZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZmZdZGd	�d
e�ZGd�d�Zej,d
de�Zd�Zd�ZGd�dej4�ZGd�dej4�ZGd�dej4�Zy)zH
I contain PythonScript, which is a very simple python script resource.
�N)�StringIO)�	copyright)�execfile�
networkString)�_coerceToFilesystemEncoding)�http�resource�server�static�utilz�<p>You forgot to assign to the variable "resource" in your script. For example:</p>
<pre>
# MyCoolWebApp.rpy

import mygreatresource

resource = mygreatresource.MyGreatResource()
</pre>
c��eZdZdZy)�
AlreadyCachedzG
    This exception is raised when a path has already been cached.
    N)�__name__�
__module__�__qualname__�__doc__���4/usr/lib/python3/dist-packages/twisted/web/script.pyrrs��rrc��eZdZd�Zd�Zd�Zy)�CacheScannerc�.�||_||_d|_y)Nr)�path�registry�doCache��selfrrs   r�__init__zCacheScanner.__init__%s����	� ��
���rc��|jj|j�}|�t|��|j	�y�N)r�
getCachedPathrr�recache)r�cs  r�cachezCacheScanner.cache*s3���M�M�'�'��	�	�2���=���"�"����rc��d|_y)N�)r)rs rr"zCacheScanner.recache0s	����rN)rrrrr$r"rrrrr$s���
�rr���Whoops! Internal Errorc�.�t||�}td|�t||j|jd�}	t|||�|d}|jr|tur|j||�|S#t$r}|jdcYd}~Sd}~wwxYw)z�
    I am a normal py file which must define a 'resource' global, which should
    be an instance of (a subclass of) web.resource.Resource; it will be
    renderred.
    �)�__file__r	rr$r"rNr	)
rr�noRsrcr$r"rr�argsr�	cachePath)rr�cs�glob�ac�rsrcs      r�ResourceScriptr37s���
�d�H�	%�B�/��D�9�������:�:��D����t�T�"��
��D�	�z�z�d�&�(����4��&��K�����w�w�q�z����s�
A2�2	B�;B�	B�Bc��ddlm}td|�tjddt
�|d�}t
|�5}|j||�}ddd�tdd�}t|||�|d	S#1swY�(xYw)
Nr)�ptl_compiler*r'r()r+r	rz<source>�execr	)
�quixoter5rr	�_UnsafeErrorPage�
rpyNoResource�open�compile_template�compile�eval)rrr5r0�f�e�codes       r�ResourceTemplaterAOs���#�0��D�9��-�-��)�=�
���D�
�d��2�q��(�(��D�1��2��1�j�&�)�D���t�T���
���	2�2�s�A5�5A>c� �eZdZdd�Zd�Zd�Zy)�ResourceScriptWrapperNc��tjj|�||_|xst	j
�|_yr �r	�Resourcerrr�Registryrrs   rrzResourceScriptWrapper.__init__bs0�����"�"�4�(���	� �5�F�O�O�$5��
rc�d�t|j|j�}|j|�Sr )r3rr�render)r�request�ress   rrIzResourceScriptWrapper.rendergs%���T�Y�Y��
�
�6���z�z�'�"�"rc�f�t|j|j�}|j||�Sr )r3rr�getChildWithDefault)rrrJrKs    rrMz)ResourceScriptWrapper.getChildWithDefaultks)���T�Y�Y��
�
�6���&�&�t�W�5�5rr )rrrrrIrMrrrrCrCas��6�
#�6rrCc�$�eZdZdZdd�Zd�Zd�Zy)�ResourceScriptDirectorya
    L{ResourceScriptDirectory} is a resource which serves scripts from a
    filesystem directory.  File children of a L{ResourceScriptDirectory} will
    be served using L{ResourceScript}.  Directory children will be served using
    another L{ResourceScriptDirectory}.

    @ivar path: A C{str} giving the filesystem path in which children will be
        looked up.

    @ivar registry: A L{static.Registry} instance which will be used to decide
        how to interpret scripts found as children of this resource.
    Nc��tjj|�||_|xst	j
�|_yr rE)r�pathnamers   rrz ResourceScriptDirectory.__init__~s0�����"�"�4�(���	� �5�F�O�O�$5��
rc�R�tjj|j|�}tjj|�rt	||j
�Stjj
|�rt||j
�Stj�Sr )
�osr�join�isdirrOr�existsr3r	�_UnsafeNoResource)rrrJ�fns    r�getChildz ResourceScriptDirectory.getChild�sk��
�W�W�\�\�$�)�)�T�
*��
�7�7�=�=���*�2�t�}�}�=�=�
�7�7�>�>�"��!�"�d�m�m�4�4��)�)�+�+rc�H�tj�j|�Sr )r	rWrI)rrJs  rrIzResourceScriptDirectory.render�s���)�)�+�2�2�7�;�;rr )rrrrrrYrIrrrrOrOps���6�
,�<rrOc� �eZdZdZdZd�Zd�Zy)�PythonScriptz�
    I am an extremely simple dynamic resource; an embedded python script.

    This will execute a file (usually of the extension '.epy') as Python code,
    internal to the webserver.
    Tc� �||_||_y)z3
        Initialize me with a script name.
        N)�filenamer)rr^rs   rrzPythonScript.__init__�s��!��
� ��
rc���|jdtdtjz��|t	d|j
�|jd�}	t|j
||�|j3�t4j6S#t$rk}|jdk(rR|jtj�|jtjd�j!|��Yd}~��d}~wt"$rit%�}t'j(|��t+j,|j/��}|j1d	�}|j|�Y��wxYw)
a4
        Render me to a web client.

        Load my file, execute it in a special namespace (with 'request' and
        '__file__' global vars) and finish the request.  Output to the web-page
        will NOT be handled with print - standard output goes to the log - but
        with request.write.
        sx-powered-byz
Twisted/%sr*)rJr+r�zFile not found.N)�file�utf8)�	setHeaderrr�versionrr^rr�OSError�errno�setResponseCoder�	NOT_FOUND�writer	rWrI�
BaseExceptionr�	traceback�	print_excr�_PRE�getvalue�encode�finishr
�NOT_DONE_YET)rrJ�	namespacer?�io�outputs      rrIzPythonScript.render�s��	����]�<�)�:K�:K�+K�L�	
��3�B��
�
�F��
�
�
�	�

	"��T�]�]�I�y�9�	�����"�"�"���	��w�w�!�|��'�'����7��
�
��.�.�/@�A�H�H��Q�����	"���B����R�(��Y�Y�r�{�{�}�-�F��]�]�6�*�F��M�M�&�!�	"�s �B	�		E-�A!C8�8A1E-�,E-N)rrrr�isLeafrrIrrrr\r\�s����F�!� #rr\)rrSrkrsr�twistedr�twisted.python.compatrr�twisted.python.filepathr�twisted.webrr	r
rrr9�	Exceptionrrr8r,r3rArFrCrOr\rrr�<module>r{s���
�

����9�?�<�<��
��I��
�
� 
#��	"�	"�3�(@�-�	P���0�$6�H�-�-�6�<�h�/�/�<�@1#�8�$�$�1#r