py-trello
py-trello copied to clipboard
Card.checklist is failing
DEBUG 2015-06-09 23:29:07,418 Configuring Raven for host: http://DEADBEEFDEADBEEFDEADBEEFDEADBEEF:DEADBEEFDEADBEEFDEADBEEFDEADBEEF@localhost:9000:/2
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/envs/cinematique/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/opt/envs/cinematique/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/envs/cinematique/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/opt/envs/cinematique/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/srv/www/cinematique/cin/core/management/commands/test_trello.py", line 24, in handle
API.create_new_uploaded_card(list_id=TrelloAPI.TRELLO_IPP_CONSTANTS['UPLOADED'], video=None)
File "/srv/www/cinematique/cin/core/trello_api.py", line 64, in create_new_uploaded_card
print card.checklists
File "/opt/envs/cinematique/local/lib/python2.7/site-packages/trello/__init__.py", line 744, in checklists
if self._checklists is None:
AttributeError: 'Card' object has no attribute '_checklists'```
@sarumont Trying to access data before fetching it an easy mistake for various objects (Card, Member, etc). It would be tedious but maybe we should add getter for all properties set by fetch function like bellow ?
@property
def checklists(self):
try:
if self._checklists is None:
self._checklists = self.fetch_checklists()
except AttributeError:
self._checklists = self.fetch_checklists()
return self._checklists
Yeah, I think lazy initialization is a good approach. Tedious, but correct. :)
I should have some time this weekend to work on this.
On Sat, Jul 18, 2015 at 5:38 PM Nathan Mustaki [email protected] wrote:
@sarumont https://github.com/sarumont Trying to access data before fetching it an easy mistake for various objects (Card, Member, etc). It would be tedious but maybe we should add getter for all properties set by fetch function like bellow ?
@propertydef checklists(self): try: if self._checklists is None: self._checklists = self.fetch_checklists() except AttributeError: self._checklists = self.fetch_checklists() return self._checklists
— Reply to this email directly or view it on GitHub https://github.com/sarumont/py-trello/issues/93#issuecomment-122604752.
Great! I started adding more tests, I'll add a pull request soon too
On Fri, 24 Jul 2015 19:49 Richard Kolkovich [email protected] wrote:
Yeah, I think lazy initialization is a good approach. Tedious, but correct. :)
I should have some time this weekend to work on this.
On Sat, Jul 18, 2015 at 5:38 PM Nathan Mustaki [email protected] wrote:
@sarumont https://github.com/sarumont Trying to access data before fetching it an easy mistake for various objects (Card, Member, etc). It would be tedious but maybe we should add getter for all properties set by fetch function like bellow ?
@propertydef checklists(self): try: if self._checklists is None: self._checklists = self.fetch_checklists() except AttributeError: self._checklists = self.fetch_checklists() return self._checklists
— Reply to this email directly or view it on GitHub <https://github.com/sarumont/py-trello/issues/93#issuecomment-122604752 .
— Reply to this email directly or view it on GitHub https://github.com/sarumont/py-trello/issues/93#issuecomment-124597898.
Hi, I just have faced this issue. The problem is that self._checklists is not being initialized in the init(). Right now you avoid the exception but the property returns None in the first call. In the second call you get the proper value.