Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/modelcluster/__pycache__/models.cpython-310.pyc

122 lines
12 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>fvA<00>@s<>ddlmZddlZddlZddlmZddlmZmZddl m
Z
ddl m Z ddl mZddlmZdd lmZdd
lmZmZd d <0C>Zd d<0E>Zddd<12>Zdd<14>Zdd<16>ZGdd<18>dej<1B>ZdS)<1A>)<01>unicode_literalsN)<01>FieldDoesNotExist)<02>models<6C> transaction)<01>ForeignObjectRel)<01>is_protected_type)<01>DjangoJSONEncoder)<01>settings)<01>timezone)<02> ParentalKey<65>ParentalManyToManyFieldcCs<>|jdur@|j||jdud<01>}t|tj<04>r5tjr5t<07>|<02>r-t<07> <09>}t<07>
||<03><02> tjj <0C>}nt<07> |tjj <0C>}t|<02>r;|S|<00>|<01>St||<00><11><00>S)N)<01>add)<12> remote_field<6C>pre_save<76>pk<70>
isinstance<EFBFBD>datetimer <00>USE_TZr
<00>is_naive<76>get_default_timezone<6E>
make_aware<EFBFBD>
astimezone<EFBFBD>utc<74> localtimer<00>value_to_string<6E>getattr<74> get_attname)<04>field<6C>model<65>value<75>default_timezone<6E>r!<00>U/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/modelcluster/models.py<70>get_field_values


r#cCsf|jj}|jr|jjr|jjjj}|jr|jjs dt||<00>i}|jjD] }|jr0t||<00>||j<q#|S)z<>
Return a serialised version of the model's fields which exist as local database
columns (i.e. excluding m2m and incoming foreign key relations)
r) <09>_metarr<00> parent_linkrr#<00>fields<64> serialize<7A>name)r<00>pk_field<6C>objrr!r!r"<00> get_serializable_data_for_fields's <0E> <02>r+TFc Cs0|jj}i}|jr!|jjr!|d||j<|jjjj}|jr!|jjs |d||j<|<01><06>D]<5D>\}}z|j<00>|<06>}Wn tyAYq,wt |t
<EFBFBD>rHq,|jrct |jt j <0C>rc|jjj j|d<02>} t| <09>||j<q,|jr<>t |jt j<10>r<>|durwd||j<q,|jjj<00>|jj<11><01>|<07>}
|
||j<|r<>z|jjj jdi|jj|
i<01><01>Wq,|jjjy<>|jjt jkr<>n$|jjt jkr<>|r<>YdSd||j<n|jjt jkr<>d||j<ntd<03><01>Yq,wq,|<08>|<07>} t |t j<1A>r<>tjr<>| dur<>t<1D><1E>} t<1D>| <0B>r<>t<1D> | | <0C>} nt<1D>!| | <0C>} | ||j"<q,|di|<05><01>} |ddu<01>rd| j#_$| S)Nr)<01>pk__inzRcan't currently handle on_delete types other than CASCADE, SET_NULL and DO_NOTHINGFr!)%r$rrr%<00>attnamer<00>items<6D> get_fieldrrrr<00> ManyToManyRel<65>_default_manager<65>filter<65>list<73> ManyToOneRel<65>
field_name<EFBFBD> to_python<6F>get<65> DoesNotExist<73> on_delete<74>
DO_NOTHING<EFBFBD>CASCADE<44>SET_NULL<4C> Exception<6F> DateTimeFieldr rr
r<00>is_awarerrr(<00>_state<74>adding)r<00>data<74> check_fks<6B>
strict_fksr)<00>kwargsr5<00> field_valuer<00>related_objects<74> clean_valuerr r*r!r!r"<00>model_from_serializable_data:sd <0E> <02>
 
"  <04><02><02>

  rIcC<00>dd<02>|j<00><01>D<00>S)z<>
