本文整理汇总了Python中announcer.model.SubscriptionAttribute类的典型用法代码示例。如果您正苦于以下问题:Python SubscriptionAttribute类的具体用法?Python SubscriptionAttribute怎么用?Python SubscriptionAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SubscriptionAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_update
def do_update(db):
SubscriptionAttribute.delete_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass)
blogs = set(map(lambda x: x.strip(),
req.args.get('announcer_watch_bloggers').split(',')))
SubscriptionAttribute.add(self.env, req.session.sid,
req.session.authenticated, klass, 'blog', blogs)
示例2: set_unwatch
def set_unwatch(self, sid, authenticated, realm, target):
klass = self.__class__.__name__
(attr,) = SubscriptionAttribute.find_by_sid_class_realm_and_target(
self.env, sid, authenticated, klass, realm, target
)
if attr:
SubscriptionAttribute.delete(self.env, attr["id"])
示例3: render_announcement_preference_box
def render_announcement_preference_box(self, req, panel):
klass = self.__class__.__name__
if req.method == "POST":
with self.env.db_transaction as db:
SubscriptionAttribute.\
delete_by_sid_and_class(self.env, req.session.sid,
req.session.authenticated,
klass, db)
def _map(value):
g = re.match('^joinable_group_(.*)', value)
if g:
if req.args.as_bool(value):
return g.groups()[0]
groups = set(filter(None, map(_map, req.args.keys())))
SubscriptionAttribute.add(self.env, req.session.sid,
req.session.authenticated, klass,
'ticket', groups, db)
attrs = filter(None, map(
lambda x: x['target'],
SubscriptionAttribute.find_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass
)
))
data = dict(joinable_groups={})
for group in self.joinable_groups:
data['joinable_groups'][group] = (group in attrs) and True or None
return 'prefs_announcer_joinable_groups.html', data
示例4: do_update
def do_update(db):
SubscriptionAttribute.delete_by_sid_and_class(self.env,
req.session.sid, req.session.authenticated, klass, db)
users = map(lambda x: x.strip(),
req.args.get("announcer_watch_users").split(','))
SubscriptionAttribute.add(self.env, req.session.sid,
req.session.authenticated, klass, 'user', users, db)
示例5: do_update
def do_update(db):
SubscriptionAttribute.delete_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass, db
)
def _map(value):
g = re.match("^component_(.*)", value)
if g:
if istrue(req.args.get(value)):
return g.groups()[0]
components = set(filter(None, map(_map, req.args.keys())))
SubscriptionAttribute.add(
self.env, req.session.sid, req.session.authenticated, klass, "ticket", components, db
)
示例6: render_announcement_preference_box
def render_announcement_preference_box(self, req, panel):
klass = self.__class__.__name__
if req.method == "POST":
@self.env.with_transaction()
def do_update(db):
SubscriptionAttribute.delete_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass, db
)
def _map(value):
g = re.match("^joinable_group_(.*)", value)
if g:
if istrue(req.args.get(value)):
return g.groups()[0]
groups = set(filter(None, map(_map, req.args.keys())))
SubscriptionAttribute.add(
self.env, req.session.sid, req.session.authenticated, klass, "ticket", groups, db
)
attrs = filter(
None,
map(
lambda x: x["target"],
SubscriptionAttribute.find_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass
),
),
)
data = dict(joinable_groups={})
for group in self.joinable_groups:
data["joinable_groups"][group] = (group in attrs) and True or None
return "prefs_announcer_joinable_groups.html", data
示例7: post_process_request
def post_process_request(self, req, template, data, content_type):
if 'BLOG_VIEW' not in req.perm:
return (template, data, content_type)
if '_blog_watch_message_' in req.session:
add_notice(req, req.session['_blog_watch_message_'])
del req.session['_blog_watch_message_']
if req.authname == "anonymous":
return (template, data, content_type)
# FullBlogPlugin sets the blog_path arg in pre_process_request
name = req.args.get('blog_path')
if not name:
return (template, data, content_type)
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_sid_class_and_target(
self.env, req.session.sid, req.session.authenticated, klass, name)
if attrs:
add_ctxtnav(req, tag.a(_('Unwatch This'),
href=req.href.blog_watch(name)))
else:
add_ctxtnav(req, tag.a(_('Watch This'),
href=req.href.blog_watch(name)))
return (template, data, content_type)
示例8: matches
def matches(self, event):
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_class_realm_and_target(self.env, klass, "user", event.author)
sids = set(map(lambda x: (x["sid"], x["authenticated"]), attrs))
for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
yield i.subscription_tuple()
示例9: is_watching
def is_watching(self, sid, authenticated, realm, target):
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_sid_class_realm_and_target(
self.env, sid, authenticated, klass, realm, target)
if attrs:
return True
else:
return False
示例10: matches
def matches(self, event):
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_class_realm_and_target(self.env,
klass, event.realm, self._get_target_id(event.target))
sids = set(map(lambda x: (x['sid'],x['authenticated']), attrs))
for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
yield i.subscription_tuple()
示例11: render_announcement_preference_box
def render_announcement_preference_box(self, req, panel):
klass = self.__class__.__name__
if req.method == "POST":
with self.env.db_transaction:
SubscriptionAttribute.delete_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated,
klass)
blogs = set(map(lambda x: x.strip(),
req.args.get(
'announcer_watch_bloggers').split(',')))
SubscriptionAttribute.add(self.env, req.session.sid,
req.session.authenticated, klass,
'blog', blogs)
attrs = SubscriptionAttribute.\
find_by_sid_and_class(self.env, req.session.sid,
req.session.authenticated, klass)
data = {'sids': ','.join(set(map(lambda x: x['target'], attrs)))}
return 'prefs_announcer_watch_bloggers.html', dict(data=data)
示例12: process_request
def process_request(self, req):
klass = self.__class__.__name__
m = re.match(r'^/blog_watch/(.*)', req.path_info)
(name,) = m.groups()
with self.env.db_transaction:
attrs = SubscriptionAttribute.find_by_sid_class_and_target(
self.env, req.session.sid, req.session.authenticated,
klass, name)
if attrs:
SubscriptionAttribute.delete_by_sid_class_and_target(
self.env, req.session.sid, req.session.authenticated,
klass, name)
req.session['_blog_watch_message_'] = \
_("You are no longer watching this blog post.")
else:
SubscriptionAttribute.add(
self.env, req.session.sid, req.session.authenticated,
klass, 'blog', (name,))
req.session['_blog_watch_message_'] = \
_("You are now watching this blog post.")
req.redirect(req.href.blog(name))
示例13: matches
def matches(self, event):
if event.realm != 'blog':
return
if event.category not in ('post created', 'post changed',
'post deleted', 'comment created',
'comment changed', 'comment deleted'):
return
klass = self.__class__.__name__
sids = set(map(lambda x: (x['sid'], x['authenticated']),
SubscriptionAttribute.find_by_class_realm_and_target(
self.env, klass, 'blog', event.blog_post.author)))
for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
yield i.subscription_tuple()
示例14: matches
def matches(self, event):
if event.realm != 'ticket':
return
if event.category not in ('changed', 'created', 'attachment added'):
return
component = event.target['component']
if not component:
return
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_class_realm_and_target(
self.env, klass, 'ticket', component)
sids = set(map(lambda x: (x['sid'], x['authenticated']), attrs))
for i in Subscription.find_by_sids_and_class(self.env, sids, klass):
yield i.subscription_tuple()
示例15: render_announcement_preference_box
def render_announcement_preference_box(self, req, panel):
klass = self.__class__.__name__
if req.method == "POST":
@self.env.with_transaction()
def do_update(db):
SubscriptionAttribute.delete_by_sid_and_class(self.env,
req.session.sid, req.session.authenticated, klass, db)
SubscriptionAttribute.add(self.env, req.session.sid,
req.session.authenticated, klass,
'wiki', req.args.get('wiki_interests', db))
(interests,) = SubscriptionAttribute.find_by_sid_and_class(
self.env, req.session.sid, req.session.authenticated, klass
) or ({'target':''},)
return "prefs_announcer_wiki.html", dict(
wiki_interests = '\n'.join(
urllib.unquote(x) for x in interests['target'].split(' ')
)
)