paulb@91 | 1 | #!/usr/bin/env python |
paulb@91 | 2 | |
paulb@91 | 3 | """ |
paulb@91 | 4 | Java Servlet classes. |
paulb@91 | 5 | """ |
paulb@91 | 6 | |
paulb@91 | 7 | import Generic |
paulb@91 | 8 | from StringIO import StringIO |
paulb@115 | 9 | from Helpers.Request import Cookie |
paulb@115 | 10 | import javax.servlet.http.Cookie |
paulb@193 | 11 | from cgi import FieldStorage |
paulb@91 | 12 | |
paulb@91 | 13 | class Stream: |
paulb@91 | 14 | |
paulb@91 | 15 | """ |
paulb@91 | 16 | Wrapper around java.io.BufferedReader. |
paulb@91 | 17 | """ |
paulb@91 | 18 | |
paulb@91 | 19 | def __init__(self, stream): |
paulb@91 | 20 | |
paulb@91 | 21 | "Initialise the stream with the given underlying 'stream'." |
paulb@91 | 22 | |
paulb@91 | 23 | self.stream = stream |
paulb@91 | 24 | |
paulb@91 | 25 | def read(self): |
paulb@91 | 26 | |
paulb@91 | 27 | "Read the entire message, returning it as a string." |
paulb@91 | 28 | |
paulb@91 | 29 | characters = StringIO() |
paulb@91 | 30 | while 1: |
paulb@91 | 31 | c = self.stream.read() |
paulb@91 | 32 | if c == -1: |
paulb@91 | 33 | return characters.getvalue() |
paulb@91 | 34 | else: |
paulb@91 | 35 | characters.write(chr(c)) |
paulb@91 | 36 | |
paulb@91 | 37 | def readline(self): |
paulb@91 | 38 | |
paulb@91 | 39 | "Read a line from the stream, returning it as a string." |
paulb@91 | 40 | |
paulb@91 | 41 | return self.stream.readLine() |
paulb@91 | 42 | |
paulb@91 | 43 | class Transaction(Generic.Transaction): |
paulb@91 | 44 | |
paulb@91 | 45 | """ |
paulb@91 | 46 | Java Servlet transaction interface. |
paulb@91 | 47 | """ |
paulb@91 | 48 | |
paulb@91 | 49 | def __init__(self, request, response): |
paulb@91 | 50 | |
paulb@91 | 51 | """ |
paulb@91 | 52 | Initialise the transaction using the Java Servlet HTTP 'request' and |
paulb@91 | 53 | 'response'. |
paulb@91 | 54 | """ |
paulb@91 | 55 | |
paulb@91 | 56 | self.request = request |
paulb@91 | 57 | self.response = response |
paulb@91 | 58 | self.status = None |
paulb@128 | 59 | self.user = None |
paulb@91 | 60 | |
paulb@115 | 61 | # Remember the cookies received in the request. |
paulb@115 | 62 | # NOTE: Discarding much of the information received. |
paulb@115 | 63 | |
paulb@115 | 64 | self.cookies_in = {} |
paulb@176 | 65 | for cookie in self.request.getCookies() or []: |
paulb@115 | 66 | cookie_name = cookie.getName() |
paulb@115 | 67 | self.cookies_in[cookie_name] = Cookie(cookie_name, cookie.getValue()) |
paulb@115 | 68 | |
paulb@193 | 69 | # Cached information. |
paulb@193 | 70 | |
paulb@193 | 71 | self.storage_body = None |
paulb@193 | 72 | |
paulb@95 | 73 | def commit(self): |
paulb@95 | 74 | |
paulb@95 | 75 | """ |
paulb@95 | 76 | A special method, synchronising the transaction with framework-specific |
paulb@95 | 77 | objects. |
paulb@95 | 78 | """ |
paulb@95 | 79 | |
paulb@95 | 80 | self.get_response_stream().close() |
paulb@95 | 81 | |
paulb@91 | 82 | # Request-related methods. |
paulb@91 | 83 | |
paulb@91 | 84 | def get_request_stream(self): |
paulb@91 | 85 | |
paulb@91 | 86 | """ |
paulb@186 | 87 | Returns the request stream for the transaction. |
paulb@91 | 88 | """ |
paulb@91 | 89 | |
paulb@91 | 90 | return Stream(self.request.getReader()) |
paulb@91 | 91 | |
paulb@91 | 92 | def get_request_method(self): |
paulb@91 | 93 | |
paulb@91 | 94 | """ |
paulb@186 | 95 | Returns the request method. |
paulb@91 | 96 | """ |
paulb@91 | 97 | |
paulb@91 | 98 | return self.request.getMethod() |
paulb@91 | 99 | |
paulb@91 | 100 | def get_headers(self): |
paulb@91 | 101 | |
paulb@91 | 102 | """ |
paulb@186 | 103 | Returns all request headers as a dictionary-like object mapping header |
paulb@186 | 104 | names to values. |
paulb@186 | 105 | |
paulb@91 | 106 | NOTE: If duplicate header names are permitted, then this interface will |
paulb@91 | 107 | NOTE: need to change. |
paulb@91 | 108 | """ |
paulb@91 | 109 | |
paulb@91 | 110 | headers = {} |
paulb@176 | 111 | header_names_enum = self.request.getHeaderNames() |
paulb@176 | 112 | while header_names_enum.hasMoreElements(): |
paulb@91 | 113 | |
paulb@176 | 114 | # NOTE: Retrieve only a single value (not using getHeaders). |
paulb@91 | 115 | |
paulb@176 | 116 | header_name = header_names_enum.nextElement() |
paulb@176 | 117 | headers[header_name] = self.request.getHeader(header_name) |
paulb@91 | 118 | |
paulb@91 | 119 | return headers |
paulb@91 | 120 | |
paulb@91 | 121 | def get_header_values(self, key): |
paulb@91 | 122 | |
paulb@91 | 123 | """ |
paulb@186 | 124 | Returns a list of all request header values associated with the given |
paulb@186 | 125 | 'key'. Note that according to RFC 2616, 'key' is treated as a |
paulb@186 | 126 | case-insensitive string. |
paulb@91 | 127 | """ |
paulb@91 | 128 | |
paulb@176 | 129 | values = [] |
paulb@176 | 130 | headers_enum = self.request.getHeaders(key) |
paulb@176 | 131 | while headers_enum.hasMoreElements(): |
paulb@176 | 132 | values.append(headers_enum.nextElement()) |
paulb@176 | 133 | return values |
paulb@91 | 134 | |
paulb@91 | 135 | def get_content_type(self): |
paulb@91 | 136 | |
paulb@91 | 137 | """ |
paulb@186 | 138 | Returns the content type specified on the request, along with the |
paulb@186 | 139 | charset employed. |
paulb@91 | 140 | """ |
paulb@91 | 141 | |
paulb@176 | 142 | content_types = self.get_header_values("Content-Type") or [] |
paulb@91 | 143 | if len(content_types) >= 1: |
paulb@91 | 144 | return self.parse_content_type(content_types[0]) |
paulb@91 | 145 | else: |
paulb@91 | 146 | return None |
paulb@91 | 147 | |
paulb@91 | 148 | def get_content_charsets(self): |
paulb@91 | 149 | |
paulb@91 | 150 | """ |
paulb@91 | 151 | Returns the character set preferences. |
paulb@91 | 152 | """ |
paulb@91 | 153 | |
paulb@176 | 154 | accept_charsets = self.get_header_values("Accept-Charset") or [] |
paulb@91 | 155 | if len(accept_charsets) >= 1: |
paulb@91 | 156 | return self.parse_content_preferences(accept_charsets[0]) |
paulb@91 | 157 | else: |
paulb@91 | 158 | return None |
paulb@91 | 159 | |
paulb@91 | 160 | def get_content_languages(self): |
paulb@91 | 161 | |
paulb@91 | 162 | """ |
paulb@186 | 163 | Returns extracted language information from the transaction. |
paulb@91 | 164 | """ |
paulb@91 | 165 | |
paulb@176 | 166 | accept_languages = self.get_header_values("Accept-Language") or [] |
paulb@91 | 167 | if len(accept_languages) >= 1: |
paulb@91 | 168 | return self.parse_content_preferences(accept_languages[0]) |
paulb@91 | 169 | else: |
paulb@91 | 170 | return None |
paulb@91 | 171 | |
paulb@91 | 172 | def get_path(self): |
paulb@91 | 173 | |
paulb@91 | 174 | """ |
paulb@186 | 175 | Returns the entire path from the request. |
paulb@91 | 176 | """ |
paulb@91 | 177 | |
paulb@162 | 178 | # NOTE: To be verified. |
paulb@162 | 179 | |
paulb@162 | 180 | path = self.get_path_without_query() |
paulb@162 | 181 | qs = self.get_query_string() |
paulb@162 | 182 | if qs: |
paulb@162 | 183 | path += "?" |
paulb@162 | 184 | path += qs |
paulb@162 | 185 | return path |
paulb@162 | 186 | |
paulb@162 | 187 | def get_path_without_query(self): |
paulb@162 | 188 | |
paulb@162 | 189 | """ |
paulb@186 | 190 | Returns the entire path from the request minus the query string. |
paulb@162 | 191 | """ |
paulb@162 | 192 | |
paulb@91 | 193 | return self.request.getServletPath() |
paulb@91 | 194 | |
paulb@91 | 195 | def get_path_info(self): |
paulb@91 | 196 | |
paulb@91 | 197 | """ |
paulb@186 | 198 | Returns the "path info" (the part of the URL after the resource name |
paulb@186 | 199 | handling the current request) from the request. |
paulb@91 | 200 | """ |
paulb@91 | 201 | |
paulb@91 | 202 | return self.request.getPathInfo() |
paulb@91 | 203 | |
paulb@91 | 204 | def get_query_string(self): |
paulb@91 | 205 | |
paulb@91 | 206 | """ |
paulb@186 | 207 | Returns the query string from the path in the request. |
paulb@91 | 208 | """ |
paulb@91 | 209 | |
paulb@91 | 210 | return self.request.getQueryString() |
paulb@91 | 211 | |
paulb@91 | 212 | # Higher level request-related methods. |
paulb@91 | 213 | |
paulb@91 | 214 | def get_fields_from_path(self): |
paulb@91 | 215 | |
paulb@91 | 216 | """ |
paulb@186 | 217 | Extracts the form fields from the path specified in the transaction. The |
paulb@186 | 218 | underlying framework may refuse to supply fields from the path if |
paulb@186 | 219 | handling a POST transaction. |
paulb@91 | 220 | |
paulb@91 | 221 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@91 | 222 | single value is associated with any given field name). |
paulb@91 | 223 | |
paulb@91 | 224 | NOTE: There may not be a reliable means of extracting only the fields |
paulb@91 | 225 | NOTE: from the path. |
paulb@91 | 226 | """ |
paulb@91 | 227 | |
paulb@91 | 228 | return self.get_fields_from_body() |
paulb@91 | 229 | |
paulb@167 | 230 | def get_fields_from_body(self, encoding=None): |
paulb@91 | 231 | |
paulb@91 | 232 | """ |
paulb@186 | 233 | Extracts the form fields from the message body in the transaction. The |
paulb@186 | 234 | optional 'encoding' parameter specifies the character encoding of the |
paulb@186 | 235 | message body for cases where no such information is available, but where |
paulb@186 | 236 | the default encoding is to be overridden. |
paulb@91 | 237 | |
paulb@91 | 238 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@193 | 239 | single value is associated with any given field name). Each value is |
paulb@193 | 240 | either a Unicode object (representing a simple form field, for example) |
paulb@193 | 241 | or a file-like object (representing a file upload form field, for |
paulb@193 | 242 | example). |
paulb@91 | 243 | |
paulb@91 | 244 | NOTE: There may not be a reliable means of extracting only the fields |
paulb@167 | 245 | NOTE: from the message body. Moreover, the encoding of the fields may |
paulb@167 | 246 | NOTE: not be pertinent. |
paulb@91 | 247 | """ |
paulb@91 | 248 | |
paulb@91 | 249 | fields = {} |
paulb@193 | 250 | |
paulb@193 | 251 | # Where the content type is "multipart/form-data", we use the |
paulb@193 | 252 | # FieldStorage class from the standard library. Otherwise, we use the |
paulb@193 | 253 | # Servlet API's parameter access methods. |
paulb@193 | 254 | |
paulb@193 | 255 | if self.get_content_type() and self.get_content_type().content_type == "multipart/form-data": |
paulb@193 | 256 | |
paulb@193 | 257 | # NOTE: Taken from WebStack.CGI.get_fields_from_body. |
paulb@193 | 258 | |
paulb@193 | 259 | if self.storage_body is None: |
paulb@193 | 260 | self.storage_body = FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(), |
paulb@193 | 261 | environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1) |
paulb@193 | 262 | |
paulb@193 | 263 | # Avoid strange design issues with FieldStorage by checking the internal |
paulb@193 | 264 | # field list directly. |
paulb@193 | 265 | |
paulb@193 | 266 | if self.storage_body.list is not None: |
paulb@193 | 267 | |
paulb@193 | 268 | # Traverse the storage, finding each field value. |
paulb@193 | 269 | |
paulb@193 | 270 | for field_name in self.storage_body.keys(): |
paulb@193 | 271 | |
paulb@193 | 272 | # NOTE: Jython 2.1 does not have a cgi module with a |
paulb@193 | 273 | # NOTE: FieldStorage.getlist implementation. |
paulb@193 | 274 | |
paulb@193 | 275 | field_values = self.storage_body.getvalue(field_name) |
paulb@193 | 276 | |
paulb@193 | 277 | if type(field_values) == type([]): |
paulb@193 | 278 | fields[field_name] = [] |
paulb@193 | 279 | for field_value in field_values: |
paulb@193 | 280 | if hasattr(field_value, "file"): |
paulb@193 | 281 | fields[field_name].append(field_value.file) |
paulb@193 | 282 | else: |
paulb@193 | 283 | fields[field_name].append(field_value) |
paulb@193 | 284 | else: |
paulb@193 | 285 | if hasattr(field_values, "file"): |
paulb@193 | 286 | fields[field_name] = [field_values.file] |
paulb@193 | 287 | else: |
paulb@193 | 288 | fields[field_name] = [field_values] |
paulb@193 | 289 | |
paulb@193 | 290 | else: |
paulb@193 | 291 | parameter_map = self.request.getParameterMap() |
paulb@193 | 292 | if parameter_map: |
paulb@193 | 293 | for key in parameter_map.keySet(): |
paulb@193 | 294 | fields[key] = parameter_map[key] |
paulb@193 | 295 | |
paulb@91 | 296 | return fields |
paulb@91 | 297 | |
paulb@91 | 298 | def get_user(self): |
paulb@91 | 299 | |
paulb@91 | 300 | """ |
paulb@186 | 301 | Extracts user information from the transaction. |
paulb@108 | 302 | |
paulb@108 | 303 | Returns a username as a string or None if no user is defined. |
paulb@91 | 304 | """ |
paulb@91 | 305 | |
paulb@128 | 306 | if self.user is not None: |
paulb@128 | 307 | return self.user |
paulb@128 | 308 | else: |
paulb@128 | 309 | return self.request.getRemoteUser() |
paulb@91 | 310 | |
paulb@115 | 311 | def get_cookies(self): |
paulb@115 | 312 | |
paulb@115 | 313 | """ |
paulb@186 | 314 | Obtains cookie information from the request. |
paulb@115 | 315 | |
paulb@115 | 316 | Returns a dictionary mapping cookie names to cookie objects. |
paulb@115 | 317 | """ |
paulb@115 | 318 | |
paulb@115 | 319 | return self.cookies_in |
paulb@115 | 320 | |
paulb@115 | 321 | def get_cookie(self, cookie_name): |
paulb@115 | 322 | |
paulb@115 | 323 | """ |
paulb@186 | 324 | Obtains cookie information from the request. |
paulb@115 | 325 | |
paulb@115 | 326 | Returns a cookie object for the given 'cookie_name' or None if no such |
paulb@115 | 327 | cookie exists. |
paulb@115 | 328 | """ |
paulb@115 | 329 | |
paulb@115 | 330 | return self.cookies_in.get(cookie_name) |
paulb@115 | 331 | |
paulb@91 | 332 | # Response-related methods. |
paulb@91 | 333 | |
paulb@91 | 334 | def get_response_stream(self): |
paulb@91 | 335 | |
paulb@91 | 336 | """ |
paulb@186 | 337 | Returns the response stream for the transaction. |
paulb@91 | 338 | """ |
paulb@91 | 339 | |
paulb@176 | 340 | return self.response.getOutputStream() |
paulb@91 | 341 | |
paulb@91 | 342 | def get_response_code(self): |
paulb@91 | 343 | |
paulb@91 | 344 | """ |
paulb@91 | 345 | Get the response code associated with the transaction. If no response |
paulb@91 | 346 | code is defined, None is returned. |
paulb@91 | 347 | """ |
paulb@91 | 348 | |
paulb@91 | 349 | return self.status |
paulb@91 | 350 | |
paulb@91 | 351 | def set_response_code(self, response_code): |
paulb@91 | 352 | |
paulb@91 | 353 | """ |
paulb@91 | 354 | Set the 'response_code' using a numeric constant defined in the HTTP |
paulb@91 | 355 | specification. |
paulb@91 | 356 | """ |
paulb@91 | 357 | |
paulb@91 | 358 | self.status = response_code |
paulb@91 | 359 | self.response.setStatus(self.status) |
paulb@91 | 360 | |
paulb@91 | 361 | def set_header_value(self, header, value): |
paulb@91 | 362 | |
paulb@91 | 363 | """ |
paulb@91 | 364 | Set the HTTP 'header' with the given 'value'. |
paulb@91 | 365 | """ |
paulb@91 | 366 | |
paulb@91 | 367 | self.response.setHeader(self.format_header_value(header), self.format_header_value(value)) |
paulb@91 | 368 | |
paulb@91 | 369 | def set_content_type(self, content_type): |
paulb@91 | 370 | |
paulb@91 | 371 | """ |
paulb@186 | 372 | Sets the 'content_type' for the response. |
paulb@91 | 373 | """ |
paulb@91 | 374 | |
paulb@91 | 375 | return self.response.setHeader("Content-Type", self.format_content_type(content_type)) |
paulb@91 | 376 | |
paulb@115 | 377 | # Higher level response-related methods. |
paulb@115 | 378 | |
paulb@115 | 379 | def set_cookie(self, cookie): |
paulb@115 | 380 | |
paulb@115 | 381 | """ |
paulb@186 | 382 | Stores the given 'cookie' object in the response. |
paulb@115 | 383 | """ |
paulb@115 | 384 | |
paulb@115 | 385 | new_cookie = javax.servlet.http.Cookie(cookie.name, cookie.value) |
paulb@115 | 386 | self.response.addCookie(new_cookie) |
paulb@115 | 387 | |
paulb@115 | 388 | def set_cookie_value(self, name, value, path=None, expires=None): |
paulb@115 | 389 | |
paulb@115 | 390 | """ |
paulb@186 | 391 | Stores a cookie with the given 'name' and 'value' in the response. |
paulb@115 | 392 | |
paulb@115 | 393 | The optional 'path' is a string which specifies the scope of the cookie, |
paulb@115 | 394 | and the optional 'expires' parameter is a value compatible with the |
paulb@115 | 395 | time.time function, and indicates the expiry date/time of the cookie. |
paulb@115 | 396 | """ |
paulb@115 | 397 | |
paulb@115 | 398 | cookie = javax.servlet.http.Cookie(name, value) |
paulb@115 | 399 | if path is not None: |
paulb@115 | 400 | cookie.setPath(path) |
paulb@115 | 401 | |
paulb@115 | 402 | # NOTE: The expires parameter seems not to be supported. |
paulb@115 | 403 | |
paulb@115 | 404 | self.response.addCookie(cookie) |
paulb@115 | 405 | |
paulb@115 | 406 | def delete_cookie(self, cookie_name): |
paulb@115 | 407 | |
paulb@115 | 408 | """ |
paulb@186 | 409 | Adds to the response a request that the cookie with the given |
paulb@186 | 410 | 'cookie_name' be deleted/discarded by the client. |
paulb@115 | 411 | """ |
paulb@115 | 412 | |
paulb@115 | 413 | # Create a special cookie, given that we do not know whether the browser |
paulb@115 | 414 | # has been sent the cookie or not. |
paulb@115 | 415 | # NOTE: Magic discovered in Webware. |
paulb@115 | 416 | |
paulb@115 | 417 | cookie = javax.servlet.http.Cookie(cookie_name, "") |
paulb@115 | 418 | cookie.setPath("/") |
paulb@115 | 419 | cookie.setMaxAge(0) |
paulb@115 | 420 | self.response.addCookie(cookie) |
paulb@115 | 421 | |
paulb@183 | 422 | # Session-related methods. |
paulb@183 | 423 | |
paulb@183 | 424 | def get_session(self, create=1): |
paulb@183 | 425 | |
paulb@183 | 426 | """ |
paulb@186 | 427 | Gets a session corresponding to an identifier supplied in the |
paulb@186 | 428 | transaction. |
paulb@183 | 429 | |
paulb@183 | 430 | If no session has yet been established according to information |
paulb@183 | 431 | provided in the transaction then the optional 'create' parameter |
paulb@183 | 432 | determines whether a new session will be established. |
paulb@183 | 433 | |
paulb@183 | 434 | Where no session has been established and where 'create' is set to 0 |
paulb@183 | 435 | then None is returned. In all other cases, a session object is created |
paulb@183 | 436 | (where appropriate) and returned. |
paulb@183 | 437 | """ |
paulb@183 | 438 | |
paulb@183 | 439 | return self.request.getSession(create) |
paulb@183 | 440 | |
paulb@183 | 441 | def expire_session(self): |
paulb@183 | 442 | |
paulb@183 | 443 | """ |
paulb@186 | 444 | Expires any session established according to information provided in the |
paulb@186 | 445 | transaction. |
paulb@183 | 446 | """ |
paulb@183 | 447 | |
paulb@183 | 448 | session = self.get_session(create=0) |
paulb@183 | 449 | if session: |
paulb@183 | 450 | session.invalidate() |
paulb@183 | 451 | |
paulb@128 | 452 | # Application-specific methods. |
paulb@128 | 453 | |
paulb@128 | 454 | def set_user(self, username): |
paulb@128 | 455 | |
paulb@128 | 456 | """ |
paulb@128 | 457 | An application-specific method which sets the user information with |
paulb@128 | 458 | 'username' in the transaction. This affects subsequent calls to |
paulb@128 | 459 | 'get_user'. |
paulb@128 | 460 | """ |
paulb@128 | 461 | |
paulb@128 | 462 | self.user = username |
paulb@128 | 463 | |
paulb@183 | 464 | class Session: |
paulb@183 | 465 | |
paulb@183 | 466 | """ |
paulb@183 | 467 | A simple session class with behaviour more similar to the Python framework |
paulb@183 | 468 | session classes. |
paulb@183 | 469 | """ |
paulb@183 | 470 | |
paulb@183 | 471 | def __init__(self, session): |
paulb@183 | 472 | |
paulb@183 | 473 | "Initialise the session object with the framework 'session' object." |
paulb@183 | 474 | |
paulb@183 | 475 | self.session = session |
paulb@183 | 476 | |
paulb@183 | 477 | def keys(self): |
paulb@183 | 478 | keys = [] |
paulb@183 | 479 | keys_enum = self.session.getAttributeNames() |
paulb@183 | 480 | while keys_enum.hasMoreElements(): |
paulb@183 | 481 | keys.append(keys_enum.nextElement()) |
paulb@183 | 482 | return keys |
paulb@183 | 483 | |
paulb@183 | 484 | def values(self): |
paulb@183 | 485 | values = [] |
paulb@183 | 486 | for key in self.keys(): |
paulb@183 | 487 | values.append(self[key]) |
paulb@183 | 488 | return values |
paulb@183 | 489 | |
paulb@183 | 490 | def items(self): |
paulb@183 | 491 | items = [] |
paulb@183 | 492 | for key in self.keys(): |
paulb@183 | 493 | items.append((key, self[key])) |
paulb@183 | 494 | return items |
paulb@183 | 495 | |
paulb@183 | 496 | def __getitem__(self, key): |
paulb@183 | 497 | return self.session.getAttribute(key) |
paulb@183 | 498 | |
paulb@183 | 499 | def __setitem__(self, key, value): |
paulb@183 | 500 | self.session.setAttribute(key, value) |
paulb@183 | 501 | |
paulb@183 | 502 | def __delitem__(self, key): |
paulb@183 | 503 | self.session.removeAttribute(key) |
paulb@183 | 504 | |
paulb@91 | 505 | # vim: tabstop=4 expandtab shiftwidth=4 |