Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 1 | #!/usr/bin/python |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 2 | |
| 3 | # ERPNext - web based ERP (http://erpnext.com) |
| 4 | # Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 5 | # |
| 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation, either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 19 | |
| 20 | import cgi, cgitb, os, sys |
| 21 | cgitb.enable() |
| 22 | |
| 23 | # import libs |
| 24 | sys.path.append('lib/py') |
| 25 | sys.path.append('erpnext') |
| 26 | |
| 27 | import webnotes |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 28 | import webnotes.handler |
| 29 | import webnotes.auth |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 30 | import webnotes.defs |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 31 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 32 | def init(): |
| 33 | # make the form_dict |
| 34 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 35 | for key in webnotes.form.keys(): |
| 36 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 37 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 38 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 39 | try: |
| 40 | webnotes.http_request = webnotes.auth.HTTPRequest() |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame^] | 41 | return True |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 42 | except webnotes.AuthenticationError, e: |
| 43 | pass |
Rushabh Mehta | 13531b7 | 2012-02-20 12:35:23 +0530 | [diff] [blame] | 44 | except webnotes.UnknownDomainError, e: |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 45 | print "Location: " + (webnotes.defs.redirect_404) |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame^] | 46 | except webnotes.SessionStopped, e: |
| 47 | if 'cmd' in webnotes.form_dict: |
| 48 | webnotes.handler.print_json() |
| 49 | else: |
| 50 | print "Content-Type: text/html" |
| 51 | print |
| 52 | print """<html> |
| 53 | <body style="background-color: #EEE;"> |
| 54 | <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto"> |
| 55 | Updating. |
| 56 | We will be back in a few moments... |
| 57 | </h3> |
| 58 | </body> |
| 59 | </html>""" |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 60 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 61 | def respond(): |
| 62 | import webnotes |
| 63 | if 'cmd' in webnotes.form_dict: |
| 64 | webnotes.handler.handle() |
| 65 | else: |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 66 | import webnotes.cms.index |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 67 | print "Content-Type: text/html" |
| 68 | webnotes.handler.print_cookies() |
| 69 | print |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 70 | print webnotes.cms.index.get() |
Rushabh Mehta | 5ede3e8 | 2011-09-08 14:16:34 +0530 | [diff] [blame] | 71 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 72 | if __name__=="__main__": |
Rushabh Mehta | da27db4 | 2012-02-28 12:17:08 +0100 | [diff] [blame^] | 73 | if init(): |
| 74 | respond() |