Ensure that Item.folder works in all cases.#32
Ensure that Item.folder works in all cases.#32hoffie wants to merge 1 commit intozarafagroupware:masterfrom
Conversation
The internal attribute Item._folder should always be initialized, at least with None. If possible, _folder should be pre-populated with parent data from the outside as this should be better performing than doing a repeated lookup. Fixes zarafagroupware#31.
|
I agree that it is a bug, but I think we should fix it either in the init() or add a check in the Item.folder() code to check if the store exists. So that Item creation with a mapiobj is a bit less buggy. The last solution also reveals the following bug So I guess we then need to set the store explicitly in the init(). |
|
Thanks for the fast reply. I am a bit unsure whether you are actually suggesting the same what I proposed or something different. :) To clarify, I would suggest to initialize _folder in In addition, I only propose to pre-initialize new Item objects with a parent if possible as this should help with performance. |
| """ Return :class:`Item` with given entryid; raise exception of not found """ # XXX better exception? | ||
|
|
||
| item = Item() # XXX copy-pasting.. | ||
| item = Item(parent=self) # XXX copy-pasting.. |
There was a problem hiding this comment.
'self' is a Store, so not really the direct parent of the item.. but note that 'Item.folder' looks up the correct parent folder using PR_PARENT_ENTRYID.
|
alright, jelle, so I guess we want to merge the Item(parent=self) changes when Item() is called from a Folder method. and probably it should be Item(folder=self) by now. |
|
@srepmub, yes, one Item(folder=self) instance seems to be wrong as you noted. Is there anything else I should do with the pull request? |
|
Looks good, we will merge this when the repo is up to date |
The internal attribute Item._folder should always be initialized,
at least with None.
If possible, _folder should be pre-populated with parent data from
the outside as this should be better performing than doing a repeated lookup.
Fixes #31.