
    W
h0                     h    S SK Jr  S SKJrJrJrJrJrJr  Sr	Sr
Sr " S S\5      r " S S	\5      rg
)    )OperationError)CASCADEDENY
DO_NOTHINGNULLIFYPULLBaseQuerySet)QuerySetQuerySetNoCacher   r   r   r   r      d   c                   `   ^  \ rS rSrSrSrSrSrS rS r	S r
S rS	 rSU 4S
 jjrS rSrU =r$ )r
      zThe default queryset, that builds queries and handles a set of results
returned from a query.

Wraps a MongoDB cursor, providing :class:`~mongoengine.Document` objects as
the results.
TNc                 |    SU l         U R                  (       a  U R                  5       $ [        U R                  5      $ )zIteration utilises a results cache which iterates the cursor
in batches of ``ITER_CHUNK_SIZE``.

If ``self._has_more`` the cursor hasn't been exhausted so cache then
batch. Otherwise iterate the result_cache.
T)_iter	_has_more_iter_resultsiter_result_cacheselfs    eC:\Users\julio\Documents\inmuebles-mzt\backend\env\Lib\site-packages\mongoengine/queryset/queryset.py__iter__QuerySet.__iter__&   s4     
>>%%'' D&&''    c                     U R                   b  U R                   $ U R                  (       a  [        U R                  5       5        [	        U R
                  5      U l         U R                   $ )zSince __len__ is called quite frequently (for example, as part of
list(qs)), we populate the result cache and cache the length.
)_lenr   listr   lenr   r   s    r   __len__QuerySet.__len__5   sP     99 99 >>##%& **+	yyr   c                     U R                   (       a  gU R                  5         U R                  S[        S-    n[	        U5      [        :  a  SUS'   [        U5      $ )z/Provide a string representation of the QuerySet.. queryset mid-iteration ..N   $...(remaining elements truncated)...)r   _populate_cacher   REPR_OUTPUT_SIZEr   repr)r   datas     r   __repr__QuerySet.__repr__D   sQ    ::1!!"8$4q$89t9''=DHDzr   c              #   F  #    U R                   c  / U l         Sn U[        U R                   5      :  a1  U R                   U   v   US-  nU[        U R                   5      :  a  M1  U R                  (       d  g[        U R                   5      U::  a  U R                  5         M  7f)zA generator for iterating over the result cache.

Also populates the cache if there are more possible results to
yield. Raises StopIteration when there are no more results.
Nr   r$   )r   r   r   r'   )r   poss     r   r   QuerySet._iter_resultsO   s      %!#D D..//((--q D..// >> 4%%&#-$$&) s   A B!$=B!c                     U R                   c  / U l         U R                  (       d  g [        [        5       H'  nU R                   R	                  [        U 5      5        M)     g! [         a
    SU l         gf = f)zc
Populates the result cache with ``ITER_CHUNK_SIZE`` more entries
(until the cursor is exhausted).
NF)r   r   rangeITER_CHUNK_SIZEappendnextStopIteration)r   _s     r   r'   QuerySet._populate_cacheo   sh    
 %!#D ~~	#?+""))$t*5 , 	# #DN		#s   :A# #A76A7c                    > USL a  [         TU ]  U5      $ U R                  c  [         TU ]  U5      U l        U R                  $ )zCount the selected elements in the query.

:param with_limit_and_skip (optional): take any :meth:`limit` or
    :meth:`skip` that has been applied to this cursor into account when
    getting the count
F)supercountr   )r   with_limit_and_skip	__class__s     r   r:   QuerySet.count   sB     %'7=!45599&9:DIyyr   c                     U R                   b  [        S5      eU R                  [        U R                  U R
                  5      5      $ )z!Convert to a non-caching querysetzQuerySet already cached)r   r   _clone_intor   	_document_collectionr   s    r   no_cacheQuerySet.no_cache   s<    ) !:;;@P@P QRRr   )r   r   r   r   )F)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r    r+   r   r'   r:   rB   __static_attributes____classcell__)r<   s   @r   r
   r
      sD     IDM(	'@#0 S Sr   r
   c                   *    \ rS rSrSrS rS rS rSrg)r      zA non caching QuerySetc                 `    U R                  [        U R                  U R                  5      5      $ )zConvert to a caching queryset)r?   r
   r@   rA   r   s    r   cacheQuerySetNoCache.cache   s$    9I9I JKKr   c                    U R                   (       a  g/ n[        [        S-   5       H  n UR                  [	        U 5      5        M      [        U5      [        :  a  SUS'   U R                  5         [        U5      $ ! [
         a       MA  f = f)z2Provides the string representation of the QuerySetr#   r$   r%   r&   )	r   r1   r(   r3   r4   r5   r   rewindr)   )r   r*   r6   s      r   r+   QuerySetNoCache.__repr__   sz    ::1'!+,ADJ' - t9''=DHDz ! s   A<<
B
Bc                 l    U nUR                   (       a  U R                  5       nUR                  5         U$ )N)r   clonerQ   )r   querysets     r   r   QuerySetNoCache.__iter__   s(    >>zz|Hr    N)	rD   rE   rF   rG   rH   rN   r+   r   rI   rW   r   r   r   r      s     L$r   r   N)mongoengine.errorsr   mongoengine.queryset.baser   r   r   r   r   r	   __all__r(   r2   r
   r   rW   r   r   <module>r[      sC    -   BS| BSJl r   