sync with gateway moved to defs
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 7db56bd..107a5d7 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -26,9 +26,11 @@
 	if login_manager.user not in ('Guest', None, '') and webnotes.conn.cur_db_name!='accounts' and webnotes.conn.get_value('Control Panel', 'Control Panel', 'account_id')!='s5u011':
 		try:
 			login_manager = login_as(login_manager)
-			update_account_details()
-			import server_tools.gateway_utils
-			server_tools.gateway_utils.check_login(login_manager.user)
+			if hasattr(webnotes.defs, 'sync_with_gateway') and \
+					cint(webnotes.defs.sync_with_gateway) or 0:
+				update_account_details()
+				import server_tools.gateway_utils
+				server_tools.gateway_utils.check_login(login_manager.user)
 			
 		except ImportError:
 			pass
@@ -157,6 +159,8 @@
 # logout the user from SSO
 #
 def on_logout(login_manager):
-	if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
+	import webnotes.defs
+	if hasattr(webnotes.defs, 'sync_with_gateway') and \
+			cint(webnotes.defs.sync_with_gateway) or 0:
 		from server_tools.gateway_utils import logout_sso
 		logout_sso(user=login_manager.user)