unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Looking for some general approaches to problems I'm having writing an elisp library
@ 2012-10-25 22:33 Jeremiah Dodds
  0 siblings, 0 replies; only message in thread
From: Jeremiah Dodds @ 2012-10-25 22:33 UTC (permalink / raw)
  To: Emacs Help


I'm writing an elisp library that's meant to be used by other elisp
code. It provides communication with a REST API, the goal is to allow
other packages to talk to the API via relevantly-named function calls,
I'm writing one client package in tandem with the library.

The API requires an authorization token to be passed in order to allow
read access to "private" things, or write access to anything. 

I could use a single auth token for the library itself, but that seems
like a bad idea -- it's more of a middleman than the application
performing operations.

The obvious solution is to store an auth token per client-application,
the issue I'm having is how this should be exposed. I'd like to avoid
forcing client code to be redundant.

Approaches I've thought up:

+ require client code to pass it's name on each request.
+ when a client application becomes known to the library, define
  wrappers for the various api functions. 

I feel like the "right" way to go about this is something like the
second approach, I know this is the type of thing that lisps are fine at
handling, but I'm not familiar enough with elisp to know but what the
appropriate way to handle this is.

Does anyone who breathes elisp have a "best practice" for something like
the following simplified scenario:

Client packages A and B both use library C. C provides a function,
'c-get-some-data' that both A and B would like to
call. 'c-get-some-data' needs to be able to use a value that is specific
to the package calling it, that value is unlikely to change once
set.

How can I make sure that if A and B are both making calls to
'c-get-some-data' that the correct value is being used without resorting
to making the call look like (c-get-some-data "A") or similar? Or does
it sound like I'm thinking about the problem incorrectly?


-- 
Jeremiah Dodds

blog       : http://jdodds.github.com
github     : https://github.com/jdodds
freenode   : exhortatory
twitter    : kaens



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-25 22:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-25 22:33 Looking for some general approaches to problems I'm having writing an elisp library Jeremiah Dodds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).