• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python soup.get_soup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中souper.soup.get_soup函数的典型用法代码示例。如果您正苦于以下问题:Python get_soup函数的具体用法?Python get_soup怎么用?Python get_soup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _data

    def _data(self):
        # facultiesList = faculties(None).by_value.keys()
        news = []
        news_filtered = []
        context = aq_inner(self.context)
        portal_state = getMultiAdapter((context, self.request), name='plone_portal_state')
        path = portal_state.navigation_root_path()
        limit = self.data.count
        state = self.data.state

        portal = getSite()
        current_user = api.user.get_current()
        userid = current_user.id

        soup_tags = get_soup('user_subscribed_tags', portal)
        tags_soup = [r for r in soup_tags.query(Eq('id', userid))]
        if tags_soup:
            tags = tags_soup[0].attrs['tags']
            news += self.get_news(context, state, path, limit, tags)
            for newObject in news:
                if newObject not in news_filtered and newObject['subject'] is not ():
                    news_filtered.append(newObject)

            newsSorted = sorted(news_filtered, key=lambda new: new['date'], reverse=True)
            return newsSorted
        else:
            return []
开发者ID:UPCnet,项目名称:ulearn.udemo,代码行数:27,代码来源:subscribednews.py


示例2: get_safe_member_by_id

def get_safe_member_by_id(username):
    """Gets user info from the repoze.catalog based user properties catalog.
       This is a safe implementation for getMemberById portal_membership to
       avoid useless searches to the LDAP server. It gets only exact matches (as
       the original does) and returns a dict. It DOES NOT return a Member
       object.
    """
    portal = api.portal.get()
    soup = get_soup('user_properties', portal)
    username = username.lower()
    records = [r for r in soup.query(Eq('id', username))]
    if records:
        properties = {}
        for attr in records[0].attrs:
            if records[0].attrs.get(attr, False):
                properties[attr] = records[0].attrs[attr]

        # Make sure that the key 'fullname' is returned anyway for it's used in
        # the wild without guards
        if 'fullname' not in properties:
            properties['fullname'] = ''

        return properties
    else:
        # No such member: removed?  We return something useful anyway.
        return {'username': username, 'description': '', 'language': '',
                'home_page': '', 'name_or_id': username, 'location': '',
                'fullname': ''}
开发者ID:UPCnet,项目名称:genweb.core,代码行数:28,代码来源:utils.py


示例3: test_group_sync

    def test_group_sync(self):
        sync_view = getMultiAdapter((self.portal, self.request), name='syncldapgroups')
        sync_view.render()

        soup = get_soup('ldap_groups', self.portal)

        self.assertTrue(len(soup.data.keys()) > 0)
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:7,代码来源:test_ldap.py


示例4: render

    def render(self):
        portal = getSite()
        current_user = api.user.get_current()
        userid = current_user.id
        tag = self.request.form['tag']
        soup_tags = get_soup('user_subscribed_tags', portal)
        exist = [r for r in soup_tags.query(Eq('id', userid))]

        if not exist:
            record = Record()
            record.attrs['id'] = userid
            record.attrs['tags'] = [tag]
            soup_tags.add(record)
        else:
            subscribed = [True for utag in exist[0].attrs['tags'] if utag == tag]
            if subscribed:
                exist[0].attrs['tags'].remove(tag)
            else:
                exist[0].attrs['tags'].append(tag)
        soup_tags.reindex()

        if IPloneSiteRoot.providedBy(self.context):
            self.request.response.redirect(self.context.absolute_url() + '/alltags')
        else:
            self.request.response.redirect(self.context.absolute_url())
开发者ID:UPCnet,项目名称:genweb.core,代码行数:25,代码来源:views.py


