Example #1
0
 def load_profile(base_dir, atompub, profile_name):
     store = atompub.service.store
     info = store.get_content_info(profile_name, 'profile.xml')
     try:
         profile = store.fetch_content(info)
     except UnknownResource:
         print "Unknown profile: %s" % profile_name
     else:
         p = Profile.from_profile_element(E.load(profile).xml_root)
         return UserProfile(profile_name, p)
Example #2
0
def _profile_process_request_body():
    if cherrypy.request.method in ['POST', 'PUT']:
        cherrypy.request.process_request_body = False
        length = cherrypy.request.headers.get('content-length', 0)
        if not length:
            cherrypy.request.params['profile'] = None
            return

        cherrypy.request.params['profile'] = None
        content = cherrypy.request.rfile.read(int(length))
        profile = Profile.from_profile_element(E.load(content).xml_root)
        field = profile.x.field_by_var('nickname')
        if field and field.values:
            profile_name = field.values[0]
            cherrypy.request.params['profile'] = UserProfile(profile_name, profile)
Example #3
0
 def xml(self):
     return Profile.to_profile_element(self.profile).xml()