In my TracPM module, I want to give schedulers free reign over ticket data. I used to do:

    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']] = t

        # Schedule the tickets
        self.scheduler.scheduleTasks(options, ticketsByID)

but changes made by the scheduler were carried back to the caller. I started with:

    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']] = copy.copy(t)

        # 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]

But the ticket attritbutes weren't copied, only the references to them. I tried but deepcopy() but that gives:

File "build/bdist.linux-x86_64/egg/tracjsgantt/tracjsgantt.py", line 558, in _add_tasks
    self.pm.computeSchedule(options, self.tickets)
File "build/bdist.linux-x86_64/egg/tracjsgantt/tracpm.py", line 566, in computeSchedule
    ticketsByID[t['id']] = copy.deepcopy(t)
  File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.6/copy.py", line 322, in _reconstruct
    args = deepcopy(args, memo)
  File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.6/copy.py", line 323, in _reconstruct
    y = callable(*args)
  TypeError: __init__() takes exactly 3 arguments (1 given)

Is this a known restriction of some Trac classes? A bug? My misuse of deepcopy()?

This is in Trac 0.11.6.

Any insight appreciated.

                                                 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.

Reply via email to