fixes in cms2 updates
diff --git a/erpnext/patches/may_2012/cms.py b/erpnext/patches/may_2012/cms.py
index 2711b1d..21ee381 100644
--- a/erpnext/patches/may_2012/cms.py
+++ b/erpnext/patches/may_2012/cms.py
@@ -4,7 +4,7 @@
 	from webnotes.model.code import get_obj
 	
 	# rewrite pages
-	get_obj('Website Settings').rewrite_pages()
+	get_obj('Website Settings').on_update()
 	
 	ss = get_obj('Style Settings')
 	ss.validate()
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
index d332802..18b10b6 100644
--- a/erpnext/website/web_cache.py
+++ b/erpnext/website/web_cache.py
@@ -167,6 +167,7 @@
 
 # cache management
 def search_cache(page_name):
+	if not page_name: return ()
 	import webnotes
 	return webnotes.conn.sql("""\
 		select html, doc_type, doc_name
@@ -193,13 +194,14 @@
 		* if page_name, doc_type and doc_name match, clear cache's copy
 		* else, raise exception that such a page already exists
 	"""
+	import webnotes
+
 	if not page_name:
 		webnotes.conn.sql("""update `tabWeb Cache` set html = ''""")
 		return
 	
 	result = search_cache(page_name)
-	
-	import webnotes
+
 	if not doc_type or (result and result[0][1] == doc_type and result[0][2] == doc_name):
 		webnotes.conn.set_value('Web Cache', page_name, 'html', '')
 	else: