Rewrote hooks for scheduler, notifications, boot, session, login, webpage webnotes/wnframework#351
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index d5b4c51..f49541b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -738,7 +738,7 @@
 					notify_errors(ref_invoice, ref_wrapper.doc.owner)
 					webnotes.conn.commit()
 
-				exception_list.append(webnotes.getTraceback())
+				exception_list.append(webnotes.get_traceback())
 			finally:
 				if commit:
 					webnotes.conn.begin()
diff --git a/erpnext/home/__init__.py b/erpnext/home/__init__.py
index 9667efd..36d7db5 100644
--- a/erpnext/home/__init__.py
+++ b/erpnext/home/__init__.py
@@ -29,8 +29,9 @@
 	'Sales Order':	  ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
 
 	# Purchase
-	'Supplier':		     ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
-	'Purchase Order':       ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s  %(grand_total_import)s', '#4169E1'],
+	'Material Request':	['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
+	'Supplier':		    ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
+	'Purchase Order':   ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s  %(grand_total_import)s', '#4169E1'],
 
 	# Stock
 	'Delivery Note':	['[%(status)s] To %(customer_name)s', '#4169E1'],
@@ -89,3 +90,9 @@
 		subject, color = feed_dict.get(doc.doctype, [None, None])
 		if subject:
 			make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
+
+def make_comment_feed(bean, method):
+	"""add comment to feed"""
+	doc = bean.doc
+	make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
+		'<i>"' + doc.comment + '"</i>', '#6B24B3')
\ No newline at end of file
diff --git a/erpnext/hooks.txt b/erpnext/hooks.txt
index 32cdcd2..69d2d8e 100644
--- a/erpnext/hooks.txt
+++ b/erpnext/hooks.txt
@@ -2,13 +2,57 @@
 
 app_include_js 			assets/js/erpnext.min.js
 app_include_css 		assets/css/erpnext.css
+web_include_js			assets/js/erpnext-web.min.js
+
 get_desktop_icons 		erpnext.manage.get_desktop_icons
 boot_session			erpnext.startup.boot.boot_session
 notification_config		erpnext.startup.notifications.get_notification_config
 
 dump_report_map			erpnext.startup.report_data_map.data_map
+update_website_context	erpnext.startup.webutils.update_website_context
+
+mail_footer				erpnext.startup.mail_footer
+
+on_session_creation		erpnext.startup.event_handlers.on_session_creation
+on_logout				erpnext.startup.event_handlers.on_logut
+
+# Bean Events
+# -----------
+
+bean_event				*:on_update:erpnext.home.update_feed
+bean_event				*:on_submit:erpnext.home.update_feed
+bean_event				Comment:on_update:erpnext.home.make_comment_feed
+
+bean_event				*:on_update:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
+bean_event				*:on_cancel:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
+bean_event				*:on_trash:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
+
+bean_event 				Stock Entry:on_update:erpnext.stock.doctype.material_request.material_request.update_completed_qty
 
 standard_queries		Warehouse:erpnext.stock.utils.get_warehouse_list
 standard_queries		Customer:erpnext.selling.utils.get_customer_list
 
-mail_footer				erpnext.startup.mail_footer
+# Schedulers
+# ----------
+
+#### Frequently
+
+scheduler_event			all:erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
+scheduler_event			all:erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
+scheduler_event			all:erpnext.selling.doctype.lead.get_leads.get_leads
+scheduler_event			all:webnotes.utils.email_lib.bulk.flush
+
+#### Daily
+
+scheduler_event			daily:webnotes.core.doctype.event.event.send_event_digest
+scheduler_event			daily:erpnext.setup.doctype.email_digest.email_digest.send
+scheduler_event			daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count
+scheduler_event			daily:webnotes.utils.email_lib.bulk.clear_outbox
+scheduler_event			daily:erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
+scheduler_event			daily:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
+scheduler_event			daily:erpnext.stock.utils.reorder_item
+scheduler_event			daily:webnotes.scheduler.report_errors
+
+#### Weekly
+
+scheduler_event			weekly:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
index 4f1069a..53b88f7 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
@@ -138,7 +138,7 @@
 			error = True
 			ret.append('Error for row (#%d) %s : %s' % (row_idx, 
 				len(row)>1 and row[1] or "", cstr(e)))
