[minor] webnotes.conn.touch, signature invalidation

This commit is contained in:
Anand Doshi 2013-10-18 16:55:29 +05:30
parent fd84b62236
commit 7ee1165fe8
3 changed files with 12 additions and 4 deletions

View file

@ -121,6 +121,7 @@ class MappingMismatchError(ValidationError): pass
class InvalidStatusError(ValidationError): pass
class DoesNotExistError(ValidationError): pass
class MandatoryError(ValidationError): pass
class InvalidSignatureError(ValidationError): pass
def getTraceback():
import utils
@ -259,7 +260,6 @@ def whitelist(allow_guest=False, allow_roles=None):
class HashAuthenticatedCommand(object):
def __init__(self):
if hasattr(self, 'command'):
import inspect
@ -271,10 +271,13 @@ class HashAuthenticatedCommand(object):
if self.verify_signature(kwargs, signature):
return self.command(*args, **kwargs)
else:
raise Exception
self.signature_error()
def command():
def command(self):
raise NotImplementedError
def signature_error(self):
raise InvalidSignatureError
def get_signature(self, params, ignore_params=None):
import hmac

View file

@ -400,6 +400,11 @@ class Database:
doc.modified_by = webnotes.session["user"]
self.set_value(doc.doctype, doc.name, field, val, doc.modified, doc.modified_by)
doc.fields[field] = val
def touch(self, doctype, docname):
from webnotes.utils import now
webnotes.conn.sql("""update `tab{doctype}` set `modified`=%s
where name=%s""".format(doctype=doctype), (now(), docname))
def set_global(self, key, val, user='__global'):
self.set_default(key, val, user)

View file

@ -3,7 +3,7 @@
{% set title=webnotes.local.message_title %}
{% block content %}
<div class="panel panel-danger">
<div class="panel panel-{{ 'success' if webnotes.local.message_success else 'danger'}}">
<div class="panel-heading">
{{ title }}
</div>