Skip to content

Commit

Permalink
Still working through request-receipt/report in CARPs. Maybe look at …
Browse files Browse the repository at this point in the history
…previous work in Caragols?
  • Loading branch information
ndenny committed Nov 18, 2024
1 parent 5bf973a commit 90cd048
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
9 changes: 7 additions & 2 deletions lib/Bastion/CARP.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(self, request, status, obj, context = None, **kwargs):
if not isinstance(status, ReplyStatus):
raise ValueError("status must be of type ReplyStatus")

self.ID = kwargs.get('ID', str(uuid.uuid4()))
self.request = request
self.status = status
self.lede = kwargs.get('lede', status.category)
Expand All @@ -174,6 +175,7 @@ def toJDN(self, **kwargs):

#-- Build result stanza.
result = {
'ID': self.ID,
'status': self.status.code,
'message': self.status.gloss,
'lede': self.lede,
Expand Down Expand Up @@ -209,9 +211,9 @@ class Receipt(isReceipt):


class Report(isReceipt):
def __init__(self, request, status, doc, obj = None, **kwargs):
def __init__(self, request, status, obj = None, **kwargs):
isReceipt.__init__(self, request, status, obj, **kwargs)
self.report = doc
self.report = kwargs.get('report', None)

def toJDN(self, **kwargs):
jdn = isReceipt.toJDN(self, **kwargs)
Expand All @@ -220,7 +222,10 @@ def toJDN(self, **kwargs):


class Request(isRequest):
#-- Subclasses can set their own REPORT.
#-- This is used mostly in the convenience methods: .succeeded, .failed, etc.
REPORT = Report

def succeeded(self, doc, data = None, **kwargs):
return self.REPORT(self, ReplyStatus.Ok, doc, data, **kwargs)

Expand Down
32 changes: 17 additions & 15 deletions lib/Bastion/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,14 @@ def pack(self, asset, basis = None, **kwargs):
* spool is the absolute path to the folder holding the new archive file.
* package is the name of the archive file in the spool folder
"""
self.mover.pack(asset, basis, **kwargs)
self.packer.pack(asset, basis, **kwargs)

def unpack(self, halo, root, **kwargs):
"""
Given a local packed archive object (e.g. .tar, .zip, etc.) at halo,
I unpack the archive into the given (local) root path.
"""
return self.mover.unpack(halo, root, **kwargs)

return self.packer.unpack(halo, root, **kwargs)

def push(self, asset, basis = None, **kwargs):
"""
Expand Down Expand Up @@ -359,18 +358,7 @@ def manifest(self, ark):
raise NotImplementedError


class isMover:
"""
abstract class for file movement in to and out of a specific vault type.
"""
def provision(self, *args):
"""
provision(ark) - ensures that the site, zone, and asset folders exist.
provision(site, zone, asset_name) - an alias for provision(ark)
provision(asset) - given an instance of Asset, provision the necessary site, zone, and asset folders.
"""
raise NotImplementedError

class isPacker:
def pack(self, asset, basis = None, **kwargs):
"""
Given a local asset, I package (.tar, .zip, etc) the asset into my scratch (spool) space.
Expand All @@ -392,6 +380,20 @@ def unpack(self, halo, root, **kwargs):
"""
raise NotImplementedError



class isMover:
"""
abstract class for file movement in to and out of a specific vault type.
"""
def provision(self, *args):
"""
provision(ark) - ensures that the site, zone, and asset folders exist.
provision(site, zone, asset_name) - an alias for provision(ark)
provision(asset) - given an instance of Asset, provision the necessary site, zone, and asset folders.
"""
raise NotImplementedError

def push(self, asset, basis = None, **kwargs):
"""
Given an asset, I push a backup of the asset to this vault.
Expand Down
1 change: 1 addition & 0 deletions lib/Bastion/Movers/CARP.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class PackRequest(Request):
REPORT = PackReport

def __init__(self, asset, spooled, basis = None, **kwargs):
Request.__init__(self, kwargs.get("action", "pack"))

Expand Down

0 comments on commit 90cd048

Please sign in to comment.