Opened 17 years ago
Closed 17 years ago
#6 closed enhancement (fixed)
register name-lookup services at runtime
Reported by: | Brian Warner | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 0.1.5 |
Component: | unknown | Version: | 0.1.4 |
Keywords: | Cc: |
Description
For a couple of allmydata.org purposes, it would be nice to be able to get more control over the name-to-Referenceable mapping. In particular, we have one service which uses unguessable names to refer to objects ("directory nodes", in this case) that are persisted on disk. We don't want to have to scan through all the files on disk ahead of time, doing a Tub.registerReference() on each one. Instead, we publish a single well-known "manager" FURL, and all operations take one of these unguessable names as a first argument.
It would be cleaner if we could instead use the unguessable name directly. To do this, we'd need to be able to tell the Tub that any !getYourReferenceByName requests that aren't in the Tub's table should be handed to an external lookup function. Our code would then register a handler for this function that would look on disk for the desired name.
Something like:
def getName(name): assert "/" not in name; assert ".." not in name filename = os.path.join(basedir, name) if os.path.exists(filename): return create_referenceable_object(filename) else: return None tub.registerLookupHandler(getName)
Done, in [0d3d0b97acff997f8419c8883b0a009b46a8daee].