def storynew(): if 'username' in session: user = session['username'] form = StoryForm() if form.validate_on_submit(): uid = dbsession.query(User.id).filter_by(name=user).first() newstory = Story(form.title.data) newstory.text = markdown.markdown(form.body.data) newstory.uid = uid[0] newstory.adult = form.adult.data tagslist = form.tags.data tagslist = tagslist.split(',') for tagitem in tagslist: tagitem = tagitem.strip() tagitem = tagitem.lower() tag = dbsession.query(Tag).filter_by(tagname=tagitem).first() if tag is None: tag = Tag(tagitem) newstory.tags.append(tag) dbsession.add(newstory) dbsession.commit() return redirect("~"+user) return render_template("storynew.html", form=form) else: return render_template("storynew.html")
if __name__ == '__main__': password = '******' from db import User, Story, addDefault, refresh_db, session as dbsession import random import loremipsum for adduser in range(1,1000): username = "******" % (adduser) user = User(username,'',password) user.species = 'Automatic' user.bio = 'Automatic bio' user.email = '*****@*****.**' user.minorflag = True user.accepttos =True dbsession.add(user) dbsession.commit() for addstories in range(1,20000): newstory = Story(loremipsum.generate_sentence()[2]) newstory.text = loremipsum.generate_paragraph()[2] newstory.adult = True newstory.uid = random.randrange(1000)+1 dbsession.add(newstory) dbsession.commit()