コード例 #1
0
ファイル: content.py プロジェクト: Aethaeryn/avenue
    def themes():
        '''Inserts the themes from themes.yml into the database.
        '''
        data = read_data('themes')

        subtheme = set(['text', 'background', 'post'])

        for entry in data:
            entry_type = entry.pop('type')

            if entry_type in subtheme:
                actions.append(table['theme_%s' % entry_type].insert().values(**entry))

            else:
                actions.append(table['theme'].insert().values(**entry))
コード例 #2
0
ファイル: content.py プロジェクト: Aethaeryn/avenue
def insert_data():
    '''Inserts static data from a data file into the database.
    '''
    def themes():
        '''Inserts the themes from themes.yml into the database.
        '''
        data = read_data('themes')

        subtheme = set(['text', 'background', 'post'])

        for entry in data:
            entry_type = entry.pop('type')

            if entry_type in subtheme:
                actions.append(table['theme_%s' % entry_type].insert().values(**entry))

            else:
                actions.append(table['theme'].insert().values(**entry))

    def forum_import(subsection):
        '''Inserts data from a forum subsection into the database.
        '''
        data = forum_data[subsection]

        for entry in data:
            actions.append(table[subsection].insert().values(**entry))

    actions = []
    forum_data = read_data('forum')

    themes()
    forum_import('nav')
    forum_import('tag')
    forum_import('url_redirect')

    for action in actions:
        connection.execute(action)