Package gavo :: Package svcs :: Module standardcores :: Class PhraseMaker
[frames] | no frames]

Class PhraseMaker

source code

                   object --+                    
                            |                    
 base.structure.StructureBase --+                
                                |                
                   object --+   |                
                            |   |                
           base.common.Parser --+                
                                |                
base.structure.ParseableStructure --+            
                                    |            
             base.structure.Structure --+        
                                        |        
                           object --+   |        
                                    |   |        
      base.structure.RestrictionMixin --+        
                                        |        
                   rscdef.procdef.ProcDef --+    
                                            |    
                       rscdef.procdef.ProcApp --+
                                                |
                                               PhraseMaker

A procedure application for generating SQL expressions from input keys.

PhraseMaker code must *yield* SQL fragments that can occur in WHERE clauses, i.e., boolean expressions (thus, they must be generator bodies). The clauses yielded by a single condDesc are combined with the joiner set in the containing CondDesc (default=OR).

The following names are available to them:

To get the standard SQL a single key would generate, say:

       yield base.getSQLForField(inputKeys[0], inPars, outPars)

To insert some value into outPars, do not simply use some key into outParse, since, e.g., the condDesc might be used multiple times. Instead, use getSQLKey, maybe like this:

       ik = inputKeys[0]
       yield "%s BETWEEN %%(%s)s AND %%(%s)s"%(ik.name,
               base.getSQLKey(ik.name, inPars[ik.name]-10, outPars),
               base.getSQLKey(ik.name, inPars[ik.name]+10, outPars))

getSQLKey will make sure unique names in outPars are chosen and enters the values there.

Nested Classes

Inherited from base.structure.StructureBase: __metaclass__

Instance Methods

Inherited from rscdef.procdef.ProcApp: breakCircles, compile, completeElement, getBodySetupCode, getFuncCode, getLateSetupCode, getParSetupCode, getSetupCode, getSetupPars, onElementComplete, validate

Inherited from rscdef.procdef.ProcDef: getCode

Inherited from base.structure.Structure: __provides__, callCompletedCallbacks, finishElement

Inherited from base.structure.ParseableStructure: __init__, end_, feed, feedFrom, feedObject, getAttribute, iterEvents, start_, value_

Inherited from base.structure.StructureBase: __providedBy__, adopt, change, copy, getAttributes, getCopyableAttributes, getSourcePosition, iterChildren, setPosition

Inherited from base.common.Parser: feedEvent

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

Class Methods

Inherited from base.structure.StructureBase: fromStructure

Class Variables
  name_ = 'phraseMaker'
hash(x)
  requiredType = 'phraseMaker'
hash(x)
  formalArgs = 'self, inputKeys, inPars, outPars, core'

Inherited from rscdef.procdef.ProcApp: additionalNamesForProcs, attrSeq, managedAttrs

Inherited from base.structure.Structure: __implemented__

Inherited from base.structure.StructureBase: completedCallbacks

Properties

Inherited from object: __class__