Subversion Repositories SmartDukaan

Rev

Rev 14960 | Rev 15229 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14960 Rev 15081
Line 3... Line 3...
3
 
3
 
4
@author: amit
4
@author: amit
5
'''
5
'''
6
from dtr import main
6
from dtr import main
7
from dtr.storage import Mongo, Mysql
7
from dtr.storage import Mongo, Mysql
8
import datetime
-
 
9
import falcon
8
import falcon
10
import json
9
import json
11
import urlparse
10
import urlparse
12
class StoreOrder():
11
class StoreOrder():
13
    def on_post(self, req, resp):
12
    def on_post(self, req, resp):
Line 127... Line 126...
127
        except ValueError:
126
        except ValueError:
128
            raise falcon.HTTPError(falcon.HTTP_400,
127
            raise falcon.HTTPError(falcon.HTTP_400,
129
                'Malformed JSON',
128
                'Malformed JSON',
130
                'Could not decode the request body. The '
129
                'Could not decode the request body. The '
131
                'JSON was incorrect.')
130
                'JSON was incorrect.')
-
 
131
 
-
 
132
class SnapShot():
-
 
133
    def on_get(self, req, resp):
-
 
134
        try:
-
 
135
            resp.content_type = 'text/html'
-
 
136
            user = req.get_param_as_int("user")
-
 
137
            file = req.get_param("file") 
-
 
138
            if  file is not None:
-
 
139
                #fetch the page and return html
-
 
140
                with open ("/AmazonTrack/User%d/%s"%(user, file), "r") as myfile:
-
 
141
                    resp.body=myfile.read() 
-
 
142
            else:
-
 
143
                #return user specific urls
-
 
144
                resp.body=getUserUrls(user)
-
 
145
        except ValueError:
-
 
146
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
147
                'Malformed JSON',
-
 
148
                'Could not decode the request body. The '
-
 
149
                'JSON was incorrect.')
-
 
150
            
-
 
151
def getUserUrls(user):
-
 
152
    pass
132
        
153
        
133
class RawHtml():
154
class RawHtml():
134
    def on_get(self, req, resp, orderId):
155
    def on_get(self, req, resp, orderId):
135
        try:
156
        try:
136
            result = Mysql.getOrderHtml(orderId)
157
            result = Mysql.getOrderHtml(orderId)