示例5: __call__

    def __call__(self):
        soup = get_soup(self.soup_name, self.context)
        aaData = list()
        length, lazydata = self.query(soup)
        columns = self.columns
        colnames = [_['id'] for _ in columns]
        # todo json response header einbaun

        def record2list(record):
            result = list()
            for colname in colnames:
                coldef = self.column_def(colname)
                renderer = coldef.get('renderer')
                if renderer:
                    value = renderer(colname, record)
                else:
                    value = record.attrs.get(colname, '')
                result.append(value)
            return result
        for lazyrecord in self.slice(lazydata):
            aaData.append(record2list(lazyrecord()))
        data = {
            "sEcho": int(self.request.form['sEcho']),
            "iTotalRecords": soup.storage.length.value,
            "iTotalDisplayRecords": length,
            "aaData": aaData,
        }
        self.request.response.setHeader("Content-type", "application/json")
        return json.dumps(data)
开发者ID:espenmn,项目名称:bda.plone.orders,代码行数:29,代码来源:views.py


示例6: initialize

 def initialize(self):
     """ setup the storage
     """
     alsoProvides(self.root, ISoupRoot)
     locator = StorageLocator(self.root)
     locator.storage(self.id)
     self._soup = get_soup(self.id, self.root)
开发者ID:collective,项目名称:rapido.souper,代码行数:7,代码来源:soup.py


示例7: do_transition_for_booking

def do_transition_for_booking(booking, transition, order_data, event=False):
    """do any transition for a given single booking

    this mixes main state and salaried!
    """
    # XXX: currently we need to delete attribute before setting to a new
    #      value in order to persist change. fix in appropriate place.
    if transition == interfaces.SALARIED_TRANSITION_SALARIED:
        del booking.attrs['salaried']
        booking.attrs['salaried'] = interfaces.SALARIED_YES
    elif transition == interfaces.SALARIED_TRANSITION_OUTSTANDING:
        del booking.attrs['salaried']
        booking.attrs['salaried'] = interfaces.SALARIED_NO
    elif transition == interfaces.STATE_TRANSITION_RENEW:
        del booking.attrs['state']
        booking.attrs['state'] = interfaces.STATE_NEW
        # fix stock item available
        order_data.decrease_stock([booking])
    elif transition == interfaces.STATE_TRANSITION_PROCESS:
        del booking.attrs['state']
        booking.attrs['state'] = interfaces.STATE_PROCESSING
    elif transition == interfaces.STATE_TRANSITION_FINISH:
        del booking.attrs['state']
        booking.attrs['state'] = interfaces.STATE_FINISHED
    elif transition == interfaces.STATE_TRANSITION_CANCEL:
        del booking.attrs['state']
        booking.attrs['state'] = interfaces.STATE_CANCELLED
        # fix stock item available
        order_data.increase_stock([booking])
    else:
        raise ValueError(u"invalid transition: %s" % transition)
    bookings_soup = get_soup('bda_plone_orders_bookings', order_data.context)
    bookings_soup.reindex(records=[booking])
开发者ID:Martronic-SA,项目名称:bda.plone.orders,代码行数:33,代码来源:transitions.py


示例8: rebuild_soup

 def rebuild_soup(self):
     sid = self.request.form.get("id")
     if not sid:
         return self.redirect_base("No soup id given")
     soup = get_soup(sid, self.context)
     soup.rebuild()
     msg = "%s rebuilt." % sid
     return self.redirect_base(msg)
开发者ID:kombinat,项目名称:souper.plone,代码行数:8,代码来源:views.py


示例9: clear_soup

 def clear_soup(self):
     sid = self.request.form.get('id')
     if not sid:
         return self.redirect_base('No soup id given!') 
     soup = get_soup(sid, self.context)
     soup.clear()
     msg = '%s cleared.' % sid
     return self.redirect_base(msg)
开发者ID:bluedynamics,项目名称:souper.plone,代码行数:8,代码来源:views.py


