Package gavo :: Package registry :: Module nonservice
[frames] | no frames]

Source Code for Module gavo.registry.nonservice

  1  """ 
  2  Resources that are not services. 
  3  """ 
  4   
  5  #c Copyright 2008-2019, the GAVO project 
  6  #c 
  7  #c This program is free software, covered by the GNU GPL.  See the 
  8  #c COPYING file in the source distribution. 
  9   
 10   
 11  from gavo import base 
 12  from gavo import rscdef 
 13  from gavo import svcs 
 14  from gavo import utils 
 15  from gavo.registry import common 
 16   
 17   
18 -class NonServiceResource( 19 base.Structure, 20 base.StandardMacroMixin, 21 base.ComputedMetaMixin):
22 """A base class for resources that are not services. 23 """
24 - def _meta_identifier(self):
25 # Special case the authority 26 if base.getMetaText(self, "resType")=="authority": 27 localPart = "" 28 else: 29 localPart = "/%s/%s"%(self.rd.sourceId, self.id) 30 return "ivo://%s%s"%(base.getConfig("ivoa", "authority"), localPart)
31 32
33 -class ResRec(rscdef.IVOMetaMixin, NonServiceResource):
34 """A resource for pure registration purposes. 35 36 A Resource without DaCHS defined behaviour. This can be 37 Organizations or Instruments, but possibly also external services 38 39 All resources must either have an id (which is used in the construction of 40 their IVOID), or you must give an identifier meta item. 41 42 You must further set the following meta items: 43 44 - resType specifying the kind of resource record. You should not 45 use this element to build resource records for services or tables 46 (use the normal elements, even if the actual resrouces are external 47 to DaCHS). resType can be registry, organization, authority, 48 deleted, or anything else for which registry.builders has a 49 handling class. 50 - title 51 - subject(s) 52 - description 53 - referenceURL 54 - creationDate 55 56 Additional meta keys (e.g., accessURL for a registry) may be required 57 depending on resType. See the registry section in the operator's guide. 58 59 ResRecs can also have publication children. These will be turned into 60 the appropriate capabilities depending on the value of the render 61 attribute. 62 """ 63 name_ = "resRec" 64 _rd = rscdef.RDAttribute() 65 66 _publications = base.StructListAttribute("publications", 67 childFactory=svcs.Publication, 68 description="Capabilities the record should have (this is empty" 69 " for standards, organisations, instruments, etc.)") 70
71 - def getPublicationsForSet(self, names):
72 """returns publications for set names in names. 73 74 names must be a python set. 75 """ 76 for pub in self.publications: 77 if pub.sets&names: 78 yield pub
79 80
81 -class _FakeRD(object):
82 - def __init__(self, id):
83 self.sourceId = id
84 85
86 -class DeletedResource(common.DateUpdatedMixin, NonServiceResource):
87 """a remainder of a deleted resource. These are always built from information 88 in the database, since that is the only place they are remembered. 89 """ 90 resType = "deleted" 91 92 _resTuple = base.RawAttribute("resTuple") 93
94 - def _meta_status(self):
95 return "deleted"
96
97 - def _meta_recTimestamp(self):
98 return utils.formatISODT(self.resTuple["recTimestamp"])
99
100 - def _meta_identifier(self):
101 return self.resTuple["ivoid"]
102
103 - def completeElement(self, ctx):
104 self._completeElementNext(DeletedResource, ctx) 105 self.rd = _FakeRD(self.resTuple["sourceRD"]) 106 self.id = self.resTuple["resId"] 107 self.dateUpdated = self.resTuple["recTimestamp"]
108