#3 could be assigned from within the user's .Rprofile via options("dbuser")
or whatever

this is how I have some REST services set up since it's a drag to write
examples otherwise


On Mon, Dec 20, 2010 at 8:35 AM, Sean Davis <sdavis2@mail.nih.gov> wrote:

> On Mon, Dec 20, 2010 at 11:24 AM, Jeff Allen <lists@jdadesign.net> wrote:
>
> > Hello.
> >
> > I'm looking to create an R package which requires a user-specific
> parameter
> > in order to work. To be more descriptive: I'm making a database API
> > available via an R package, but I want to control access to this API by
> > using keys so that I can monitor activity at the user-level and make sure
> no
> > one is abusing the database. So the R package is complete, but I need a
> way
> > for users to specify their key so that it can be included in each call to
> > the API. I'm looking for a way to avoid having the include the API key in
> > every function call, but instead be able to include the key when you
> first
> > attach the package.
> >
> > The functionality I'm looking for would essentially be to be able to pass
> a
> > parameter to a package through the library call. That doesn't seem to be
> > possible, so I'm looking for alternatives that would be user-friendly.
> >
> > I'd appreciate any thoughts!
> >
> >
> Hi, Jeff.
>
> I think the standard way this is usually handled (in multiple languages,
> not
> just R) is to create a connection object (where connection credentials
> would
> be specified) and then use that object in further calls to the db API.  You
> might consider the DBI interface (
> http://cran.r-project.org/web/packages/DBI/index.html) as the basis for
> your
> API.
>
> That said, if you don't choose to use the standard interface, there are a
> number of ways that this type of thing could be done.
>
> 1)  Read a file from the system that contains the information (like .psqlrc
> of .my.cnf file)
> 2)  Read an environment variable or two--these could be set before starting
> R or using R commands to set the environment variable
> 3)  Setting an R option
> 4)  Other, more creative solutions such as reading the username, etc., from
> environment
> 5)  Combinations of the above....
> 6)  There may be others.
>
> All of these except (4) will require the user to specify once per R session
> the information that you need.
>
> Sean
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>



-- 
If people do not believe that mathematics is simple, it is only because they
do not realize how complicated life is.
John von Neumann<http://www-groups.dcs.st-and.ac.uk/~history/Biographies/Von_Neumann.html>

	[[alternative HTML version deleted]]

