当前位置: 首页>>代码示例>>Python>>正文


Python Notification.put方法代码示例

本文整理汇总了Python中models.Notification.put方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.put方法的具体用法?Python Notification.put怎么用?Python Notification.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Notification的用法示例。


在下文中一共展示了Notification.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
 def post(self):
   notification = Notification(
       item_cl = Model.get(Key(self.request.get('key'))),
       message = self.request.get('message'),
       user = users.User(self.request.get('email')),
       is_cl = ("True" == self.request.get('is_cl')),
       time = datetime.now(),
       read = False)
   notification.put()
开发者ID:yoooyle,项目名称:checklist,代码行数:11,代码来源:notify.py

示例2: update_tree

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
 def update_tree(self,tree_dict):
     
     try:
         tree_dict = self.merged_tree(tree_dict)
     except:
         return False, ['invalid_parameters']
     
     if tree_dict['tree_name'] is None:
         return False, ['tree_not_found']
     
     if tree_dict['moderatorname'] is None:
         return False, ['unauthenticated']
     
     author_info = UserInfo.get_by_username(tree_dict['moderatorname'])
     
     if author_info is None or not self.is_user_info_current(author_info):
         return False, ['unauthenticated']
     
     if author_info.username is None:
         return False, ['invalid_user']
     
     tree = Tree.get_by_name(tree_dict['tree_name'])
     
     tree.conventions = tree_dict['conventions']
     
     tree.link_moderator_only = tree_dict['link_moderator_only']
     tree.link_max = tree_dict['link_max']
     tree.link_prompt = tree_dict['link_prompt']
     
     tree.content_moderator_only = tree_dict['content_moderator_only']
     tree.content_max = tree_dict['content_max']
     tree.content_prompt = tree_dict['content_prompt']
         
     tree.single_thread = tree_dict['single_thread']
     
     tree.branch_max = tree_dict['branch_max']
     
     tree.put()
     
     notification = Notification()
     notification.from_username = tree.moderatorname
     #only set the to_username when a different user is performing the action
     notification.notification_type = 'edit_tree'
     notification.tree_name = tree_dict['tree_name']
     notification.put()
         
     return True, tree
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:49,代码来源:controllers.py

示例3: post

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
    def post(self, hash):
        hash = hash.lower()
        target = Account.all().filter("hash =", hash).get()
        if not target:
            target = Account.all().filter("hashes =", hash).get()
        source = Account.all().filter("api_key =", self.request.get("api_key")).get()

        channel = Channel.all().filter("target =", target).filter("source =", source).get()
        approval_notice = None
        if not channel and source and target:
            channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
            channel.put()
            approval_notice = channel.get_approval_notice()
            channel.send_activation_email()

        if channel:
            notice = Notification(channel=channel, text=strip_tags(self.request.get("text")), icon=source.source_icon)
            for arg in ["title", "link", "icon", "sticky", "tags"]:
                value = strip_tags(self.request.get(arg, None))
                if value:
                    setattr(notice, arg, value)
            notice.put()

            # Increment the counter on the channel to represent number of notices sent
            channel.count += 1
            channel.put()

            if channel.status == "enabled":
                notice.dispatch()
                self.response.out.write("OK\n")

            elif channel.status == "pending":
                self.response.set_status(202)
                if approval_notice:
                    approval_notice.dispatch()
                    self.response.out.write("OK\n")
                else:
                    self.response.out.write("202 Pending approval")
            elif channel.status == "disabled":
                self.response.set_status(202)
                self.response.out.write("202 Accepted but disabled")
        else:
            self.error(404)
            self.response.out.write("404 Target or source not found")
开发者ID:Mondego,项目名称:pyreco,代码行数:46,代码来源:allPythonContent.py

示例4: post

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
 def post(self): 
     hash = self.request.path.split('/')[-1]
     target = Account.all().filter('hash =', hash).get()
     if not target:
         target = Account.all().filter('hashes =', hash).get()
     source = Account.all().filter('api_key =', self.request.get('api_key')).get()
     
     channel = Channel.all().filter('target =', target).filter('source =', source).get()
     approval_notice = None
     if not channel and source and target:
         channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
         channel.put()
         approval_notice = channel.get_approval_notice()
         channel.send_activation_email()
         
     if channel:
         notice = Notification(channel=channel, text=strip_tags(self.request.get('text')), icon=source.source_icon)
         for arg in ['title', 'link', 'icon', 'sticky', 'tags']:
             value = strip_tags(self.request.get(arg, None))
             if value:
                 setattr(notice, arg, value)
         notice.put()
         
         # Increment the counter on the channel to represent number of notices sent
         channel.count += 1
         channel.put()
         
         if channel.status == 'enabled':
             self.response.out.write(notice.dispatch())
             
         elif channel.status == 'pending':
             self.response.set_status(202)
             if approval_notice:
                 self.response.out.write(":".join([channel.outlet.hash, approval_notice.to_json()]))
             else:
                 self.response.out.write("202 Pending approval")
         elif channel.status == 'disabled':
             self.response.set_status(202)
             self.response.out.write("202 Accepted but disabled")
     else:
         self.error(404)
         self.response.out.write("404 Target or source not found")
