blob: 60a91673f90dc953c89128398f71717e7c069594 [file] [log] [blame]
Rushabh Mehta03e87872012-04-14 15:02:17 +05301#!/usr/bin/env python
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05302
Rushabh Mehta03e87872012-04-14 15:02:17 +05303# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05304#
Rushabh Mehta03e87872012-04-14 15:02:17 +05305# MIT License (MIT)
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05306#
Rushabh Mehta03e87872012-04-14 15:02:17 +05307# Permission is hereby granted, free of charge, to any person obtaining a
8# copy of this software and associated documentation files (the "Software"),
9# to deal in the Software without restriction, including without limitation
10# the rights to use, copy, modify, merge, publish, distribute, sublicense,
11# and/or sell copies of the Software, and to permit persons to whom the
12# Software is furnished to do so, subject to the following conditions:
Rushabh Mehta3966f1d2012-02-23 12:35:32 +053013#
Rushabh Mehta03e87872012-04-14 15:02:17 +053014# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23#
Rushabh Mehta3966f1d2012-02-23 12:35:32 +053024
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053025
26import cgi, cgitb, os, sys
27cgitb.enable()
28
29# import libs
30sys.path.append('lib/py')
31sys.path.append('erpnext')
32
33import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053034import webnotes.handler
35import webnotes.auth
Anand Doshib319d2c2012-02-17 12:47:36 +053036import webnotes.defs
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053037
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053038def init():
39 # make the form_dict
40 webnotes.form = cgi.FieldStorage(keep_blank_values=True)
41 for key in webnotes.form.keys():
42 webnotes.form_dict[key] = webnotes.form.getvalue(key)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053043
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053044 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010045 try:
46 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtada27db42012-02-28 12:17:08 +010047 return True
Rushabh Mehtaafaac602012-02-14 11:44:13 +053048 except webnotes.AuthenticationError, e:
Rushabh Mehtaa38bbe22012-02-29 10:55:43 +053049 return True
Rushabh Mehta13531b72012-02-20 12:35:23 +053050 except webnotes.UnknownDomainError, e:
Anand Doshib319d2c2012-02-17 12:47:36 +053051 print "Location: " + (webnotes.defs.redirect_404)
Rushabh Mehtada27db42012-02-28 12:17:08 +010052 except webnotes.SessionStopped, e:
53 if 'cmd' in webnotes.form_dict:
54 webnotes.handler.print_json()
55 else:
56 print "Content-Type: text/html"
57 print
58 print """<html>
59 <body style="background-color: #EEE;">
60 <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
61 Updating.
62 We will be back in a few moments...
63 </h3>
64 </body>
65 </html>"""
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053066
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053067def respond():
68 import webnotes
69 if 'cmd' in webnotes.form_dict:
70 webnotes.handler.handle()
71 else:
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053072 import webnotes.cms.index
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053073 print "Content-Type: text/html"
74 webnotes.handler.print_cookies()
75 print
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053076 print webnotes.cms.index.get()
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053077
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053078if __name__=="__main__":
Rushabh Mehtada27db42012-02-28 12:17:08 +010079 if init():
80 respond()