-			webnotes.errprint(webnotes.getTraceback())
+			webnotes.errprint(webnotes.get_traceback())
 
 	if error:
 		webnotes.conn.rollback()		
diff --git a/erpnext/patches/april_2013/p05_update_file_data.py b/erpnext/patches/april_2013/p05_update_file_data.py
index b41019d..1403dff 100644
--- a/erpnext/patches/april_2013/p05_update_file_data.py
+++ b/erpnext/patches/april_2013/p05_update_file_data.py
@@ -35,7 +35,7 @@
 			webnotes.conn.commit()
 			webnotes.conn.sql("""alter table `tab%s` drop column `file_list`""" % doctype)
 		except Exception, e:
-			print webnotes.getTraceback()
+			print webnotes.get_traceback()
 			if (e.args and e.args[0]!=1054) or not e.args:
 				raise
 
diff --git a/erpnext/portal/templates/includes/cart.js b/erpnext/portal/templates/includes/cart.js
index 0765c60..c521b6c 100644
--- a/erpnext/portal/templates/includes/cart.js
+++ b/erpnext/portal/templates/includes/cart.js
@@ -127,7 +127,7 @@
 	render_item_row: function($cart_items, doc) {
 		doc.image_html = doc.website_image ?
 			'<div style="height: 120px; overflow: hidden;"><img src="' + doc.website_image + '" /></div>' :
-			'{% include "app/stock/doctype/item/templates/includes/product_missing_image.html" %}';
+			'{% include "stock/doctype/item/templates/includes/product_missing_image.html" %}';
 			
 		if(doc.description === doc.item_name) doc.description = "";
 		
diff --git a/erpnext/setup/doctype/backup_manager/backup_dropbox.py b/erpnext/setup/doctype/backup_manager/backup_dropbox.py
index bbd33b5..8659b5a 100644
--- a/erpnext/setup/doctype/backup_manager/backup_dropbox.py
+++ b/erpnext/setup/doctype/backup_manager/backup_dropbox.py
@@ -114,7 +114,7 @@
 				upload_file_to_dropbox(filepath, "/files", dropbox_client)
 			except Exception:
 				did_not_upload.append(filename)
-				error_log.append(webnotes.getTraceback())
+				error_log.append(webnotes.get_traceback())
 	
 	webnotes.connect()
 	return did_not_upload, list(set(error_log))
diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.py b/erpnext/setup/doctype/backup_manager/backup_manager.py
index 332d983..339038f 100644
--- a/erpnext/setup/doctype/backup_manager/backup_manager.py
+++ b/erpnext/setup/doctype/backup_manager/backup_manager.py
@@ -37,7 +37,7 @@
 		send_email(True, "Dropbox")
 	except Exception:
 		file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
-		error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
+		error_message = ("\n".join(file_and_error) + "\n" + webnotes.get_traceback())
 		webnotes.errprint(error_message)
 		
 		if not webnotes.conn:
@@ -57,7 +57,7 @@
 		send_email(True, "Google Drive")
 	except Exception:
 		file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
-		error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback())
+		error_message = ("\n".join(file_and_error) + "\n" + webnotes.get_traceback())
 		webnotes.errprint(error_message)
 		send_email(False, "Google Drive", error_message)
 
diff --git a/erpnext/startup/bean_handlers.py b/erpnext/startup/bean_handlers.py
deleted file mode 100644
index a427ffc..0000000
--- a/erpnext/startup/bean_handlers.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from erpnext.home import update_feed
-from webnotes.core.doctype.notification_count.notification_count import clear_doctype_notifications
-from erpnext.stock.doctype.material_request.material_request import update_completed_qty
-
-def on_method(bean, method):
-	if method in ("on_update", "on_submit"):
-		update_feed(bean.controller, method)
-	
-	if method in ("on_update", "on_cancel", "on_trash"):
-		clear_doctype_notifications(bean.controller, method)
-
-	if bean.doc.doctype=="Stock Entry" and method in ("on_submit", "on_cancel"):
-		update_completed_qty(bean.controller, method)
\ No newline at end of file
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index cd565c7..e28e5ba 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -47,7 +47,6 @@
 		where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
 
 def get_letter_heads():