示例10: rebuild_length

 def rebuild_length(self):
     sid = self.request.form.get("id")
     if not sid:
         return self.redirect_base("No soup id given")
     soup = get_soup(sid, self.context)
     newlen = len(soup.storage.data)
     soup.storage.length.set(newlen)
     transaction.commit()
     return self.redirect_base(u"Length of storage %s is %s" % (sid, newlen))
开发者ID:kombinat,项目名称:souper.plone,代码行数:9,代码来源:views.py


示例11: getMyTags

    def getMyTags(self):
        portal = getSite()
        current_user = api.user.get_current()
        userid = current_user.id

        soup_tags = get_soup('user_subscribed_tags', portal)
        tags_soup = [r for r in soup_tags.query(Eq('id', userid))]

        return tags_soup[0].attrs['tags'] if tags_soup else []
开发者ID:UPCnet,项目名称:ulearn.theme,代码行数:9,代码来源:mytags.py


示例12: remove_user_from_catalog

def remove_user_from_catalog(username):
    portal = api.portal.get()
    soup = get_soup('user_properties', portal)
    exists = [r for r in soup.query(Eq('id', username))]
    if exists:
        user_record = exists[0]
        del soup[user_record]

    if IAMULEARN:
        extender_name = api.portal.get_registry_record('genweb.controlpanel.core.IGenwebCoreControlPanelSettings.user_properties_extender')
        # Make sure that, in fact we have such a extender in place
        if extender_name in [a[0] for a in getUtilitiesFor(ICatalogFactory)]:
            extended_soup = get_soup(extender_name, portal)
            exist = []
            exist = [r for r in extended_soup.query(Eq('id', username))]
            if exist:
                extended_user_record = exist[0]
                del extended_soup[extended_user_record]
开发者ID:UPCnet,项目名称:genweb.core,代码行数:18,代码来源:utils.py


示例13: test_delete_community

    def test_delete_community(self):
        login(self.portal, 'ulearn.testuser1')
        community = self.create_test_community()
        gwuuid = IGWUUID(community).get()
        api.content.delete(obj=community)

        soup = get_soup('communities_acl', self.portal)
        records = [r for r in soup.query(Eq('gwuuid', gwuuid))]

        self.assertFalse(records)
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:10,代码来源:test_communities.py


示例14: get_editacl

    def get_editacl(self, community):
        # The user has role Manager

        gwuuid = community.gwuuid
        portal = api.portal.get()
        soup = get_soup('communities_acl', portal)

        records = [r for r in soup.query(Eq('gwuuid', gwuuid))]
        editacl = dict(users=records[0].attrs['acl'].get('users', ''),
                       groups=records[0].attrs['acl'].get('groups', ''))
        return editacl
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:11,代码来源:communities.py


示例15: render

    def render(self):
        query = self.request.form.get('q', '')
        if query:
            portal = api.portal.get()
            soup = get_soup('ldap_groups', portal)
            normalized_query = query.replace('.', ' ') + '*'

            results = [dict(id=r.attrs.get('id')) for r in soup.query(Eq('searchable_id', normalized_query))]
            return json.dumps(dict(results=results))
        else:
            return json.dumps(dict(id='No results yet.'))
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:11,代码来源:omega13.py


