本文整理汇总了Python中trac.ticket.query.Query.get_href方法的典型用法代码示例。如果您正苦于以下问题:Python Query.get_href方法的具体用法?Python Query.get_href怎么用?Python Query.get_href使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.query.Query
的用法示例。
在下文中一共展示了Query.get_href方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from trac.ticket.query import Query [as 别名]
# 或者: from trac.ticket.query.Query import get_href [as 别名]
def process_request(self, req):
if req.method != 'POST':
raise HTTPBadRequest(_("Only POST is supported"))
query = Query(self.env,
constraints=QueryModule(self.env)._get_constraints(req),
cols=req.args['col'],
desc=req.args.get('desc', 0),
group=req.args['group'],
groupdesc=req.args.get('groupdesc', 0),
max=req.args['max'],
order=req.args['order'])
req.session['default_user_query'] = query.get_href(req.href)
add_notice(req, _("Your default query has been changed"))
# Let the query system handle the request
req.redirect(query.get_href(req.href))
示例2: process_request
# 需要导入模块: from trac.ticket.query import Query [as 别名]
# 或者: from trac.ticket.query.Query import get_href [as 别名]
def process_request(self, req):
req.perm.assert_permission('TICKET_VIEW')
constraints = self._get_constraints(req)
if not constraints and not 'order' in req.args:
# If no constraints are given in the URL, use the default ones.
if req.authname and req.authname != 'anonymous':
qstring = self.default_query
user = req.authname
else:
email = req.session.get('email')
name = req.session.get('name')
qstring = self.default_anonymous_query
user = email or name or None
if user:
qstring = qstring.replace('$USER', user)
self.log.debug('TasklistPlugin: Using default query: %s', qstring)
constraints = Query.from_string(self.env, qstring).constraints
# Ensure no field constraints that depend on $USER are used
# if we have no username.
for field, vals in constraints.items():
for val in vals:
if val.endswith('$USER'):
del constraints[field]
cols = req.args.get('col')
if not cols:
cols = self.default_cols
cols.append(self.field_name)
if isinstance(cols, basestring):
cols = [cols]
form_cols = copy.copy(cols)
# Since we don't show 'id' or the tasklist_field as an option
# to the user, we need to re-insert it here.
if cols and 'id' not in cols:
cols.insert(0, 'id')
if cols and self.field_name not in cols:
cols.insert(0, self.field_name)
rows = req.args.get('row', [])
if isinstance(rows, basestring):
rows = [rows]
q = Query(self.env, constraints=constraints, cols=cols)
query = Query(self.env, req.args.get('report'),
constraints, cols, req.args.get('order'),
'desc' in req.args, req.args.get('group'),
'groupdesc' in req.args, 'verbose' in req.args,
rows,
req.args.get('limit'))
if 'update' in req.args:
# Reset session vars
for var in ('query_constraints', 'query_time', 'query_tickets'):
if var in req.session:
del req.session[var]
req.redirect(q.get_href(req.href).replace('/query', '/tasklist'))
if 'add' in req.args:
req.perm.require('TICKET_CREATE')
t = Ticket(self.env)
if req.method == 'POST' and 'field_owner' in req.args and \
'TICKET_MODIFY' not in req.perm:
del req.args['field_owner']
self._populate(req, t)
reporter_id = req.args.get('field_reporter') or \
get_reporter_id(req, 'author')
t.values['reporter'] = reporter_id
valid = None
valid = self._validate_ticket(req, t)
if valid:
t.insert()
# Notify
try:
tn = TicketNotifyEmail(self.env)
tn.notify(t, newticket=True)
except Exception, e:
self.log.exception("Failure sending notification on creation of "
"ticket #%s: %s" % (t.id, e))
req.redirect(q.get_href(req.href).replace('/query', '/tasklist'))
示例3: process_request
# 需要导入模块: from trac.ticket.query import Query [as 别名]
# 或者: from trac.ticket.query.Query import get_href [as 别名]
def process_request(self, req):
req.perm.assert_permission("TICKET_VIEW")
if not self.env.config.has_option("ticket-custom", self.field_name):
raise TracError(
'Configuration error: the custom ticket field "%s" has not been defined '
"in the [ticket-custom] section of trac.ini. See the documentation "
"for more info on configuring the TaskListPlugin." % self.field_name
)
constraints = self._get_constraints(req)
if not constraints and not "order" in req.args:
# If no constraints are given in the URL, use the default ones.
if req.authname and req.authname != "anonymous":
qstring = self.default_query
user = req.authname
else:
email = req.session.get("email")
name = req.session.get("name")
qstring = self.default_anonymous_query
user = email or name or None
if user:
qstring = qstring.replace("$USER", user)
self.log.debug("TasklistPlugin: Using default query: %s", qstring)
constraints = Query.from_string(self.env, qstring).constraints
# Ensure no field constraints that depend on $USER are used
# if we have no username.
# It may be possible to just use constraints[0] here, rather than
# iterating over constraints. See th#6336.
for constraint in constraints:
for field, vals in constraint.items():
for val in vals:
if val.endswith("$USER"):
del constraint[field]
cols = req.args.get("col")
if not cols:
cols = self.default_cols
cols.append(self.field_name)
if isinstance(cols, basestring):
cols = [cols]
form_cols = copy.copy(cols)
# Since we don't show 'id' or the tasklist_field as an option
# to the user, we need to re-insert it here.
if cols and "id" not in cols:
cols.insert(0, "id")
if cols and self.field_name not in cols:
cols.insert(0, self.field_name)
rows = req.args.get("row", [])
if isinstance(rows, basestring):
rows = [rows]
q = Query(self.env, constraints=constraints, cols=cols)
query = Query(
self.env,
req.args.get("report"),
constraints,
cols,
req.args.get("order"),
"desc" in req.args,
req.args.get("group"),
"groupdesc" in req.args,
"verbose" in req.args,
rows,
req.args.get("limit"),
)
if "update" in req.args:
# Reset session vars
for var in ("query_constraints", "query_time", "query_tickets"):
if var in req.session:
del req.session[var]
req.redirect(q.get_href(req.href).replace("/query", "/tasklist"))
if "add" in req.args:
req.perm.require("TICKET_CREATE")
t = Ticket(self.env)
if req.method == "POST" and "field_owner" in req.args and "TICKET_MODIFY" not in req.perm:
del req.args["field_owner"]
self._populate(req, t)
reporter_id = req.args.get("field_reporter") or get_reporter_id(req, "author")
t.values["reporter"] = reporter_id
valid = None
valid = self._validate_ticket(req, t)
if valid:
t.insert()
# Notify
try:
tn = TicketNotifyEmail(self.env)
tn.notify(t, newticket=True)
except Exception, e:
self.log.exception("Failure sending notification on creation of " "ticket #%s: %s" % (t.id, e))
req.redirect(q.get_href(req.href).replace("/query", "/tasklist"))