-	"""load letter heads with startup"""
 	import webnotes
 	ret = webnotes.conn.sql("""select name, content from `tabLetter Head` 
 		where ifnull(disabled,0)=0""")
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 7d51872..262771d 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -5,9 +5,7 @@
 from __future__ import unicode_literals
 import webnotes
 
-from erpnext.home import make_feed
-
-def on_login_post_session(login_manager):
+def on_session_creation(login_manager):
 	"""
 		called after login
 		update login_from and delete parallel sessions
@@ -63,10 +61,4 @@
 	webnotes.msgprint(msg)
 	
 	webnotes.response['message'] = 'Account Expired'
-	raise webnotes.AuthenticationError
-
-def comment_added(doc):
-	"""add comment to feed"""
-	make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
-		'<i>"' + doc.comment + '"</i>', '#6B24B3')
-	
+	raise webnotes.AuthenticationError	
diff --git a/erpnext/startup/schedule_handlers.py b/erpnext/startup/schedule_handlers.py
deleted file mode 100644
index e1b3bb4..0000000
--- a/erpnext/startup/schedule_handlers.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-"""will be called by scheduler"""
-
-import webnotes
-from webnotes.utils import scheduler
-	
-def execute_all():
-	"""
-		* get support email
-		* recurring invoice
-	"""
-	# pull emails
-	from erpnext.support.doctype.support_ticket.get_support_mails import get_support_mails
-	run_fn(get_support_mails)
-
-	from erpnext.hr.doctype.job_applicant.get_job_applications import get_job_applications
-	run_fn(get_job_applications)
-
-	from erpnext.selling.doctype.lead.get_leads import get_leads
-	run_fn(get_leads)
-
-	from webnotes.utils.email_lib.bulk import flush
-	run_fn(flush)
-	
-def execute_daily():
-	# event reminders
-	from webnotes.core.doctype.event.event import send_event_digest
-	run_fn(send_event_digest)
-	
-	# clear daily event notifications
-	from webnotes.core.doctype.notification_count.notification_count import delete_notification_count_for
-	delete_notification_count_for("Event")
-	
-	# email digest
-	from erpnext.setup.doctype.email_digest.email_digest import send
-	run_fn(send)
-
-	# run recurring invoices
-	from erpnext.accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
-	run_fn(manage_recurring_invoices)
-
-	# send bulk emails
-	from webnotes.utils.email_lib.bulk import clear_outbox
-	run_fn(clear_outbox)
-
-	# daily backup
-	from erpnext.setup.doctype.backup_manager.backup_manager import take_backups_daily
-	run_fn(take_backups_daily)
-
-	# check reorder level
-	from erpnext.stock.utils import reorder_item
-	run_fn(reorder_item)
-		
-	# scheduler error
-	scheduler.report_errors()
-
-def execute_weekly():
-	from erpnext.setup.doctype.backup_manager.backup_manager import take_backups_weekly
-	run_fn(take_backups_weekly)
-
-def execute_monthly():
-	pass
-
-def execute_hourly():
-	pass
-	
-def run_fn(fn):
-	try:
-		fn()
-	except Exception, e:
-		scheduler.log(fn.func_name)
diff --git a/erpnext/startup/webutils.py b/erpnext/startup/webutils.py
index 9e18d4e..ef8c88b 100644
--- a/erpnext/startup/webutils.py
+++ b/erpnext/startup/webutils.py
@@ -4,7 +4,7 @@
 import webnotes
 from webnotes.utils import cint
 
-def get_website_settings(context):
+def update_website_context(context):
 	post_login = []
 	cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled"))
 	if cart_enabled:
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 1d838c9..b748029 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -343,7 +343,7 @@
 					exceptions_list.append([] + webnotes.local.message_log)
 					webnotes.local.message_log = []
 				else:
-					exceptions_list.append(webnotes.getTraceback())
+					exceptions_list.append(webnotes.get_traceback())
 
 	if mr_list:
 		if getattr(webnotes.local, "reorder_email_notify", None) is None: