def import_nuke_phpbb_users(self):
        cursor = self.conn.cursor()

        sql_user = """SELECT username, user_email, user_avatar,
        user_website, user_from, user_sig, user_regdate FROM nuke_phpbb_users
        ORDER BY user_id"""
        # sql_user += " LIMIT 0,550"
        sql_user += ";"

        cursor.execute(sql_user)

        context = self.context
        cnt = 0
        while True:
            row = cursor.fetchone()
            if row is None:
                break
            if row[0].lower() == 'anonymous':
                continue
            try:
                sht.add_user(
                    context=context,
                    username=row[0],
                    password=row[0],
                    groups=[],
                    email=row[1],
                    fullname="",
                    data={'portrait': sht.load_file(globals(),
                          'setupdata/avatar/%s' % row[2]),
                          'home_page': row[3],
                          'location': row[4],
                          'description': row[5],
                          },
                    logger=logger)

                # TODO: portrait must be set differently.
                # see:
                """
(11:25:34 PM) pelado: can someone tell me what is the way to set a portrait to a plone user?
(11:25:46 PM) pelado: programatically
(11:36:06 PM) supton: pelado: IIRC for now this is not a property of the user, but stored in a BTree on portal_memberdata
(11:36:31 PM) pelado: supton: thanks
(11:40:51 PM) supton: pelado: you likely want to look at Products.PlonePAS.tools.membership.MembershipTool.changeMemberPortrait() -- this is the official way now until this eventually lands https://dev.plone.org/ticket/11323 
                """

            except ValueError:
                logger.error("Invalid Username: %s, %s" % (row[0], row[1]))

            except:
                logger.error("Invalid Format: %s, %s" % (row[0], row[1]))

            cnt = cnt + 1; print cnt

        cursor.close()
Beispiel #2
0
def setup_content(context):
    if sht.isNotThisProfile(context, 'plonetheme.zopeorg_setup_content.txt'):
        return

    site = context.getSite()
    sht.delete_items(site, ('front-page', 'news', 'events'), logger)
    sht.hide_and_retract(site['Members'], logger)

    content_structure = [
        {
            'type': 'Image',
            'title': 'old.zope.org Screenshot',
            'id': u'Screenshotold.zope.org.png',
            'opts': {
                'setExcludeFromNav': True
            },
            'data': {
                'image':
                sht.load_file(globals(),
                              'setupdata/Screenshotold.zope.org.png')
            }
        },
        {
            'type':
            'Folder',
            'title':
            u'Teasers',
            'opts': {
                'workflow': None,  # leave private
                'setLocallyAllowedTypes': [
                    'Teaser',
                ],
                'setImmediatelyAddableTypes': [
                    'Teaser',
                ],
                'setLayout': 'folder_summary_view'
            },
            'childs': [{
                'type': 'Teaser',
                'title': 'The World of Zope',
                'data': {
                    'image':
                    sht.load_file(globals(),
                                  'setupdata/teaser_world-of-zope.jpg'),
                    'importance':
                    u'3'
                }
            }]
        },
        {
            'type':
            'Collage',
            'title':
            u'Start',
            'id':
            'front-page',
            'data': {
                'show_title': False,
                'show_description': False,
            },
            'childs': [
                {
                    'type':
                    'CollageRow',
                    'title':
                    '',
                    'id':
                    '1',
                    'childs': [
                        # the following column should hold a teaser portlet
                        {
                            'type': 'CollageColumn',
                            'title': '',
                            'id': '1'
                        }
                    ]
                },
                {
                    'type':
                    'CollageRow',
                    'title':
                    '',
                    'id':
                    '2',
                    'childs': [
                        {
                            'type':
                            'CollageColumn',
                            'title':
                            '',
                            'id':
                            '1',
                            'childs': [{
                                'type': 'Document',
                                'title': u'Zope Community',
                                'id': u'front-community',
                                'opts': {
                                    'setExcludeFromNav': True
                                },
                                'data': {
                                    'text': START_ZOPE_COMMUNITY_TEXT
                                }
                            }]
                        },
                        {
                            'type':
                            'CollageColumn',
                            'title':
                            '',
                            'id':
                            '2',
                            'childs': [{
                                'type': 'Document',
                                'title': u'Zope Foundation',
                                'id': u'front-foundation',
                                'opts': {
                                    'setExcludeFromNav': True
                                },
                                'data': {
                                    'text': START_ZOPE_FOUNDATION_TEXT
                                }
                            }]
                        },
                        {
                            'type':
                            'CollageColumn',
                            'title':
                            '',
                            'id':
                            '3',
                            'childs': [{
                                'type': 'Document',
                                'title': u'Zope.org legacy',
                                'id': u'front-legacy',
                                'opts': {
                                    'setExcludeFromNav': True
                                },
                                'data': {
                                    'text': START_ZOPEORG_LEGACY_TEXT
                                }
                            }]
                        },
                    ]
                },
            ]
        },
        {
            'type': 'Document',
            'title': u'The World of Zope',
            'id': 'the-world-of-zope',
            'data': {
                'text': THE_WORLD_OF_ZOPE_TEXT
            }
        },
        {
            'type': 'Document',
            'title': u'News & Events',
            'id': u'news-events',
            'data': {
                'text': NEWS_EVENTS_TEXT
            }
        },
        {
            'type': 'Document',
            'title': u'Community',
            'id': u'community',
            'data': {
                'text': COMMUNITY_TEXT
            }
        },
        {
            'type': 'Document',
            'title': u'Resources',
            'id': u'resources',
            'data': {
                'text': RESOURCES_TEXT
            }
        },
        {
            'type': 'Document',
            'title': u'Zope Foundation',
            'id': u'foundation',
            'data': {
                'text': ZOPE_FOUNDATION_TEXT
            }
        },
        {
            'type': 'Document',
            'title': u'Legal',
            'id': u'legal',
            'opts': {
                'setExcludeFromNav': True
            },
            'data': {
                'description': u"""Zope.org Legal Notice.""",
                'text': LEGAL_TEXT
            }
        },
    ]
    sht.create_item_runner(site, content_structure, logger=logger)

    #the collage column will hold a portlet, so the view must be portlets-top
    from Products.Collage.interfaces import IDynamicViewManager
    manager = IDynamicViewManager(site['front-page']['1']['1'])
    manager.setLayout('portlets-top')

    #set the link reference in the teaser
    site['teasers']['the-world-of-zope'].setLink_internal(
        site['the-world-of-zope'])
    site['teasers']['the-world-of-zope'].reindexObject()
