https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/wiki/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/wiki/__pycache__/model.cpython-310.pyc
o

�k�`�(�@s\ddlTddlmZddlmZmZmZmZddlm	Z	ddl
mZmZGdd�de
�ZdS)	�)�*)�Resource)�datetime_now�from_utimestamp�
to_utimestamp�utc)�_)�
WikiSystem�validate_page_namec@sveZdZdZejZedd��Zddd�Zddd�Z	d	d
�Z
edd��Zdd
d�Zddd�Z
dd�Zdd�Zdd�ZdS)�WikiPagez)Represents a wiki page (new or existing).cCst|j|j|j�S�N)r�realm�name�_resource_version��self�r�1/usr/lib/python3/dist-packages/trac/wiki/model.py�resourceszWikiPage.resourceNcCs�||_|rzt|�}Wntyd}Ynwt|t�r=|}|j}|dur=|jdur=zt|j�}Wnty<d}Ynw||_||_|rL|�	||�nd|_d|_
|_|_d|_
d|_|j
|_|j|_dS)a;Create a new page object or retrieves an existing page.

        :param env: an `Environment` object.
        :param name: the page name or a `Resource` object.
        :param version: the page version. The value takes precedence over the
                        `Resource` version when both are specified.
        Nr�)�env�int�
ValueError�
isinstancer�id�versionrr�_fetch�text�comment�author�time�readonly�old_text�old_readonly)rrrrrrrr�__init__#s4�
�zWikiPage.__init__c
Cs�|dur
d}|t|�f}nd}|f}|j�||�D]&\}}}}}}	t|�|_||_t|�|_||_||_|	r:t|	�nd|_	dSd|_d|_|_|_d|_d|_	dS)NzqSELECT version, time, author, text, comment, readonly
                     FROM wiki WHERE name=%s AND version=%sz�SELECT version, time, author, text, comment, readonly
                     FROM wiki WHERE name=%s ORDER BY version DESC LIMIT 1rr)
rr�db_queryrrrr rrr!)
rrr�sql�argsr rrrr!rrrrMs$�


zWikiPage._fetchcCs2|jdur	|j}nd|j|jf}d|jj|fS)Nz%s@%sz<%s %r>)rr�	__class__�__name__)rrrrr�__repr__es
zWikiPage.__repr__cCs
|jdkS)Nr)rrrrr�<lambda>ls
zWikiPage.<lambda>cCs(|js	ttd���|jj�W}|dur#|d|jf�|jj�d|j�n|d|j|f�|jj�d||j�|dus>||jkrE|�	|jd�|js]t
|j�`ddlm
}|�|j|j|j�Wd�n1sgwY|jst
|j�jD]}|�|�qudSt
|j�jD]}t|d	�r�|�|�q�dS)
z.Delete one or all versions of a page.
        zCannot delete non-existent pageNzDELETE FROM wiki WHERE name=%szDeleted page %sz-DELETE FROM wiki WHERE name=%s and version=%szDeleted version %d of page %sr��
Attachment�wiki_page_version_deleted)�exists�	TracErrorrr�db_transactionr�log�inforrr	�pages�trac.attachmentr-�
delete_allr
�change_listeners�wiki_page_deleted�hasattrr.)rr�dbr-�listenerrrr�deletens:
��
���

��zWikiPage.deleteFc
Cs�t|j�sttd|jd���|j|jk}|s"|j|jkr"ttd���|p'tt	�}|j
j�J}|r\|rB|jdkrB|d|j|j|jf�n#|jd7_|d|j|jt
|�||j||jf�n	|d|j|jf�|jdkrot|j
�`Wd	�n1sywY||_||_||_t|j
�jD]-}|j
�|��|jdkr�|�|�n
|�||j|||�Wd	�n1s�wYq�|j|_|j|_d	S)
zSave a new version of a page.�!Invalid Wiki page name '%(name)s'�rzPage not modifiedrzf
                        UPDATE wiki SET text=%s WHERE name=%s AND version=%s
                        �z�INSERT INTO wiki
                           (name,version,time,author,text,comment,readonly)
                          VALUES (%s,%s,%s,%s,%s,%s,%s)
                          z)UPDATE wiki SET readonly=%s WHERE name=%sN)r
rr0rrr"r!r#rrrr1rrr	r4rrr r7�component_guard�wiki_page_added�wiki_page_changed)rrr�t�replace�new_textr:r;rrr�save�sT
�
���
�

��
����z
WikiPage.savecCs |js	ttd���|sttd���|j|krttd���t|�s(ttd|d���|j}|jj�7}t|j|�}|jrAttd|d���|d||f�t|j�`	dd	l
m}|�|j|j
||j
|�Wd
�n1siwY||_|jj�d||�t|j�jD]
}t|d�r�|�||�q�d
S)
z�Rename wiki page in-place, keeping the history intact.
        Renaming a page this way will eventually leave dangling references
        to the old page - which literally doesn't exist anymore.
        zCannot rename non-existent pagez%A new name is mandatory for a rename.zPage name is unchanged.r=r>z#The page '%(name)s' already exists.z%UPDATE wiki SET name=%s WHERE name=%srr,NzRenamed page %s to %s�wiki_page_renamed)r/r0rrr
rr1rr	r4r5r-�reparent_allr
r2r3r7r9rG)r�new_name�old_namer:�new_pager-r;rrr�rename�s>
�
�
��
��zWikiPage.renamecCs�|js	ttd���|j}|jj�}|d||j|jf�Wd�n1s%wY||_|jj�	d|j|j|�t
|j�jD]
}t|d�rL|�
||�q?dS)z+Edit comment of wiki page version in-place.z(Cannot edit comment of non-existent pagez7UPDATE wiki SET comment=%s WHERE name=%s AND version=%sNz+Changed comment on page %s version %s to %s�wiki_page_comment_modified)r/r0rrrr1rrr2r3r	r7r9rM)r�new_comment�old_commentr:r;rrr�edit_comment�s"
��

�
��zWikiPage.edit_commentccs<�|j�d|j|jf�D]\}}}}|t|�||fVqdS)z�Retrieve the edit history of a wiki page.

        :return: a tuple containing the `version`, `datetime`, `author`
                 and `comment`.
        z�
                SELECT version, time, author, comment FROM wiki
                WHERE name=%s AND version<=%s ORDER BY version DESC
                N)rr%rrr)rr�tsrrrrr�get_history�s�
��zWikiPage.get_history)NNr)NF)r)�
__module__�__qualname__�__doc__r	r
�propertyrr$rr*r/r<rFrLrPrRrrrrrs


*

%.(rN)�	trac.core�
trac.resourcer�trac.util.datefmtrrrr�trac.util.translationr�
trac.wiki.apir	r
�objectrrrrr�<module>s

https://t.me/RX1948 - 2025