Return a list of RelatedObject records for child relations of the given model,
including ones attached to ancestors of the model
cSsg|]
}t|jt<02>r|<01>qSr!)rrr <00><02>.0rr!r!r"<00>
<listcomp><3E>s 
<02><06>z+get_all_child_relations.<locals>.<listcomp><3E>r$<00>
get_fields<EFBFBD>rr!r!r"<00>get_all_child_relations<6E><00><06>rQcCrJ)z}
Return a list of ParentalManyToManyFields on the given model,
including ones attached to ancestors of the model
cSsg|] }t|t<01>r|<01>qSr!)rr rKr!r!r"rM<00>s <02><06>z/get_all_child_m2m_relations.<locals>.<listcomp>rNrPr!r!r"<00>get_all_child_m2m_relations<6E>rRrScs<>eZdZ<02>fdd<02>Z<03>fdd<04>Zdd<06>Zdd<08>Zedd d <0C><01>Zedd d<0E><01>Z e
j ddd<10><01>Z ddd<13>Z ddd<15>ZGdd<17>d<17>Z<0F>ZS)<1C>ClusterableModelc s<>dd<02>t|<00>D<00>dd<02>t|<00>D<00>}t<02>fdd<05>|D<00><01>rM<72><00><03>}i}|D] }|<06>vr2|<04>|<06>||<q%t<05>j|i|<04><01>|<05><07>D]
\}}t|||<08>q@dSt<05>j|i<00><00><01>dS)zv
Extend the standard model constructor to allow child object lists to be passed in
via kwargs
cS<00>g|]}|<01><00><00>qSr!<00><01>get_accessor_name<6D>rL<00>relr!r!r"rM<00><00>z-ClusterableModel.__init__.<locals>.<listcomp>cS<00>g|]}|j<00>qSr!<00>r(rKr!r!r"rM<00><00>c3s<00>|]}|<01>vVqdS<00>Nr!)rLr(<00>rEr!r"<00> <genexpr><3E>s<02>z,ClusterableModel.__init__.<locals>.<genexpr>N) rQrS<00>any<6E>copy<70>pop<6F>super<65>__init__r.<00>setattr) <09>self<6C>argsrE<00>child_relation_names<65>kwargs_for_super<65>relation_assignments<74>rel_namer5<00>related_instances<65><01> __class__r_r"re<00>s <02><02><02><04>zClusterableModel.__init__c
 s<>dd<02>t|<00>D<00>}dd<02>t|<00>D<00>}|<01>dd<05>}|dur#d}|}|}n$g}g}g}|D]}||vr7|<06>|<08>q+||vrA|<07>|<08>q+|<05>|<08>q+t<04>jdd|i|<01><01>|D] } t|| <09><02><07>qT|D] }t||<08><02><07>q`dS)z@
Save the model and commit all child relations.
cSrUr!rVrXr!r!r"rM<00>rZz)ClusterableModel.save.<locals>.<listcomp>cSr[r!r\rKr!r!r"rM<00>r]<00> update_fieldsNr!)rQrSrc<00>appendrd<00>saver<00>commit)
rgrEri<00>child_m2m_field_namesrp<00>real_update_fields<64>relations_to_commit<69>m2m_fields_to_commitr<00>relationrnr!r"rr<00>s,    <04>zClusterableModel.savecCs<>t|<00>}t|<00>D]&}|<02><02>}t||<03><02><04>}t|jd<01>r%dd<03>|D<00>||<qdd<03>|D<00>||<qt|<00>D]}|jrJt||j <09><02><04>}dd<03>|D<00>||j <q3|S)N<>serializable_datacSrUr!)ry<00>rL<00>childr!r!r"rM<00>rZz6ClusterableModel.serializable_data.<locals>.<listcomp>cSsg|]}t|<01><01>qSr!)r+rzr!r!r"rM<00>rZcSr[r!)rrzr!r!r"rM<00>r])
r+rQrWr<00>all<6C>hasattr<74> related_modelrSr'r()rgr*rYrl<00>childrenrr!r!r"ry<00>s   <02>z"ClusterableModel.serializable_datacCstj|<00><02>td<01>S)N)<01>cls)<04>json<6F>dumpsryr)rgr!r!r"<00>to_json<6F>szClusterableModel.to_jsonTFc
s<>t||<01>|d<01>}|durdSt|<00>}|D]@}|<06><02>}z||}Wn ty)Yqw|j<04>t<05>d<03>r=<3D><00>fdd<05>|D<00>} n
<EFBFBD><00>fdd<05>|D<00>} tdd<08>| <09>} t||| <09>q|S) a<>
Build an instance of this model from the JSON-like structure passed in,
recursing into related objects as required.
If check_fks is true, it will check whether referenced foreign keys still
exist in the database.
- dangling foreign keys on related objects are dealt with by either nullifying the key or
dropping the related object, according to the 'on_delete' setting.
- dangling foreign keys on the base object will be nullified, unless strict_fks is true,
in which case any dangling foreign keys with on_delete=CASCADE will cause None to be
returned for the entire object.
<20>rCrDN<>from_serializable_datacsg|]
}<01>j|<01>dd<01><03>qS<00>Tr<54>)r<><00>rL<00>
child_data<EFBFBD>rCr~r!r"rM<00><0E><06>z;ClusterableModel.from_serializable_data.<locals>.<listcomp>csg|]
}t<00>|<01>dd<01><04>qSr<>)rIr<>r<>r!r"rM r<>cSs|duSr^r!)r{r!r!r"<00><lambda>sz9ClusterableModel.from_serializable_data.<locals>.<lambda>)rIrQrW<00>KeyErrorr~r}r2rf)
r<EFBFBD>rBrCrDr*<00>child_relationsrYrl<00>child_data_listrr!r<>r"r<><00>s,   <02>
 <08> <06>z'ClusterableModel.from_serializable_datacCs|jt<01>|<01>||d<01>S)Nr<4E>)r<>r<><00>loads)r<><00> json_datarCrDr!r!r"<00> from_jsonszClusterableModel.from_jsonc Cs<>i}t|t<01>r |j<02>|<01>}t|jt<05>std<01><01>|jj}t ||<01>
