Changeset ee8e6d0 for server/lib/gutenbach/server/requests.py
- Timestamp:
- Dec 27, 2011, 7:03:46 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 7c143c9
- Parents:
- 1037115
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/27/11 19:03:46)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/27/11 19:03:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/requests.py
r1037115 ree8e6d0 41 41 42 42 def __init__(self): 43 print "init" 43 44 self.printers = { 44 45 "test": GutenbachPrinter(name="test") … … 227 228 jobs = self.printers[printer_name].get_jobs() 228 229 229 # requesting username230 if 'requesting-user-name' in operation:231 username_attr = operation['requesting-user-name']232 username = username_attr.values[0].value233 if username_attr != ipp.RequestingUserName(username):234 raise ipp.errors.ClientErrorBadRequest(str(username_attr))235 236 230 # get the job attributes and add them to the response 237 231 for job in self.printers[printer_name].get_jobs(): 238 attrs = job.get_job_attributes( request)232 attrs = job.get_job_attributes(operation) 239 233 response.attribute_groups.append(ipp.AttributeGroup( 240 234 ipp.AttributeTags.JOB, attrs)) … … 260 254 in the multi-document Job object. 261 255 262 Group 1: Operation Attributes 256 Request 257 ------- 258 Group 1: Operation Attributes 259 REQUIRED 'attributes-charset' 260 REQUIRED 'attributes-natural-language' 261 REQUIRED 'printer-uri' (uri) 262 OPTIONAL 'requesting-user-name' (name(MAX)) 263 OPTIONAL 'job-name' (name(MAX)) 264 OPTIONAL 'ipp-attribute-fidelity' (boolean) 265 OPTIONAL 'job-k-octets' (integer(0:MAX)) 266 OPTIONAL 'job-impressions' (integer(0:MAX)) 267 OPTIONAL 'job-media-sheets' (integer(0:MAX)) 268 Group 2: Job Template Attributes 269 270 Response 271 -------- 272 Group 1: Operation Attributes 273 OPTIONAL 'status-message' (text(255)) 274 OPTIONAL 'detailed-status-message' (text(MAX)) 275 REQUIRED 'attributes-charset' 276 REQUIRED 'attributes-natural-language' 277 Group 2: Unsupported Attributes 278 Group 3: Job Object Attributes 279 REQUIRED 'job-uri' (uri) 280 REQUIRED 'job-id' (integer(1:MAX)) 281 REQUIRED 'job-state' (type1 enum) 282 REQUIRED 'job-state-reasons' (1setOf type2 keyword) 283 OPTIONAL 'job-state-message' (text(MAX)) 284 OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX)) 263 285 264 286 """ 265 287 266 raise ipp.errors.ServerErrorOperationNotSupported 288 289 operation = request.attribute_groups[0] 290 291 # requested printer uri 292 if 'printer-uri' not in operation: 293 raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute") 294 uri_attr = operation['printer-uri'] 295 printer_name = uri_attr.values[0].value.split("/")[-1] 296 if uri_attr != ipp.PrinterUri(uri_attr.values[0].value): 297 raise ipp.errors.ClientErrorBadRequest(str(uri_attr)) 298 if printer_name not in self.printers: 299 raise ipp.errors.ClientErrorAttributes(str(uri_attr), uri_attr) 300 301 # get attributes from the printer and add to response 302 job = self.printers[printer_name].create_job(request) 303 response.attribute_groups.append(ipp.AttributeGroup( 304 ipp.AttributeTags.JOB, job.get_job_attributes(operation))) 267 305 268 306 @handler_for(ipp.OperationCodes.PAUSE_PRINTER) … … 296 334 OPTIONAL 'requesting-user-name' (name(MAX)) 297 335 OPTIONAL 'requested-attributes' (1setOf type2 keyword) 298 OPTIONAL 'document-format' (mimeMediaType) :299 336 OPTIONAL 'document-format' (mimeMediaType) 337 300 338 Response 301 339 -------- … … 324 362 printer = self.printers[printer_name] 325 363 326 # requesting username327 if 'requesting-user-name' in operation:328 username_attr = operation['requesting-user-name']329 username = username_attr.values[0].value330 if username_attr != ipp.RequestingUserName(username):331 raise ipp.errors.ClientErrorBadRequest(str(username_attr))332 333 364 # get attributes from the printer and add to response 334 365 response.attribute_groups.append(ipp.AttributeGroup( 335 ipp.AttributeTags.PRINTER, printer.get_printer_attributes( request)))366 ipp.AttributeTags.PRINTER, printer.get_printer_attributes(operation))) 336 367 337 368 @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES) … … 379 410 job = printer.get_job(job_id) 380 411 381 # requesting username382 if 'requesting-user-name' in operation:383 username_attr = operation['requesting-user-name']384 username = username_attr.values[0].value385 if username_attr != ipp.RequestingUserName(username):386 raise ipp.errors.ClientErrorBadRequest(str(username_attr))387 388 412 # get the job attributes and add them to the response 389 attrs = job.get_job_attributes( request)413 attrs = job.get_job_attributes(operation) 390 414 response.attribute_groups.append(ipp.AttributeGroup( 391 415 ipp.AttributeTags.JOB, attrs)) … … 438 462 printer = self.printers[self.default] 439 463 440 # requesting username441 if 'requesting-user-name' in operation:442 username_attr = operation['requesting-user-name']443 username = username_attr.values[0].value444 if username_attr != ipp.RequestingUserName(username):445 raise ipp.errors.ClientErrorBadRequest(str(username_attr))446 447 464 # get attributes from the printer and add to response 448 465 response.attribute_groups.append(ipp.AttributeGroup( 449 ipp.AttributeTags.PRINTER, printer.get_printer_attributes( request)))466 ipp.AttributeTags.PRINTER, printer.get_printer_attributes(operation))) 450 467 451 468 @handler_for(ipp.OperationCodes.CUPS_GET_PRINTERS) … … 462 479 operation = request.attribute_groups[0] 463 480 464 # requesting username465 if 'requesting-user-name' in operation:466 username_attr = operation['requesting-user-name']467 username = username_attr.values[0].value468 if username_attr != ipp.RequestingUserName(username):469 raise ipp.errors.ClientErrorBadRequest(str(username_attr))470 471 481 # get attributes from the printer and add to response 472 482 for printer in self.printers.values(): 473 483 response.attribute_groups.append(ipp.AttributeGroup( 474 ipp.AttributeTags.PRINTER, printer.get_printer_attributes( request)))484 ipp.AttributeTags.PRINTER, printer.get_printer_attributes(operation))) 475 485 476 486 @handler_for(ipp.OperationCodes.CUPS_GET_CLASSES)
Note: See TracChangeset
for help on using the changeset viewer.