0

Is there any way to pass a javascript varialbe during process_request in trac 0.11? The code goes like this:

def process_request(self, req):

    component = req.args.get('component_name')
    milestones = []
    db = self.env.get_db_cnx()
    cursor = db.cursor()
    milestones_sql = "SELECT name FROM milestone WHERE component = '" + component+ "'"
    cursor.execute(milestones_sql)
    milestones = cursor.fetchall()
    milestones = itertools.chain(*milestones)
    db.commit()
    return 'filter.js', {'milestones':json.dumps(list(milestones))}, 'text/plain' 

I get arguments, do a SQL query, and want to return result to a script. Not as a string though.

konart
  • 1,714
  • 1
  • 12
  • 19

1 Answers1

0

Since Trac 0.12 there is trac.web.chrome.add_script_data, that might serve your need.

hasienda
  • 2,390
  • 1
  • 13
  • 16
  • I've noticed that too, but upgrade is still in "planned" and the backport wasn't a solution either. However I've found solution that doesn't require additional data passed to the script. Thank you anyway! – konart May 31 '13 at 10:03
  • Sharing it here would be liked by followers on this question. Hint: You're even allowed to write a good answer to your own question and accept that one. – hasienda Jun 06 '13 at 03:43