开发者ID:DFectuoso,项目名称:notify-io,代码行数:44,代码来源:api.py

示例5: processParticipant

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
 def processParticipant(self, person, meeting):
     logging.info('Processing {}'.format(person.name))
     note = Notification(meeting=meeting.key.id(), person=person.key.id())
     note.put()
开发者ID:ShyAlon,项目名称:herex,代码行数:6,代码来源:main.py

示例6: save_branch

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
    def save_branch(self,authorname,parent_urlsafe_key,link,content):
        
        userinfo = UserInfo.get_by_username(authorname)    
        if userinfo is None or not self.is_user_info_current(userinfo):
            
            return False, [ 'unauthenticated' ]
        
        branch = Branch()
        branch.authorname = authorname
        
        parent_key = ndb.Key(urlsafe=parent_urlsafe_key)
        parent_branch = parent_key.get()
        
        if parent_branch is None:
            return False, ['parent_branch_not_found']
        
        branch.tree_name = parent_branch.tree_name
        
        tree = Tree.get_by_name(parent_branch.tree_name)
        
        if tree is None:
            return False, ['tree_not_found']

        if tree.moderatorname == authorname or not tree.link_moderator_only:
            branch.link = link
        else:
            branch.link = ""
        
        if tree.moderatorname == authorname or not tree.content_moderator_only:
            branch.content = content
        else:
            branch.content = ""
        
        errors = self.validate_branch(tree, branch,authorname)
                    
#currently there is a db lock on unique links
#eventually we should have a memcache lcok
        
        authored_branch_count = 0
                
        branchs = parent_branch.children()
        
        if tree.single_thread and parent_branch.authorname == authorname:
            errors.append('has_single_thread_parent_branch')
        
        if tree.single_thread and len(branchs) > 0:
            errors.append('has_single_thread_branch')
        
        for branch_branch in branchs:
            if branch_branch.link == branch.link:
                errors.append('has_identical_link')
            if branch_branch.authorname == authorname:
                authored_branch_count += 1
        
        if tree.branch_max > 0 and tree.branch_max <= authored_branch_count:
            errors.append('has_branches')
        
        if len(errors) == 0:
            branch.revision = 0
            branch.parent_branch = parent_key
            branch.parent_branch_authorname = parent_branch.authorname
            branch.put()
            self.create_branch_version(branch)
            
            parent_branch.append_child(branch)
            
            notification = Notification()
            notification.from_username = branch.authorname
            if branch.authorname != parent_branch.authorname:
                notification.to_username = parent_branch.authorname
            notification.notification_type = 'new_branch'
            notification.branch = branch.key
            notification.branch_link = branch.link
            notification.tree_name = branch.tree_name
            notification.put()
            
            return True, branch
        else:
            return False, errors
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:81,代码来源:controllers.py