示例16: test_community_creation_closed

    def test_community_creation_closed(self):
        nom = u'community-test'
        description = 'Blabla'
        image = None
        community_type = 'Closed'
        twitter_hashtag = 'helou'

        login(self.portal, 'ulearn.testuser1')

        self.portal.invokeFactory('ulearn.community', 'community-test',
                                 title=nom,
                                 description=description,
                                 image=image,
                                 community_type=community_type,
                                 twitter_hashtag=twitter_hashtag)

        community = self.portal['community-test']

        logout()

        # Test for the acl registry
        soup = get_soup('communities_acl', self.portal)
        # By the gwuuid
        records = [r for r in soup.query(Eq('gwuuid', IGWUUID(community).get()))]
        self.assertEqual(len(records), 1)
        self.assertEqual(records[0].attrs.get('gwuuid', ''), IGWUUID(community).get())
        self.assertEqual(records[0].attrs.get('path', ''), '/'.join(community.getPhysicalPath()))
        self.assertEqual(records[0].attrs.get('hash', ''), sha1(community.absolute_url()).hexdigest())
        self.assertEqual(records[0].attrs.get('acl', '').get('users', [])[0]['role'], u'owner')
        self.assertEqual(records[0].attrs.get('acl', '').get('users', [])[0]['id'], u'ulearn.testuser1')

        # Test for internal objects
        self.assertEqual(community.objectIds(), ['documents', 'events', 'discussion'])

        # Test for photo folder
        self.assertEqual(community['documents'].objectIds(), ['media', ])

        # Test for subscribed users
        self.assertTrue(u'ulearn.testuser1' in self.get_max_subscribed_users(community))

        # Test for Plone permissions/local roles
        self.assertTrue('Reader' not in community.get_local_roles_for_userid(userid='AuthenticatedUsers'))
        self.assertTrue('Editor' in community.get_local_roles_for_userid(userid='ulearn.testuser1'))
        self.assertTrue('Owner' in community.get_local_roles_for_userid(userid='ulearn.testuser1'))
        self.assertTrue('Reader' in community.get_local_roles_for_userid(userid='ulearn.testuser1'))

        # Test the initial MAX properties
        max_community_info = self.get_max_context_info(community)
        self.assertEqual('helou', max_community_info.get(u'twitterHashtag', ''))
        self.assertFalse(max_community_info.get(u'notifications', False))
        self.assertTrue(u'[COMMUNITY]' in max_community_info.get('tags', []))

        for key in CLOSED_PERMISSIONS:
            self.assertEqual(max_community_info['permissions'].get(key, ''), CLOSED_PERMISSIONS[key])
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:54,代码来源:test_communities.py


示例17: isTagFollowed

    def isTagFollowed(self, category):
        portal = getSite()
        current_user = api.user.get_current()
        userid = current_user.id

        soup_tags = get_soup('user_subscribed_tags', portal)
        tags_soup = [r for r in soup_tags.query(Eq('id', userid))]
        if tags_soup:
            tags = tags_soup[0].attrs['tags']
            return True if category in tags else False
        else:
            return False
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:12,代码来源:viewlets.py


示例18: is_community_manager

    def is_community_manager(self, community):
        # The user has role Manager
        if self.is_role_manager:
            return True

        gwuuid = community.gwuuid
        portal = api.portal.get()
        soup = get_soup('communities_acl', portal)

        records = [r for r in soup.query(Eq('gwuuid', gwuuid))]
        if records:
            return self.username in [a['id'] for a in records[0].attrs['acl']['users'] if a['role'] == u'owner']
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:12,代码来源:communities.py


示例19: get_data_acces_community_user

        def get_data_acces_community_user():
            """ Returns the date of user access to the community.
            """
            user_community = user + '_' + community.id
            portal = api.portal.get()

            soup_access = get_soup('user_community_access', portal)
            exist = [r for r in soup_access.query(Eq('user_community', user_community))]
            if not exist:
                return DateTime()
            else:
                return exist[0].attrs['data_access']
开发者ID:UPCnet,项目名称:ulearn.theme,代码行数:12,代码来源:communities.py


示例20: render

    def render(self):
        portal = api.portal.get()
        soup = get_soup('uuid_preserver', portal)
        pc = api.portal.get_tool('portal_catalog')
        results = pc.searchResults()

        for result in results:
            record = Record()
            record.attrs['uuid'] = result.UID
            record.attrs['path'] = result.getPath()
            soup.add(record)
            logger.warning('Preserving {}: {}'.format(result.getPath(), result.UID))
开发者ID:UPCnet,项目名称:genweb.core,代码行数:12,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python soupselect.select函数代码示例发布时间:2022-05-27
下一篇:
Python soundfile.write函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap