Closed Kyle-yrnhe closed 2 years ago
Hi @Kyle-yrnhe ,
Is folder.get_items(limit=100, offeset=0) returning a NoneType for _all_items expected behavior?
Yes, get_items returns Iterable and you can iterate easily over all items. Underneath it is doing an API call each time you ask for items. So unless you start iterating over this _all_items
attribute will be None
, but after first call it will be <generator object BoxObjectCollection._items_generator>
root = client.folder("0")
for item in root.get_items(limit=2, offset=0):
print(f'{item.id} [{item.type}] "{item.name}"')
Limit and offset are respected. Iterable will allow you to get ALL elements in the folder. Each call will get up to the specified limit of the elements and execute next call to get another page once you consume all elements requested. You can check that by switching to LoggingClient
, it will log all API calls.
Hey @antusus thank you for the quick and concise answer! Requesting as an iteration resolves all questions that I had.
Description of the Issue
Since updating to the latest version, calling folder.get_items() returns as a box object with an attribute _all_items. During initial testing on 3.2.0 this attribute was a generator of all items in the Folder. Now any attempt to call get_items() returns with a None type for the _all_items attribute. I see that the items are available in the "Item_Collection" of the folder itself though.
My questions Are: Is folder.get_items(limit=100, offeset=0) returning a NoneType for _all_items expected behavior? I have verified there are numerous items in the folder. Does the size of item_collection for a Folder respect a limit size? If so, are there any plans to allow passing a limit to a Folder call?
Steps to Reproduce
Expected Behavior
I expect the get_items method to return a list of Items in the Folder.
Error Message, Including Stack Trace
There is no error message, just a None Type where I would expect a List or Generator
Screenshots
Versions Used
Python SDK: 3.3.0 Python: 3.8