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.

4

1 回答 1

0

由于 Trac 0.12 有trac.web.chrome.add_script_data,这可能满足您的需要。

于 2013-05-20T20:29:44.820 回答