
    h                         S SK r S SKJrJr  S SKJr  S SKJr   " S S\5      r	 " S S\
5      r " S	 S
5      r " S S\5      r " S S\5      r " S S\5      rg)    N)MappingMutableMapping)	force_str)jsonc                   J   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	rU =r$ )

ReturnDict	   z
Return object from `serializer.data` for the `Serializer` class.
Includes a backlink to the serializer instance for renderers
to use if they need richer field information.
c                 R   > UR                  S5      U l        [        TU ]  " U0 UD6  g N
serializerpopr   super__init__selfargskwargs	__class__s      _/var/www/html/shao/venv/lib/python3.13/site-packages/rest_framework/utils/serializer_helpers.pyr   ReturnDict.__init__   %     **\2$)&)    c                 (    [        X R                  S9$ Nr   )r   r   r   s    r   copyReturnDict.copy   s    $??;;r   c                 ,    [         R                  U 5      $ N)dict__repr__r   s    r   r#   ReturnDict.__repr__       }}T""r   c                 &    [         [        U 5      44$ r!   )r"   r   s    r   
__reduce__ReturnDict.__reduce__        tDzm$$r   c                     [        U[        5      (       d  [        $ U R                  X R                  S9nUR                  U5        U$ r   
isinstancer"   NotImplementedr   r   updater   othernews      r   __or__ReturnDict.__or__    s:    %&&!!nnToon>

5
r   c                     [        U[        5      (       d  [        $ U R                  XR                  S9nUR                  U 5        U$ r   r+   r/   s      r   __ror__ReturnDict.__ror__'   s:    %&&!!nnUn?

4
r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r#   r'   r2   r5   __static_attributes____classcell__r   s   @r   r   r   	   s+    *<#% r   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )
ReturnList/   z
Return object from `serializer.data` for the `SerializerList` class.
Includes a backlink to the serializer instance for renderers
to use if they need richer field information.
c                 R   > UR                  S5      U l        [        TU ]  " U0 UD6  g r   r   r   s      r   r   ReturnList.__init__6   r   r   c                 ,    [         R                  U 5      $ r!   )listr#   r   s    r   r#   ReturnList.__repr__:   r%   r   c                 &    [         [        U 5      44$ r!   )rE   r   s    r   r'   ReturnList.__reduce__=   r)   r   r   )
r7   r8   r9   r:   r;   r   r#   r'   r<   r=   r>   s   @r   r@   r@   /   s    *#% %r   r@   c                   D    \ rS rSrSrS
S jrS r\S 5       rS r	S r
Srg	)
BoundFieldC   z
A field object that also includes `.value` and `.error` properties.
Returned when iterating over a serializer instance,
providing an API similar to Django forms and form fields.
c                 Z    Xl         X@l        X l        X0l        X@R                  -   U l        g r!   )_field_prefixvalueerrors
field_namename)r   fieldrO   rP   prefixs        r   r   BoundField.__init__J   s$    
__,	r   c                 .    [        U R                  U5      $ r!   )getattrrM   )r   	attr_names     r   __getattr__BoundField.__getattr__Q   s    t{{I..r   c                 .    U R                   R                  $ r!   )rM   r   r   s    r   _proxy_classBoundField._proxy_classT   s    {{$$$r   c                 p    SU R                   R                  < SU R                  < SU R                  < S3$ )N<z value=z errors=>)r   r7   rO   rP   r   s    r   r#   BoundField.__repr__X   s%    NN##TZZ
 	
r   c                     U R                   b  U R                   SL a  SOU R                   nU R                  U R                  XR                  U R                  5      $ NF )rO   r   rM   rP   rN   r   rO   s     r   as_form_fieldBoundField.as_form_field]   s@    zz)TZZ5-@tzz~~dkk5++t||LLr   )rM   rN   rP   rR   rO   Nrd   )r7   r8   r9   r:   r;   r   rY   propertyr\   r#   rf   r<    r   r   rJ   rJ   C   s0    -/ % %

Mr   rJ   c                       \ rS rSrS rSrg)JSONBoundFieldb   c                 T   U R                   n[        USS5      (       dI  [        R                  " [        [
        5         [        R                  " U R                   SSSS9nS S S 5        U R                  U R                  XR                  U R                  5      $ ! , (       d  f       N?= f)Nis_json_stringFT   ),z: )	sort_keysindent
separators)rO   rW   
contextlibsuppress	TypeError
ValueErrorr   dumpsr   rM   rP   rN   re   s     r   rf   JSONBoundField.as_form_fieldc   sz    

 u.66$$Y
;

JJ"*	 < ~~dkk5++t||LL <;s   "B
B'rj   N)r7   r8   r9   r:   rf   r<   rj   r   r   rl   rl   b   s    Mr   rl   c                   B   ^  \ rS rSrSrSU 4S jjrS rS rS rSr	U =r
$ )	NestedBoundFieldr   z
This `BoundField` additionally implements __iter__ and __getitem__
in order to support nested bound fields. This class is the type of
`BoundField` that is used for serializer fields.
c                 f   > Ub  US:X  d  [        U[        5      (       d  0 n[        TU ]  XX45        g )Nrd   )r,   r   r   r   )r   rS   rO   rP   rT   r   s        r   r   NestedBoundField.__init__y   s.    =ERKz%/I/IEv6r   c              #   n   #    U R                   R                  5        H  nXR                     v   M     g 7fr!   )fieldsvaluesrQ   )r   rS   s     r   __iter__NestedBoundField.__iter__~   s+     [['')E''(( *s   35c                    U R                   U   nU R                  (       a  U R                  R                  U5      OS n[        U R                  [
        5      (       a  U R                  R                  U5      OS n[        US5      (       a  [        X#X@R                  S-   S9$ [        USS5      (       a  [        X#X@R                  S-   S9$ [        X#X@R                  S-   S9$ )Nr   .)rT   _is_jsonfieldF)r   rO   getr,   rP   r"   hasattrr|   rR   rW   rl   rJ   )r   keyrS   rO   errors        r   __getitem__NestedBoundField.__getitem__   s    C '+zz

s#t(24;;(E(E$45(###E%		CPPUOU33!%ii#oNN%ii#oFFr   c                    0 nU R                   R                  5        H=  u  p#[        U[        [        45      (       a  X1U'   M&  Ub  USL a  SO
[        U5      X'   M?     U R                  U R                  XR                  U R                  5      $ rc   )
rO   itemsr,   rE   r"   r   r   rM   rP   rN   )r   r   r   rO   s       r   rf   NestedBoundField.as_form_field   sr    ****,JC%$..#s%*]eunb9UZK[	 -
 ~~dkk6;;MMr   rj   rh   )r7   r8   r9   r:   r;   r   r   r   rf   r<   r=   r>   s   @r   r|   r|   r   s$    7
)GN Nr   r|   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)BindingDict   z
This dict-like object is used to store fields on a serializer.

This ensures that whenever fields are added to the serializer we call
`field.bind()` so that the `field_name` and `parent` attributes
can be set correctly.
c                     Xl         0 U l        g r!   )r   r   )r   r   s     r   r   BindingDict.__init__   s    $r   c                 R    X R                   U'   UR                  XR                  S9  g )N)rQ   parent)r   bindr   )r   r   rS   s      r   __setitem__BindingDict.__setitem__   s      C

c//
:r   c                      U R                   U   $ r!   r   r   r   s     r   r   BindingDict.__getitem__   s    {{3r   c                     U R                   U	 g r!   r   r   s     r   __delitem__BindingDict.__delitem__   s    KKr   c                 ,    [        U R                  5      $ r!   )iterr   r   s    r   r   BindingDict.__iter__   s    DKK  r   c                 ,    [        U R                  5      $ r!   )lenr   r   s    r   __len__BindingDict.__len__   s    4;;r   c                 @    [         R                  U R                  5      $ r!   )r"   r#   r   r   s    r   r#   BindingDict.__repr__   s    }}T[[))r   )r   r   N)r7   r8   r9   r:   r;   r   r   r   r   r   r   r#   r<   rj   r   r   r   r      s*    ; ! *r   r   )ru   collections.abcr   r   django.utils.encodingr   rest_framework.utilsr   r"   r   rE   r@   rJ   rl   r|   r   rj   r   r   <module>r      s_     3 + %# #L% %(M M>MZ M !Nz !NH*. *r   