Package gavo :: Package protocols :: Module uws :: Class BaseUWSJob
[frames] | no frames]

Class BaseUWSJob

source code

object --+
         |
        BaseUWSJob
Known Subclasses:

An abstract UWS job.

UWS jobs are always instanciated with a row from the associated jobs table (i.e. a dictionary giving all the uws properties). You can read the properties as attributes. UWSJobs also keep a (weak) reference to the UWS that made them.

To alter uws properties, use the change method. This will fail unless the job was created giving writable=True.

To make it concrete, you need to define:

You may want to override:

For every piece of the job parameters, define class attributes _parameters_<parname.lower()> with JobParameter values saying how they are serialized and deserialized. Only parameters defined in this way are accepted and integrated into the parameters dict.

If you need to clean up before the job is torn down, redefine the prepareForDestruction method.

Nested Classes
  __metaclass__
The metaclass for UWS jobs.
Instance Methods
 
__init__(self, props, uws, writable=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getattr__(self, name) source code
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
setSerializedPar(self, parName, parValue)
enters parName:parValue into self.parameters after deserializing it.
source code
 
setPar(self, parName, parValue)
enters parName:parValue into self.parameters.
source code
 
getSerializedPar(self, parName)
returns self.parameters[parName] in text form.
source code
 
iterSerializedPars(self)
iterates over the serialized versions of the parameters.
source code
 
iterParameterNames(self)
iterates over the names of the parameters declared for the job.
source code
 
setParamsFromRequest(self, request)
sets our parameter dict from a nevow request.
source code
 
getTransitionTo(self, newPhase)
returns the action prescribed to push self to newPhase.
source code
 
change(self, **kwargs)
changes the property values to what's given by the keyword arguments.
source code
 
getProperties(self)
returns the properties of the job as they are stored in the database.
source code
 
update(self)
fetches a new copy of the job props from the DB.
source code
 
prepareForDestruction(self)
is called before the job's database row is torn down.
source code
 
getURL(self)
returns the UWS URL for this job.
source code
 
getWritable(*args, **kwds)
a context manager for a writeable version of the job.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
getNewId(cls, uws, conn) source code
 
getDefaults(cls, conn)
returns a dictionary suitable for inserting into a jobsTD table.
source code
Properties
  quote
Always returns None.

Inherited from object: __class__

Method Details

__init__(self, props, uws, writable=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__setattr__(self, name, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

setSerializedPar(self, parName, parValue)

source code 

enters parName:parValue into self.parameters after deserializing it.

This is when input comes from text; use setPar for values already parsed.

getSerializedPar(self, parName)

source code 

returns self.parameters[parName] in text form.

This is for use from a text-based interface. Workers read from parameters directly.

setParamsFromRequest(self, request)

source code 

sets our parameter dict from a nevow request.

This can be called on both writable and non-writable jobs.

getTransitionTo(self, newPhase)

source code 

returns the action prescribed to push self to newPhase.

A ValidationError is raised if no such transition is defined.

change(self, **kwargs)

source code 

changes the property values to what's given by the keyword arguments.

It is an AttributeError to try and change a property that is not defined.

getProperties(self)

source code 

returns the properties of the job as they are stored in the database.

Use attribute access to read them and change to change them. Do not get values from the dictionary you get and do not change the dictionary.

update(self)

source code 

fetches a new copy of the job props from the DB.

You should in general not need this, since UWSJob objects are intended to be short-lived ("for the duration of an async request"). Still, for testing and similar, it's convenient to be able to update a UWS job from the database.

prepareForDestruction(self)

source code 

is called before the job's database row is torn down.

Self is writable at this point.

getWritable(*args, **kwds)

source code 

a context manager for a writeable version of the job.

Changes will be written back at the end, and the job object itself will be updated from the database.

If self already is writable, it is returned unchanged, and changes are only persisted when the enclosing controlling block finishes.

Decorators:
  • @contextlib.contextmanager

Property Details

quote

Always returns None.

Override if you have a queue management.

Get Method:
unreachable.quote(self) - Always returns None.