Ejemplo n.º 1
0
 def render(self, request):
     
     def _cb(result):
         request.write('<html><body>')
         request.write("User " + result.first_name + " " + result.last_name + " ( " + result.name + " ) added.")
         user = IdentityResource.create_new_resource()
         request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n', "/add_user"))
         request.write(give_links())
         request.write('</body></html>')
         request.finish()
         
     print str(request)
         
     if (len(request.args) > 0):
         new_user = coi_resource_descriptions.IdentityResource.create_new_resource()
         for field_name in new_user.attributes:
             if (field_name not in ("RegistryBranch","RegistryIdentity","RegistryCommit", "lifecycle")):
                 if (len(request.args[field_name]) > 0):
                     setattr(new_user, field_name, request.args[field_name][0])
                     
         d = self.client.register_user(new_user)
         d.addCallback(_cb)
     else:
         user = IdentityResource.create_new_resource()
         return wrap_html(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n', "/add_user") + give_links())
   
     return server.NOT_DONE_YET
Ejemplo n.º 2
0
        def show_array_cb(result):
            request.write('<html><body>')
            if ((len(result) == 0) or (result == None)):
                request.write("no matches (2)" + str(result) + "<br\>")
                user = IdentityResource.create_new_resource()
                request.write(
                    wrap_form(
                        give_form(user) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n'
                        + give_links(), "/find_user"))
            else:
                request.write("Found " + str(len(result)) + " matches<br/>\n")

                for i in result:
                    request.write('<dd/><a href="/find_user?ooi_id=' +
                                  i.RegistryIdentity + '&branch=' +
                                  i.RegistryBranch + '&commit=' +
                                  i.RegistryCommit + '">' + i.first_name +
                                  ' ' + i.last_name + '(' + i.name +
                                  ')</a><br/>\n')

                user = result[0]
                request.write("<hr>")
                request.write(
                    wrap_form(
                        give_form(user) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                        '/find_user'))
                request.write(give_links())
            request.write('</body></html>')
            request.finish()
Ejemplo n.º 3
0
 def _cb(result):
     request.write('<html><body>')
     request.write("Registry cleared.<br/>")
     user = IdentityResource.create_new_resource()
     request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n', "/erase_registry"))
     request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 4
0
 def _cb(result):
     request.write('<html><body>')
     request.write("User " + result.first_name + " " + result.last_name + " ( " + result.name + " ) added.")
     user = IdentityResource.create_new_resource()
     request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n', "/add_user"))
     request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 5
0
 def _cb(result):
     request.write('<html><body>')
     request.write("Registry cleared.<br/>")
     user = IdentityResource.create_new_resource()
     request.write(
         wrap_form(
             give_form(user) +
             '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n',
             "/erase_registry"))
     request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 6
0
 def _cb(result):
     request.write('<html><body>')
     request.write("User " + result.first_name + " " +
                   result.last_name + " ( " + result.name + " ) added.")
     user = IdentityResource.create_new_resource()
     request.write(
         wrap_form(
             give_form(user) +
             '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n',
             "/add_user"))
     request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 7
0
 def show_single_cb(result):
     request.write('<html><body>')
     if (result == None):
         request.write("no matches (1)<br\>")
         user = IdentityResource.create_new_resource()
         request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', "/find_user"))
         request.write(give_links())
     else:
         request.write("<hr>")
         request.write(wrap_form(give_form(result) +  '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', "/find_user"))
         request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 8
0
 def show_array_cb(result):
     request.write('<html><body>')
     if ((len(result) == 0) or (result == None)):
         request.write("no matches (2)" + str(result) + "<br\>")
         user = IdentityResource.create_new_resource()
         request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n' + give_links(), "/find_user"))
     else:
         request.write("Found " + str(len(result)) + " matches<br/>\n")
         
         for i in result:
             request.write('<dd/><a href="/find_user?ooi_id=' +  i.RegistryIdentity + '&branch=' + i.RegistryBranch + '&commit=' + i.RegistryCommit +'">' + i.first_name + ' ' + i.last_name + '(' + i.name + ')</a><br/>\n')
         
         user = result[0]
         request.write("<hr>")
         request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', '/find_user'))
         request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 9
0
 def show_single_cb(result):
     request.write('<html><body>')
     if (result == None):
         request.write("no matches (1)<br\>")
         user = IdentityResource.create_new_resource()
         request.write(
             wrap_form(
                 give_form(user) +
                 '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                 "/find_user"))
         request.write(give_links())
     else:
         request.write("<hr>")
         request.write(
             wrap_form(
                 give_form(result) +
                 '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                 "/find_user"))
         request.write(give_links())
     request.write('</body></html>')
     request.finish()
Ejemplo n.º 10
0
    def render(self, request):
        def _cb(result):
            request.write('<html><body>')
            request.write("User " + result.first_name + " " +
                          result.last_name + " ( " + result.name + " ) added.")
            user = IdentityResource.create_new_resource()
            request.write(
                wrap_form(
                    give_form(user) +
                    '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n',
                    "/add_user"))
            request.write(give_links())
            request.write('</body></html>')
            request.finish()

        print str(request)

        if (len(request.args) > 0):
            new_user = coi_resource_descriptions.IdentityResource.create_new_resource(
            )
            for field_name in new_user.attributes:
                if (field_name not in ("RegistryBranch", "RegistryIdentity",
                                       "RegistryCommit", "lifecycle")):
                    if (len(request.args[field_name]) > 0):
                        setattr(new_user, field_name,
                                request.args[field_name][0])

            d = self.client.register_user(new_user)
            d.addCallback(_cb)
        else:
            user = IdentityResource.create_new_resource()
            return wrap_html(
                wrap_form(
                    give_form(user) +
                    '<INPUT TYPE="submit" NAME="add" VALUE="Add User" /><p/>\n',
                    "/add_user") + give_links())

        return server.NOT_DONE_YET
Ejemplo n.º 11
0
    def render(self, request):
        def show_array_cb(result):
            request.write('<html><body>')
            if ((len(result) == 0) or (result == None)):
                request.write("no matches (2)" + str(result) + "<br\>")
                user = IdentityResource.create_new_resource()
                request.write(
                    wrap_form(
                        give_form(user) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n'
                        + give_links(), "/find_user"))
            else:
                request.write("Found " + str(len(result)) + " matches<br/>\n")

                for i in result:
                    request.write('<dd/><a href="/find_user?ooi_id=' +
                                  i.RegistryIdentity + '&branch=' +
                                  i.RegistryBranch + '&commit=' +
                                  i.RegistryCommit + '">' + i.first_name +
                                  ' ' + i.last_name + '(' + i.name +
                                  ')</a><br/>\n')

                user = result[0]
                request.write("<hr>")
                request.write(
                    wrap_form(
                        give_form(user) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                        '/find_user'))
                request.write(give_links())
            request.write('</body></html>')
            request.finish()

        def show_single_cb(result):
            request.write('<html><body>')
            if (result == None):
                request.write("no matches (1)<br\>")
                user = IdentityResource.create_new_resource()
                request.write(
                    wrap_form(
                        give_form(user) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                        "/find_user"))
                request.write(give_links())
            else:
                request.write("<hr>")
                request.write(
                    wrap_form(
                        give_form(result) +
                        '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n',
                        "/find_user"))
                request.write(give_links())
            request.write('</body></html>')
            request.finish()

        if ((len(request.args) > 0) and ('clear' not in request.args)):
            if ('update' in request.args.keys()):
                updated_user = coi_resource_descriptions.IdentityResource()
                for field_name in updated_user.attributes:
                    if (field_name not in ("lifecycle")):
                        if (len(request.args[field_name]) > 0):
                            setattr(updated_user, field_name,
                                    request.args[field_name][0])

                foo = dataobject.LCState(
                    state=request.args["lifecycle"][0].lower())
                updated_user.set_lifecyclestate(foo)

                d = self.client.update_user(updated_user)
                d.addCallback(show_single_cb)
            else:
                if ('ooi_id' in request.args.keys()):
                    user = IdentityResource.create_new_resource(
                        id=request.args['ooi_id'][0],
                        branch=request.args['branch'][0]
                    )  # was supposed to need commit=request.args['commit'][0], but doesnt want it. need to ask davif
                    d = self.client.get_user(user.reference(head=True))
                    d.addCallback(show_single_cb)
                else:
                    user_description = coi_resource_descriptions.IdentityResource(
                    )

                    attnames = []
                    print "************ " + str(request.args)
                    for field_name in user_description.attributes:
                        if (field_name
                                not in ("RegistryBranch", "RegistryIdentity",
                                        "RegistryCommit", "lifecycle")):
                            if (len(request.args[field_name]) > 0) and (len(
                                    request.args[field_name][0]) > 0):
                                setattr(user_description, field_name,
                                        request.args[field_name][0])
                                attnames.append(field_name)
                                print "************************* " + field_name + " = '" + request.args[
                                    field_name][0] + "'"
                    print "lifecycle = " + request.args["lifecycle"][0]
                    if (request.args["lifecycle"][0] != '*'):
                        attnames.append('lifecycle')
                        foo = dataobject.LCState(
                            state=request.args["lifecycle"][0].lower())
                        user_description.set_lifecyclestate(foo)
                    print "************ LOOKING FOR..... " + str(
                        user_description)
                    print "************ attnames ......... " + str(attnames)
                    d = self.client.find_users(
                        user_description, regex=True,
                        attnames=attnames)  #, ignore_defaults=True)
                    d.addCallback(show_array_cb)
            return server.NOT_DONE_YET
        else:
            user = IdentityResource.create_new_resource()
            return wrap_html(
                wrap_form(
                    give_form(user) +
                    '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n',
                    "/find_user") + give_links())
Ejemplo n.º 12
0
    def render(self, request):
        
        def show_array_cb(result):
            request.write('<html><body>')
            if ((len(result) == 0) or (result == None)):
                request.write("no matches (2)" + str(result) + "<br\>")
                user = IdentityResource.create_new_resource()
                request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n' + give_links(), "/find_user"))
            else:
                request.write("Found " + str(len(result)) + " matches<br/>\n")
                
                for i in result:
                    request.write('<dd/><a href="/find_user?ooi_id=' +  i.RegistryIdentity + '&branch=' + i.RegistryBranch + '&commit=' + i.RegistryCommit +'">' + i.first_name + ' ' + i.last_name + '(' + i.name + ')</a><br/>\n')
                
                user = result[0]
                request.write("<hr>")
                request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', '/find_user'))
                request.write(give_links())
            request.write('</body></html>')
            request.finish()
            
        def show_single_cb(result):
            request.write('<html><body>')
            if (result == None):
                request.write("no matches (1)<br\>")
                user = IdentityResource.create_new_resource()
                request.write(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', "/find_user"))
                request.write(give_links())
            else:
                request.write("<hr>")
                request.write(wrap_form(give_form(result) +  '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><INPUT TYPE="submit" NAME="update" VALUE="Update" /><input type="submit" name="clear" value="Clear"><p/>\n', "/find_user"))
                request.write(give_links())
            request.write('</body></html>')
            request.finish()
        
        
        
        
        if ((len(request.args) > 0) and ('clear' not in request.args)) :
            if ('update' in request.args.keys()):
                updated_user = coi_resource_descriptions.IdentityResource()
                for field_name in updated_user.attributes:
                    if (field_name not in ("lifecycle")):
                        if (len(request.args[field_name]) > 0):
                            setattr(updated_user, field_name, request.args[field_name][0])
                
                foo = dataobject.LCState(state=request.args["lifecycle"][0].lower())
                updated_user.set_lifecyclestate(foo)
                
                d = self.client.update_user(updated_user)
                d.addCallback(show_single_cb)
            else:    
                if ('ooi_id' in request.args.keys()):
                    user = IdentityResource.create_new_resource(id=request.args['ooi_id'][0],  branch=request.args['branch'][0]) # was supposed to need commit=request.args['commit'][0], but doesnt want it. need to ask davif
                    d = self.client.get_user(user.reference(head=True))
                    d.addCallback(show_single_cb)
                else:    
                    user_description = coi_resource_descriptions.IdentityResource()

                    attnames = []
                    print "************ " + str(request.args)
                    for field_name in user_description.attributes:
                        if (field_name not in ("RegistryBranch","RegistryIdentity","RegistryCommit", "lifecycle")):
                            if (len(request.args[field_name]) > 0) and (len(request.args[field_name][0]) > 0) :
                                setattr(user_description, field_name, request.args[field_name][0])
                                attnames.append(field_name)
                                print "************************* " + field_name + " = '" + request.args[field_name][0] + "'"
                    print "lifecycle = " + request.args["lifecycle"][0]
                    if (request.args["lifecycle"][0] != '*'):
                        attnames.append('lifecycle')
                        foo = dataobject.LCState(state=request.args["lifecycle"][0].lower())
                        user_description.set_lifecyclestate(foo)
                    print "************ LOOKING FOR..... " + str(user_description)
                    print "************ attnames ......... " + str(attnames)
                    d = self.client.find_users(user_description, regex=True, attnames=attnames) #, ignore_defaults=True) 
                    d.addCallback(show_array_cb)
            return server.NOT_DONE_YET
        else:
            user = IdentityResource.create_new_resource()
            return wrap_html(wrap_form(give_form(user) + '<INPUT TYPE="submit" NAME="search" VALUE="Search" /><p/>\n', "/find_user") + give_links())