def delete(self):
   if self.params.key:
     item = Role.get(self.params.key)
     if item:
       item.delete()
       self.status ='Role is deleted!'
     else:
       self.status='Role does not exist'
   else:
     self.status = 'Key was not Provided!'
   self.redirect(RoleController.get_url())
 def index(self):
   self.SetTemplate(templateName='Role_lst.html')
   results =None
   index = 0; count=1000
   try:
     index = int(self.params.index)
     count = int(self.params.count)
   except:
     pass
   result = {'RoleList': Role.all().fetch(limit=count, offset=index)}
   result.update(locals())
   self.respond(result)
 def edit(self):
   self.SetTemplate(templateName='Role_shw.html')
   if self.params.key:
     item = Role.get(self.params.key)
     if item:
       return {'op':'upd', 'RoleForm': RoleForm(instance=item)}
     else:
       self.status = 'Role does not exists'
       self.redirect(RoleController.get_url())
   else:
     self.status = 'Key not provided'
     return {'op':'ins' ,'RoleForm':RoleForm()}
 def save(self):
   instance = None
   if self.params.key:
     instance = Role.get(self.params.key)
   form=RoleForm(data=self.request.POST, instance=instance)
   if form.is_valid():
     result=form.save(commit=False)
     result.put()
     self.status = 'Role is saved'
     self.redirect(RoleController.get_url())
   else:
     self.SetTemplate(templateName = 'Role_shw.html')
     self.status = 'Form is not Valid'
     result = {'op':'upd', 'RoleForm': form}
     self.respond(result)