On 01/12/2012 01:38 PM, Ethan Jucovy wrote:
On Thu, Jan 12, 2012 at 1:31 PM, Chris Nelson<[email protected]> wrote:
But even
[snip]
ticketsByID[t['id']] = copy.copy(dict(t))
[snip]
# Copy back the schedule results
for t in tickets:
for field in [ 'calc_start', 'calc_finish']:
t[field] = ticketsByID[t['id']][field]
leaves changes to ticketsByID visible in tickets to the caller of
computeSchedule(). And if I do `copy.deepcopy(dict(t))` I'm back to
`__init__() takes exactly 3 arguments (1 given)`.
Huh. Then it sounds like you need to drop into an interactive pdb
session in there to inspect the dict and figure out exactly what
nested object is involved. Once you isolate that you can just
special-case it one way or another.
For now
# tickets is an unordered list of tickets. Each ticket contains
# at least the fields returned by queryFields() and the whole list
# was processed by postQuery().
def computeSchedule(self, options, tickets):
# Convert list to dictionary, making copies so schedule can
# mess with the tickets.
ticketsByID = {}
for t in tickets:
ticketsByID[t['id']] = {}
for field in t:
ticketsByID[t['id']][field] = copy.copy(t[field])
# Schedule the tickets
self.scheduler.scheduleTasks(options, ticketsByID)
# Copy back the schedule results
for t in tickets:
for field in [ 'calc_start', 'calc_finish']:
t[field] = ticketsByID[t['id']][field]
works and I can clean it up later.
Thanks to all for their patience.
Chris
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.