Exemple #1
0
    def init_settings(self):
        init_values = { 
            'author' : ('CoderZh', u'博客作者名称'),
            'email' : ('*****@*****.**', u'博客作者名称'),
            'homepage' : ('http://blog.coderzh.com', u'作者主页'),
            'blogtitle' : ('Nancy Blog', u'博客标题'),
            'subtitle' : ('This is NancyBlog', u'子标题'),
            'theme' : ('default', u'博客皮肤'),
            'announce' : (u'欢迎使用NancyBlog', u'公告'),
            'admin_pages' : ('20', u'管理页面每页显示条数'),
            'blog_pages' : ('20', u'首页博客每页显示条数'),
            'comment_pages' : ('50', u'评论每页显示条数'),
            'tag_pages' : ('50', u'Tag每页显示条数'),
            'rss_coderzh' : ('http://feeds.feedburner.com/coderzh', u'rss地址'),
            'rss_coderzh_description' : (u'我的技术博客', u'rss描述'),
        }

        for name, value in init_values.items():
            setting = Settings(name=name, value=value[0], description=value[1])
            setting.put()
            BlogInfo.__shared_values[name] = value[0]
Exemple #2
0
    def create_setting(name, value, description):
		new_setting = Settings(name=name, value=value, description=description)
		new_setting.put()
		BlogInfo.__shared_values[name] = value
else:
    #   We need to check that we don't already have the data in the database as
    #   we don't want people to overwrite what we already have, yup, that's right
    #   once we've made a selection there's no going back unless we either blow
    #   away the database, or go in by hand and update it
    settingsRows = Settings.all()

    if settingsRows.count() == 0:
        newJSON = {
            'stories': {},
            'storiesList': [],
            'rejects': {},
            'rejectsList': []
        }

        #   Now put it into the database
        settingsRow = Settings()
        settingsRow.apiKey = args['apiKey']
        settingsRow.json = simplejson.dumps(newJSON)
        settingsRow.put()

        statusJSON = {'status': 'ok', 'results': newJSON}

    else:

        statusJSON = {'status': 'error', 'msg': 'already have a settingsJSON record'}

print 'Content-Type: application/json; charset=UTF-8'
print ''
print simplejson.dumps(statusJSON)