Ejemplo n.º 1
0
    def signup_complete(self, username):
        username = username.strip()

        valid = True
        if not username:
            valid = False
            
        if ProfileManager.has_profile(self.atompub, username):
            valid = False
            
        if not valid:
            tpl = self.tpl_lookup.get_template('newaccount_step2.mako')
            return tpl.render(username=username, error="Username already taken")

        profile = UserProfile(username)
        profile.fill(nickname=username)

        ProfileManager.store_profile(self.atompub, profile)
        cherrypy.session[MICROBLOG_SESSION_PROFILE] = profile
        if cherrypy.request.openid:
            oid = cherrypy.request.openid.info.identity_url
            cherrypy.session[oid] = profile

        w = self.atompub.add_workspace(profile.username)
        c = self.atompub.add_collection(w, profile.username)
        self.atompub.save_service()
        self.attach_serving_collection_application(c, profile,
                                                   d = cherrypy.request.dispatch)

        self.new_profiles_atompub_app.add_profile(profile)
        self.profiles_atompub_app.add_profile(profile)

        raise cherrypy.HTTPRedirect('/%s' % profile.username)