def setup_content(context):
    if sht.isNotThisProfile(context, 'plonetheme.zopeorg_setup_content.txt'):
        return

    site = context.getSite()
    sht.delete_items(site, ('front-page', 'news', 'events'), logger)
    sht.hide_and_retract(site['Members'], logger)

    content_structure = [

        {'type': 'Image', 'title': 'old.zope.org Screenshot',
         'id': u'Screenshotold.zope.org.png',
         'opts': {'setExcludeFromNav': True},
         'data': {'image': sht.load_file(globals(),
                               'setupdata/Screenshotold.zope.org.png')}},

        {'type': 'Folder', 'title': u'Teasers',
         'opts': {'workflow': None, # leave private
                  'setLocallyAllowedTypes': ['Teaser',],
                  'setImmediatelyAddableTypes':['Teaser',],
                  'setLayout': 'folder_summary_view'},
         'childs': [
             {'type': 'Teaser', 'title': 'The World of Zope',
              'data': {'image': sht.load_file(globals(),
                                'setupdata/teaser_world-of-zope.jpg'),
                       'importance': u'3'}}]},

        {'type': 'Collage', 'title': u'Start', 'id': 'front-page',
         'data': { 'show_title': False, 'show_description': False, },
         'childs': [
             {'type': 'CollageRow', 'title': '', 'id': '1',
              'childs': [
                  # the following column should hold a teaser portlet
                  {'type': 'CollageColumn', 'title': '', 'id': '1'}]},
             {'type': 'CollageRow', 'title': '', 'id': '2',
              'childs': [
                  {'type': 'CollageColumn', 'title': '', 'id': '1',
                   'childs': [
                        {'type': 'Document', 'title': u'Zope Community', 'id': u'front-community',
                         'opts': {'setExcludeFromNav': True},
                         'data': {'text': START_ZOPE_COMMUNITY_TEXT}}]},
                  {'type': 'CollageColumn', 'title': '', 'id': '2',
                   'childs': [
                        {'type': 'Document', 'title': u'Zope Foundation', 'id': u'front-foundation',
                         'opts': {'setExcludeFromNav': True},
                         'data': {'text': START_ZOPE_FOUNDATION_TEXT}}]},
                  {'type': 'CollageColumn', 'title': '', 'id': '3',
                   'childs': [
                        {'type': 'Document', 'title': u'Zope.org legacy', 'id': u'front-legacy',
                         'opts': {'setExcludeFromNav': True},
                         'data': {'text': START_ZOPEORG_LEGACY_TEXT}}]},
            ]},
        ]},

        {'type': 'Document', 'title': u'The World of Zope', 'id': 'the-world-of-zope',
         'data': {'text': THE_WORLD_OF_ZOPE_TEXT}},

        {'type': 'Document', 'title': u'News & Events', 'id': u'news-events',
         'data': {'text': NEWS_EVENTS_TEXT}},

        {'type': 'Document', 'title': u'Community', 'id': u'community',
         'data': {'text': COMMUNITY_TEXT}},

        {'type': 'Document', 'title': u'Resources', 'id': u'resources',
         'data': {'text': RESOURCES_TEXT}},

        {'type': 'Document', 'title': u'Zope Foundation', 'id': u'foundation',
         'data': {'text': ZOPE_FOUNDATION_TEXT}},

        {'type': 'Document', 'title': u'Legal', 'id': u'legal',
         'opts': {'setExcludeFromNav': True},
         'data': {'description':u"""Zope.org Legal Notice.""",
                  'text': LEGAL_TEXT}},
    ]
    sht.create_item_runner(site, content_structure, logger=logger)

    #the collage column will hold a portlet, so the view must be portlets-top
    from Products.Collage.interfaces import IDynamicViewManager
    manager = IDynamicViewManager(site['front-page']['1']['1'])
    manager.setLayout('portlets-top')

    #set the link reference in the teaser
    site['teasers']['the-world-of-zope'].setLink_internal(site['the-world-of-zope'])
    site['teasers']['the-world-of-zope'].reindexObject()