コード例 #1
0
ファイル: importer.py プロジェクト: lukin0110/website-sintjan
def importNews(out):
    #file = open('import/nieuws.yml')
    #map = yaml.load(file)
    #file.close()

    csvReader = csv.reader(open('import/nieuws.csv'), delimiter=';')
    
    for entry in csvReader:
        out.write(",".join(entry) + "\n")
        
        news = News()
        colnum = 0
        
        for col in entry:
            #out.write(str(colnum) + "-" + col + ",")
            
            if colnum == 1:
                news.name = unicode(col, errors='ignore')
            elif colnum == 2:
                news.email = unicode(col, errors='ignore')
            elif colnum == 3:
                news.title = unicode(col, errors='ignore')
            elif colnum == 4:
                news.date = newsParseDate(out, col)
            elif colnum == 5:
                news.msg = unicode(col, errors='ignore')
            elif colnum == 8:
                news.visible = util.parseBool(col)
            
            colnum += 1
            
        # store it!!!
        if news.msg != "" and news.msg != None and news.name != "" and news.name != None and news.title != "" and news.title != None:
            news.put()
コード例 #2
0
    def getNewsItem(self, request):
        # POST id
        id = sintjan.business.util.parseint(request.get("id"), 0)

        # GET id
        if id < 1:
            id = sintjan.business.util.parseint(request.get("newsid"), 0)

        if id > 0:
            return News.get_by_id(id)
        else:
            user = users.get_current_user()
            news = News()
            news.name = user.nickname()
            news.email = user.email()
            news.title = ""
            news.msg = ""
            news.visible = True
            return news