Permalink
Browse files

Save the fields we've gathered in a 'fields' attributes, and add a to…

…_json_obj() method to the Ticket class so that we can output the whole ticket as a dict/array suitable for JSONing
  • Loading branch information...
1 parent 8dcf096 commit f002a23cee23b6673551f4fcea01bd81a639fe13 @rcoup rcoup committed Dec 22, 2010
Showing with 10 additions and 3 deletions.
  1. +10 −3 lighthouse.py
View
@@ -320,8 +320,9 @@ def get_tickets(self, project, page=1):
for field in ticket['children']:
field_name, field_value, field_type = \
self._parse_field(field)
- t_obj.__setattr__(field_name.replace('-', '_'),\
- field_value)
+ py_field_name = field_name.replace('-', '_')
+ t_obj.__setattr__(py_field_name, field_value)
+ t_obj.fields.add(py_field_name)
project.tickets[t_obj.number] = t_obj
return c
@@ -364,13 +365,19 @@ class Ticket(object):
</ticket>"""
def __init__(self):
super(Ticket, self).__init__()
+ self.versions = []
+ self.attachments = []
+ self.fields = set()
def __repr__(self):
if self.title:
return "Ticket: %s" % (self.title,)
else:
return "Ticket: Unnamed"
-
+
+ def to_json_obj(self):
+ return dict([(f, getattr(self, f)) for f in self.fields])
+
class Project(object):
"""Projects contain milestones, tickets, messages, and changesets"""

0 comments on commit f002a23

Please sign in to comment.