示例7: save_tree

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
    def save_tree(self,tree_dict):
        
        try:
            tree_dict = self.merged_tree(tree_dict)
        except:
            return False, ['invalid_parameters']
            
        #tree_name,moderatorname,conventions,root_branch_link,root_branch_content
        
        if tree_dict['moderatorname'] is None:
            return False, ['unauthenticated','no_moderator']
        
        if tree_dict['tree_name'] is None:
            return False, ['empty_name']
        
        author_info = UserInfo.get_by_username(tree_dict['moderatorname'])
        
        if author_info is None:
            return False, ['unauthenticated','moderator_not_found']
        
        if not self.is_user_info_current(author_info):
            return False, ['unauthenticated','moderator_not_current']
        
        if author_info.username is None:
            return False, ['invalid_user']
        
        errors = []
        
        if tree_dict['content_max'] < 16:
            errors.append('min_content_max')
            
        if tree_dict['link_max'] < 16:
            errors.append('min_link_max')
            
        if len(tree_dict['link_prompt']) > tree_dict['link_max']:
            errors.append('link_prompt_too_large')
            
        if len(tree_dict['content_prompt']) > tree_dict['content_max']:
            errors.append('content_prompt_too_large')
        
        tree_key = Tree.create_key(tree_dict['tree_name'])
        
        empty_name = tree_dict['tree_name'] is None or len(tree_dict['tree_name']) == 0
        
        if empty_name:
            errors.append('empty_name')
        else:
            match = re.search(r'^[\d\w_\-]+$', tree_dict['tree_name'])
            isvalid = match and 4 <= len(tree_dict['tree_name']) and len(tree_dict['tree_name']) <= 20;
            if not isvalid:
                errors.append('invalid_name')
        
        branch = Branch(id=tree_dict['tree_name'])
        branch.authorname = tree_dict['moderatorname']
        branch.link = tree_dict['root_branch_link']
        branch.content = tree_dict['root_branch_content']
        branch.tree_name = tree_dict['tree_name']
        
        if branch.link == None or len(branch.link) == 0:
            errors.append('empty_root_branch_link')
        
        if branch.content == None or len(branch.content) == 0:
            errors.append('empty_root_branch_content')
        
#let the user complete the other validation before trying to create the tree        
        if len(errors) != 0:
            return False, errors
        
        
        tree = tree_key.get();
        
        if tree:
            errors.append('tree_exists')
        
        if len(errors) == 0:
            #if two users enter identical information at the same time, then
            #whoever gets it second is the winner
            tree = Tree(id=tree_dict['tree_name'].lower(),name=tree_dict['tree_name'])
            tree.moderatorname = tree_dict['moderatorname']
            tree.conventions = tree_dict['conventions']
            
            tree.link_moderator_only = tree_dict['link_moderator_only']
            tree.link_max = tree_dict['link_max']
            tree.link_prompt = tree_dict['link_prompt']
            
            tree.content_moderator_only = tree_dict['content_moderator_only']
            tree.content_max = tree_dict['content_max']
            tree.content_prompt = tree_dict['content_prompt']
            
            tree.single_thread = tree_dict['single_thread']
            
            tree.branch_max = tree_dict['branch_max']
            
            branch.put()
            tree.put()
        
            notification = Notification()
            notification.from_username = tree.moderatorname
            #only set the to_username when a different user is performing the action
            notification.notification_type = 'new_tree'
#.........这里部分代码省略.........
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:103,代码来源:controllers.py

示例8: update_branch

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import put [as 别名]
    def update_branch(self,authorname,urlsafe_key,link,content):
        
        userinfo = UserInfo.get_by_username(authorname)
        
        if userinfo is None or not self.is_user_info_current(userinfo):
            return False, [ 'unauthenticated' ]
        
        branch = ndb.Key(urlsafe=urlsafe_key).get()
        tree = Tree.get_by_name(branch.tree_name)
        
        if tree is None:
            return False, [ 'tree_not_found' ]
        
        if branch.authorname != authorname and tree.moderatorname != authorname:
            return False, [ 'not_author' ]
        
        if tree.moderatorname == authorname or not tree.link_moderator_only:
            branch.link = link
        if tree.moderatorname == authorname or not tree.content_moderator_only:
            branch.content = content
                
        errors = self.validate_branch(tree, branch,authorname)
        
#Comment on thread safety:
#Branch creation will be a VERY frequent operation. Multiple branchs with identical links
#Isn't an application error, just an annoyance for the user. So we allow this to occur
#without a lock in place
        parent_branch = None

        if branch.parent_branch is not None:
            parent_branch = branch.parent_branch.get();
                    
            branchs = parent_branch.children()
            
            for branch_branch in branchs:
                if branch_branch.link == branch.link and branch.key != branch_branch.key:
                    errors.append('has_identical_link')
            
        if len(errors) == 0:
            if branch.revision is None:
                branch.revision = 1
            else:
                branch.revision = branch.revision + 1
                
            branch.put()
            self.create_branch_version(branch)
            if parent_branch is not None:
                parent_branch.update_child(branch)
            
            notification = Notification()
            notification.from_username = authorname
            #only set the to_username when a different user is performing the action
            if branch.authorname != authorname:
                notification.to_username = branch.authorname
            notification.notification_type = 'edit_branch'
            notification.branch = branch.key
            notification.branch_link = branch.link
            notification.tree_name = branch.tree_name
            notification.put()
                
            return True, branch
        else:
            return False, errors
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:65,代码来源:controllers.py


注:本文中的models.Notification.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。