unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jeremiah Dodds <jeremiah.dodds@gmail.com>
To: Emacs Help <help-gnu-emacs@gnu.org>
Subject: Looking for some general approaches to problems I'm having writing an elisp library
Date: Thu, 25 Oct 2012 18:33:49 -0400	[thread overview]
Message-ID: <87ip9ygp0y.fsf@friendface.i-did-not-set--mail-host-address--so-tickle-me> (raw)


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



                 reply	other threads:[~2012-10-25 22:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ip9ygp0y.fsf@friendface.i-did-not-set--mail-host-address--so-tickle-me \
    --to=jeremiah.dodds@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).