<EFBFBD><00>}t ||<01>
<EFBFBD><00>}|s/|<08> <0B>|<07> <0C><00> d<02>D]8} | j}
|
du} d| _t| ||j<10>|<08>| <09>|
durY| |||
f<q6|df|vreg||df<||df<00>| <09>q6|ru|<08><13>|S)a[
Copies all of the objects in the accessor_name to the target object.
For example, say we have an event with speakers (my_event) and we need to copy these to another event (my_other_event):
my_event.copy_child_relation('speakers', my_other_event)
By default, this copies the child objects without saving them. Set the commit paremter to True to save the objects
but note that this would cause an exception if the target object is not saved.
This will overwrite the child relation on the target object. This is to avoid any issues with unique keys
and/or sort_order. If you want it to append. set the `append` parameter to True.
This method returns a dictionary mapping the child relation/primary key on the source object to the new object created for the
target object.
zQcopy_child_relation can only be used for relationships defined with a ParentalKeyrN)r<00>strr$r/rr <00> LookupErrorrr-rrW<00>clearr|<00>order_byrrf<00>idr rqrs) rg<00>child_relation<6F>targetrsrq<00>child_object_map<61>parental_key_name<6D>source_manager<65>target_manager<65> child_object<63>old_pk<70>is_savedr!r!r"<00>copy_child_relations0
  
  z$ClusterableModel.copy_child_relationNc CsD|pg}i}t|<00>D]}|<06><01>|vrq
|<05>|j||||d<01><04>q
|S)a<>
Copies all of the objects in all child relations to the target object.
This will overwrite all of the child relations on the target object.
Set exclude to a list of child relation accessor names that shouldn't be copied.
This method returns a dictionary mapping the child_relation/primary key on the source object to the new object created for the
target object.
)rsrq)rQrW<00>updater<65>)rgr<><00>excludersrqr<>r<>r!r!r"<00>copy_all_child_relationsSs   z)ClusterableModel.copy_all_child_relationscCs<>|pg}i}|j<00><01>D]T}|j|vrq |jrq |jr6t|t<06>r5t||j<02>}t|d<01>r5|<04> <09>}|r5|||j<q t|t
j <0B>rA|j j rAq t|t
j<0E>rVd||j<t||j<0F>||j<q t||j<02>||j<q |jdi|<02><01>}|j||d<03>}||fS)a
Makes a copy of this object and all child relations.
Includes all field data including child relations and parental many to many fields.
Doesn't include non-parental many to many.
The result of this method is unsaved.
r|N)r<>r!)r$rOr(<00> auto_created<65> many_to_manyrr rr}r|r<00> OneToOneFieldrr%<00>
ForeignKeyr-ror<>)rg<00>exclude_fields<64> data_dictr<00>parental_field<6C>valuesrbr<>r!r!r"<00> copy_clusteris0


 

 
zClusterableModel.copy_clusterc@seZdZdZdS)zClusterableModel.MetaTN)<04>__name__<5F>
__module__<EFBFBD> __qualname__<5F>abstractr!r!r!r"<00>Meta<74>sr<><00>TF)FF)NFFr^)r<>r<>r<>rerrryr<><00> classmethodr<64>r<>r<00>atomicr<63>r<>r<>r<><00> __classcell__r!r!rnr"rT<00>s    +  
:
;rTr<>)<1D>
__future__rr<>r<00>django.core.exceptionsr<00> django.dbrr<00>django.db.models.fields.relatedr<00>django.utils.encodingr<00>django.core.serializers.jsonr<00> django.confr <00> django.utilsr
<00>modelcluster.fieldsr r r#r+rIrQrS<00>ModelrTr!r!r!r"<00><module>s"       
H