More flexibility in ID Generation #923
Replies: 4 comments 1 reply
-
A NOID uses a template and is reproducible via a numeric index. Some things wrt config come to mind:
|
Beta Was this translation helpful? Give feedback.
-
While I am generally a little bit wary of passing the I still think it's probably the best thing to do to allow users the most liberty in how they chose to implement the logic. The implementation can be quite simple I think. Pyramid has a utility method to resolve strings to callables. from pyramid.util import DottedNameResolver
user_setting = "my_package:concept.id_generator"
resolver = DottedNameResolver()
id_generator = resolver.resolve(user_setting)
concept_id = id_generator(request) And since we currently call |
Beta Was this translation helpful? Give feedback.
-
Created #925 to allow configuring a custom id generator. |
Beta Was this translation helpful? Give feedback.
-
TODO: create issue for generating NOID |
Beta Was this translation helpful? Give feedback.
-
Use Case
Currently Atramhasis has three ways of generating a concept id:
Some users would like to have more options. Things like noid (https://metacpan.org/dist/Noid/view/noid) have been mentioned, but there are also usecases where an organisation has a central service for distributing identifiers. Therefore, the best option might be to allow users to specify a custom id generator for a certain conceptscheme. A second option is including the noid algorithm as another option similar to GUID.
It might be possible to have the system call a URI generator, but Atramhasis normally generates the URI by combining the UriGenerator and the local identifier. This would introduce extra complexities though, so for now is considered out of scope as this propasal will make it possible to generate URI's with custom local identifiers.
Implementation
Allow configuring a noid minter
Generating a noid requires some configuration such as a template, scheme and naa. These will need to be entered when configuring the provider. There's a also a Python implementation: https://pypi.org/project/noid/
Allow configuring a custom id generator
By allowing a user to call a custom id generation function, we could provide a lot of flexibility (at the cost of a little bit of coding).
When a provider is configured with this strategy, the SkosManager.get_next_cid method calls a custom method that was passed to the provider in dotted syntax, eg. mythes.idgenerators.spam. This custom method should expect to be passed an environment that can be used for making outbound calls. Ideally this would be the pyramid request, but right now the DataManagers only have access to the SQLAlchemy session. Not sure if this is enough, or if more is needed. If we ever want to have other DataManagers that connect to eg. a SPARQL store as opposed to a SQL database, having the DataManagers receive the request seems like a step in the right direction.
TODO:
Beta Was this translation helpful? Give feedback.
All reactions