[Gmod-tripal-devel] Tripal/Chado Access Control

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-tripal-devel] Tripal/Chado Access Control

Kucheran, Lacey Sanderson
Since there was a lot of discussion during the Tripal Developer meeting about access control and chado, I thought it might be a good idea to start an feature request issue on this topic: https://www.drupal.org/node/2352859. Anyone in the community interested in this functionality please chime in! It would be really helpful to see how widespread this need is and hear everyones individual use cases to make sure we come up with as widely applicable a design as possible :)

Nelson: I would particularly appreciate it if you could add your use case & needs to the issue.
Valentin: Could you discuss what your motivation for the chado control is and what functionality you might need to be able to use any new module?

I actually have some ideas of my own about how this might be able to be implemented so I'll chime in with those after everyone comments just to make sure I understand everyones needs fully :)

Thanks!
~Lacey

------------------------------------------------------
Lacey-Anne Sanderson
Bioinformaticist
Pulse Crop Breeding and Genetics
Phone: (306) 966-3208
Room 2C33 Agriculture
Department of Plant Sciences
University of Saskatchewan


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Tripal/Chado Access Control

Nelson Nazzicari


On Wed, Oct 8, 2014 at 6:09 PM, Lacey-Anne Sanderson <[hidden email]> wrote:
Nelson: I would particularly appreciate it if you could add your use case & needs to the issue.
Sure :)

I have phenotype and genotype data. Let's talk phenotypes, but genotype is similar.
I use nd_module to link phenotype in this way

stock (cultivar)
     |
     | (clone_of)
     |
stock (tree)
     |
     |
nd_experiment
   / | \
all phenotypes collected on a specific date

I would like to label nd_experiment and separate them in "datasets". I can then have
  • project-members-only datasets (accessible to all members of a short list)
  • public datasets (everybody can access it)
  • mixed situation, where datasets are accessible to only certain users

I always envisioned my access rules as a table: columns are dataset, rows are users, cell contains a YES/NO to specify access.

Ideally a dataset should be able to contain different types of data (phenotypes, genotypes and so forth). If I were going to implement all by myself, I would create a special type of prop, used to specify that a specific bit of information is part of a specific dataset. Since we already have a prop in chado for (almost) everything, this solution would integrate nicely without changing the schema.







------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Tripal/Chado Access Control

Guignon, Valentin (Bioversity-France)
In reply to this post by Kucheran, Lacey Sanderson

Hi Lacey,

 

Long mail warning: skip parts you don’t need… ;-)

 

 

[CHADO CONTROLLER (in few words)]

 

The CHADO Controller was designed (before Tripal was out) to solve 3 issues:

1)      Manage access rights (hide/read only/read-write) to gene annotations based on either user login or user group

2)      Manage manual annotations and report obvious mistakes (missing start/stop codons, annotation concistency,…) to annotators

3)      Manage annotation history to keep track of changes

 

The CHADO Controller is embedded into PostgreSQL inside the chado schema as triggers, functions, views, rules and some additional tables. One of the goals was to keep backward compatibility with existing GMDO tools. Another goal was to allow administrators to choose which parts of the CHADO Controller they want. So basically, you can setup any part of the CHADO Controller you need/want on you existing database and still use tools like Tripal without any problem… that’s the idea but there are some uses cases that may not work as expected unfortunately (but there are always solutions!).

 

 

[ACCESS MANAGEMENT]

 

It only restricts access to the feature table. Access can be granted at a single feature level but to simplify management, the admin interface setups access rights on a scaffold/contig basis. However, admin can provide an SQL query that returns a set of feature_id to manage their access specifically.

There are 3 access levels: no access (default), read and read-write. These accesses can be granted to users or groups. A user can belong to 0, 1 or more groups and its rights on a given feature are computed using the highest access she/he has form her/his account or her/his groups.

 

Use case example: I have a new scaffold and I want it to be private even if it’s on a public database where other scaffolds are public. John can annotate it and the group “reviewers” can view it but not edit it. I have a GBrowse on that database using the plugin I made for the CHADO Controller. Any anonymous user won’t see the private scaffold. Users with an account that are not John or a “reviewer” won’t see the scaffold either. John can connect to the GBrowse site with his login and then use a provided link to launch Artemis and edit the gene. People from the reviewers group can connect to GBrowse or Artemis the same way and see the private scaffold. However, if they try to commit changes on Artemis, they will have an error message telling them it’s not allowed.

That’s the basic idea but you can imagine many other use cases of different teams working on different parts of a same genome, or several genomes on a same database,...

 

 

[ANNOTATION INSPECTOR]

 

The annotation inspector is a PostgreSQL function that launches several other PostgreSQL procedures on a given PostgreSQL transaction to check database modification and reports errors or flag what’s wrong. By “transaction” I mean an SQL transaction, that is for instance from the moment you start Artemis to the moment you click on the “commit” button. However, it can also work without transactions but I won’t explain it here. The inspector finds what has been modified and launch several check functions and each of them will provide a report that will be then displayed to the user. There are functions to check the gene structure (codons, length, gene-mrna-exon-protein-utr, repeats,…), to check the consistency (if such property is set, then there shouldn’t be or should such other property or dbxref,…), and also functions to automate some tasks like setting the gene owner to current annotator and the gene color according to its annotation state (never edited, in progress, finished).

 

The annotation inspector can be used with Artemis or Apollo: I made patches/plugins in order to have them call the inspector on commit and display the annotation report. The annotator can then choose either go back to fix the issues or ignore the report and commit anyway. In that last case, the inspector can automatically add some properties to the annotated feature like “missing stop codon” or such.

 

The annotation inspector only requires the annotation history module to be installed in order to see what has been changed.

 

 

[ANNOTATION HISTORY]

 

This (sub)module is based on the CHADO Audit module with some changes in order to know who did what, when and during which transaction. This module is required by the annotation inspector in order to see what has been changed.

 

 

[LINK WITH TRIPAL]

 

The CHADO Controller can seem quite complicated to setup… well, it is complicated to setup. I wrote a PERL script for that but it is still not very friendly. The admin interface to manage rights is also quite horrible! …and not friendly either. And I’m not talking about the inspector management interface which does not exist! J (ie.: you have to add/remove/enable/disable functions manually in the database by setting the appropriate entries in a specific table used by the inspector) And also the annotation history is not very nice.

 

Using Tripal could solve these issues with not a lot of development efforts. That’s why we are thinking of a student internship for that. But “we” (Gaetan and I) are working on other projects and we need to find time to follow a student.

 

The annotation history part is the easiest part to do as it requires almost no development! We only need to add custom tables to Tripal CHADO schema and some pre-built views on them and that’s pretty much it.

The annotation inspector could also be easily interfaced by providing a page to enable/disable check functions and many also a way to add new ones. What about adding a page to run inspector checks on a given set of genes? I don’t know yet. We have to think about it. It can be long to run, maybe as a job? Dunno.

The access restriction management would require more work but it’s feasible.

The biggest part would be the installation/removal part as there might be some tricks.

 

 

[RELATED TO OUR DISCUSSION]

 

I talked about the CHADO Controller because we were talking about access restriction on a CHADO database. Since the CHADO controller is embedded inside CHADO, it can restrict accesses from any end user interface (Tripal, Apollo, Artemis, GBrowse,…). But there are 2 points to raise: 1) right now, it works on the feature table only; 2) for some technical aspects, the “feature” table to protect is replaced by a “feature” view and the original table becomes named “feature_data” and only the database admin account can directly query that table and other users must have their own database account.

 

About point 1): the idea used on the feature table can be applied to any other table (stock, phenotypes, experiments,…). We just need something that can generate the appropriate views, rules and triggers.

 

About point 2): changing a table into a view can break some third party software that expect a table and not a view (I thinking about Java hibernate and also the COPY PostgreSQL query). To partially solve that, I added a function that can temporarily rename the view and the table while the third party software is running. But at the time I designed that thing, I didn’t’ know much about the “search_path” PostgreSQL variable and now, I think there might be nicer way to design that thing using additional schemas… so far, it’s just a though. :-p

 

 

[CONCLUSION]

 

Solving access issue is not trivial and there are many things to take into account otherwise it won’t be generic enough or not take in account some uses cases or even not really protect the data! The CHADO Controller approach solves the access issue (for features) but have several drawbacks: hard to setup and manage, should be extended to other tables, and it safely protects you data from any software but it might break some third party tools (ie. Even people directly connecting to the database though their postgreSQL client to issue custom queries will only access to what they are allowed to but if you want to use gmod_bulk_load that uses the COPY command, then you’ll have to either use a patched version of gmod_bulk_load that uses “feature_data” instead of “feature” or put the access restriction in “compatibility mode” during the database loading, which will block access from other software like GBrowse to the database while loading).

 

Sorry for quite a long mail but it’s kind of hard to explain all of that in a few sentences and I even didn’t get much into details… Anyway, feel free to contact me if you need details on some aspects.

Regards,

 

   Val

 

 

 

From: Lacey-Anne Sanderson [mailto:[hidden email]]
Sent: mercredi 8 octobre 2014 18:09
To: GMOD Tripal; gmod tripal devel
Cc: Nelson Nazzicari; Guignon, Valentin (Bioversity-France)
Subject: Tripal/Chado Access Control

 

Since there was a lot of discussion during the Tripal Developer meeting about access control and chado, I thought it might be a good idea to start an feature request issue on this topic: https://www.drupal.org/node/2352859. Anyone in the community interested in this functionality please chime in! It would be really helpful to see how widespread this need is and hear everyones individual use cases to make sure we come up with as widely applicable a design as possible :)

 

Nelson: I would particularly appreciate it if you could add your use case & needs to the issue.

Valentin: Could you discuss what your motivation for the chado control is and what functionality you might need to be able to use any new module?

 

I actually have some ideas of my own about how this might be able to be implemented so I'll chime in with those after everyone comments just to make sure I understand everyones needs fully :)

 

Thanks!

~Lacey

 

------------------------------------------------------

Lacey-Anne Sanderson

Bioinformaticist

Pulse Crop Breeding and Genetics

Phone: (306) 966-3208

Email: [hidden email]

Room 2C33 Agriculture

Department of Plant Sciences

University of Saskatchewan

 


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

[Gmod-tripal-devel] Question about multiple databases

Guignon, Valentin (Bioversity-France)

Hi there !

 

I’m currently implementing a new extension module for Tripal that I will call "Tripal Multi-Chado" (it will be put and drupal.org) and the purpose of that module will be to allow admins to manage several Chado database connections in a same Tripal site.

By the way, if someone would like to know more about this "Tripal Multi-Chado" module, let me know.

 

I need to change the way Tripal "chado_set_active()" works but I need some clarifications from your (Lacey and/or Stephen) side…

 

Currently I see this code:

----------

function chado_set_active($dbname  = 'default') {

  global $databases, $active_db;

 

  if ($dbname ) {

    if ($dbname == 'chado') {

      db_query('set search_path to chado,public');

      return 'default';

    }

    else {

      db_query('set search_path to public');

      return 'chado';

    }

  }

  // if the 'chado' database is in the $db_url variable then chado is

  // not in the same Drupal database, so we don't need to set any

  // search_path and can just change the database

  elseif (array_key_exists($dbname, $databases)) {

    return db_set_active($dbname);

  }

}

----------

 

And I only see one case in which we can reach the last "elseif (array_key_exists($dbname, $databases))", it’s when the $dbname is set to a false-value and then, it means $database which is set in settings.php has that "false" key defined.

Since I may have missed some use case, could you confirm that this last elseif is useless now (since we should not have any $db_url anymore in our Drupal 7 settings)?

 

I also noticed that in some cases, that function could return no value (if $dbname is set to FALSE, 0, 0.0, '', array(),… and the $databases does not have such key).

And finally, how I understand it, this function should only allow 2 values for $dbname: 'public' or 'chado'.

 

 

So here is how I would like chado_set_active() to be (with a hook__alter):

----------

function chado_set_active($dbname = 'default') {

 

  // check if the chado_active_db has been set yet

  if (!array_key_exists('chado_active_db', $GLOBALS)) {

    $GLOBALS['chado_active_db'] = 'default';

  }

 

  $active_db = $GLOBALS['chado_active_db'];

  $search_path = 'public';

 

  // change only if 'chado' has been specified

  if ($dbname == 'chado') {

    $active_db = 'chado';

    $search_path = 'chado,public';

  }

 

  $parameters = array(

    'dbname'          => $dbname,

    'new_active_db'   => &$active_db,

    'new_search_path' => &$search_path,

  );

 

  // will call all modules implementing hook_chado_search_path_alter

  drupal_alter('chado_search_path', $parameters);

 

  // set chado_active_db

  $GLOBALS['chado_active_db'] = $active_db;

 

  // set PostgreSQL search_path

  db_query('SET search_path TO ' . $search_path);

 

  return $previous_db;

}

----------

 

This would allow contributed modules to alter the search_path but also the current connection (for instance connect on the same database and chado but using a different user account with specific access rights). What do you think?

Cheers,

 

   Val

 

 

 


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Question about multiple databases

Stephen Ficklin-2
HI Valentin,

Sorry for the slow response. I've been out of the office a few days.  We have discussed in the past the desire to host multiple Chado databases, but have not yet dealt with it in the Tripal code.  I see you have also added a patch here:  https://www.drupal.org/node/2341657

I'll look through the patch and see how it will affect things. I'll post my response on the issue at the link above.  So, anyone interested in this topic and follow that issue for updates.

Thanks for the contribution.

Stephen

On 2/20/2015 11:10 AM, Guignon, Valentin (Bioversity-France) wrote:

Hi there !

 

I’m currently implementing a new extension module for Tripal that I will call "Tripal Multi-Chado" (it will be put and drupal.org) and the purpose of that module will be to allow admins to manage several Chado database connections in a same Tripal site.

By the way, if someone would like to know more about this "Tripal Multi-Chado" module, let me know.

 

I need to change the way Tripal "chado_set_active()" works but I need some clarifications from your (Lacey and/or Stephen) side…

 

Currently I see this code:

----------

function chado_set_active($dbname  = 'default') {

  global $databases, $active_db;

 

  if ($dbname ) {

    if ($dbname == 'chado') {

      db_query('set search_path to chado,public');

      return 'default';

    }

    else {

      db_query('set search_path to public');

      return 'chado';

    }

  }

  // if the 'chado' database is in the $db_url variable then chado is

  // not in the same Drupal database, so we don't need to set any

  // search_path and can just change the database

  elseif (array_key_exists($dbname, $databases)) {

    return db_set_active($dbname);

  }

}

----------

 

And I only see one case in which we can reach the last "elseif (array_key_exists($dbname, $databases))", it’s when the $dbname is set to a false-value and then, it means $database which is set in settings.php has that "false" key defined.

Since I may have missed some use case, could you confirm that this last elseif is useless now (since we should not have any $db_url anymore in our Drupal 7 settings)?

 

I also noticed that in some cases, that function could return no value (if $dbname is set to FALSE, 0, 0.0, '', array(),… and the $databases does not have such key).

And finally, how I understand it, this function should only allow 2 values for $dbname: 'public' or 'chado'.

 

 

So here is how I would like chado_set_active() to be (with a hook__alter):

----------

function chado_set_active($dbname = 'default') {

 

  // check if the chado_active_db has been set yet

  if (!array_key_exists('chado_active_db', $GLOBALS)) {

    $GLOBALS['chado_active_db'] = 'default';

  }

 

  $active_db = $GLOBALS['chado_active_db'];

  $search_path = 'public';

 

  // change only if 'chado' has been specified

  if ($dbname == 'chado') {

    $active_db = 'chado';

    $search_path = 'chado,public';

  }

 

  $parameters = array(

    'dbname'          => $dbname,

    'new_active_db'   => &$active_db,

    'new_search_path' => &$search_path,

  );

 

  // will call all modules implementing hook_chado_search_path_alter

  drupal_alter('chado_search_path', $parameters);

 

  // set chado_active_db

  $GLOBALS['chado_active_db'] = $active_db;

 

  // set PostgreSQL search_path

  db_query('SET search_path TO ' . $search_path);

 

  return $previous_db;

}

----------

 

This would allow contributed modules to alter the search_path but also the current connection (for instance connect on the same database and chado but using a different user account with specific access rights). What do you think?

Cheers,

 

   Val

 

 

 



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk


_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Question about multiple databases

Guignon, Valentin (Bioversity-France)

Hi there !

 

I just need an update on the status of the patch I proposed a couple of month ago that would allow me to create the tripal-multi-chado module. Do you plan to include it in Tripal sooner or later?

 

I’m working on the multi-chado module right now but it would make no sense if Tripal does not offer natively the hook I proposed. People would have to patch their Tripal instance to use this extension…

 

Please let me know what your plans are! J

Thanks,

 

   Val

 

 

 

From: Stephen Ficklin [mailto:[hidden email]]
Sent: lundi 23 février 2015 17:53
To: [hidden email]
Subject: Re: [Gmod-tripal-devel] Question about multiple databases

 

HI Valentin,

Sorry for the slow response. I've been out of the office a few days.  We have discussed in the past the desire to host multiple Chado databases, but have not yet dealt with it in the Tripal code.  I see you have also added a patch here:  https://www.drupal.org/node/2341657

I'll look through the patch and see how it will affect things. I'll post my response on the issue at the link above.  So, anyone interested in this topic and follow that issue for updates.

Thanks for the contribution.

Stephen

On 2/20/2015 11:10 AM, Guignon, Valentin (Bioversity-France) wrote:

Hi there !

 

I’m currently implementing a new extension module for Tripal that I will call "Tripal Multi-Chado" (it will be put and drupal.org) and the purpose of that module will be to allow admins to manage several Chado database connections in a same Tripal site.

By the way, if someone would like to know more about this "Tripal Multi-Chado" module, let me know.

 

I need to change the way Tripal "chado_set_active()" works but I need some clarifications from your (Lacey and/or Stephen) side…

 

Currently I see this code:

----------

function chado_set_active($dbname  = 'default') {

  global $databases, $active_db;

 

  if ($dbname ) {

    if ($dbname == 'chado') {

      db_query('set search_path to chado,public');

      return 'default';

    }

    else {

      db_query('set search_path to public');

      return 'chado';

    }

  }

  // if the 'chado' database is in the $db_url variable then chado is

  // not in the same Drupal database, so we don't need to set any

  // search_path and can just change the database

  elseif (array_key_exists($dbname, $databases)) {

    return db_set_active($dbname);

  }

}

----------

 

And I only see one case in which we can reach the last "elseif (array_key_exists($dbname, $databases))", it’s when the $dbname is set to a false-value and then, it means $database which is set in settings.php has that "false" key defined.

Since I may have missed some use case, could you confirm that this last elseif is useless now (since we should not have any $db_url anymore in our Drupal 7 settings)?

 

I also noticed that in some cases, that function could return no value (if $dbname is set to FALSE, 0, 0.0, '', array(),… and the $databases does not have such key).

And finally, how I understand it, this function should only allow 2 values for $dbname: 'public' or 'chado'.

 

 

So here is how I would like chado_set_active() to be (with a hook__alter):

----------

function chado_set_active($dbname = 'default') {

 

  // check if the chado_active_db has been set yet

  if (!array_key_exists('chado_active_db', $GLOBALS)) {

    $GLOBALS['chado_active_db'] = 'default';

  }

 

  $active_db = $GLOBALS['chado_active_db'];

  $search_path = 'public';

 

  // change only if 'chado' has been specified

  if ($dbname == 'chado') {

    $active_db = 'chado';

    $search_path = 'chado,public';

  }

 

  $parameters = array(

    'dbname'          => $dbname,

    'new_active_db'   => &$active_db,

    'new_search_path' => &$search_path,

  );

 

  // will call all modules implementing hook_chado_search_path_alter

  drupal_alter('chado_search_path', $parameters);

 

  // set chado_active_db

  $GLOBALS['chado_active_db'] = $active_db;

 

  // set PostgreSQL search_path

  db_query('SET search_path TO ' . $search_path);

 

  return $previous_db;

}

----------

 

This would allow contributed modules to alter the search_path but also the current connection (for instance connect on the same database and chado but using a different user account with specific access rights). What do you think?

Cheers,

 

   Val

 

 

 




------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk




_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel

 


------------------------------------------------------------------------------

_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] Question about multiple databases

Stephen Ficklin-2
Hi Valentin,

Thanks for re-raising the issue.  I've added a comment to the issue thread related to the multi-chado support.  I think we can accommodate some changes to support multiple chado instances, but since the patched function is so critical I just want to make sure we get it right.

See comment here: https://www.drupal.org/node/2341657

Thanks,
Stephen

On 15-08-26 05:53 AM, Guignon, Valentin (Bioversity-France) wrote:

Hi there !

 

I just need an update on the status of the patch I proposed a couple of month ago that would allow me to create the tripal-multi-chado module. Do you plan to include it in Tripal sooner or later?

 

I’m working on the multi-chado module right now but it would make no sense if Tripal does not offer natively the hook I proposed. People would have to patch their Tripal instance to use this extension…

 

Please let me know what your plans are! J

Thanks,

 

   Val

 

 

 

From: Stephen Ficklin [[hidden email]]
Sent: lundi 23 février 2015 17:53
To: [hidden email]
Subject: Re: [Gmod-tripal-devel] Question about multiple databases

 

HI Valentin,

Sorry for the slow response. I've been out of the office a few days.  We have discussed in the past the desire to host multiple Chado databases, but have not yet dealt with it in the Tripal code.  I see you have also added a patch here:  https://www.drupal.org/node/2341657

I'll look through the patch and see how it will affect things. I'll post my response on the issue at the link above.  So, anyone interested in this topic and follow that issue for updates.

Thanks for the contribution.

Stephen

On 2/20/2015 11:10 AM, Guignon, Valentin (Bioversity-France) wrote:

Hi there !

 

I’m currently implementing a new extension module for Tripal that I will call "Tripal Multi-Chado" (it will be put and drupal.org) and the purpose of that module will be to allow admins to manage several Chado database connections in a same Tripal site.

By the way, if someone would like to know more about this "Tripal Multi-Chado" module, let me know.

 

I need to change the way Tripal "chado_set_active()" works but I need some clarifications from your (Lacey and/or Stephen) side…

 

Currently I see this code:

----------

function chado_set_active($dbname  = 'default') {

  global $databases, $active_db;

 

  if ($dbname ) {

    if ($dbname == 'chado') {

      db_query('set search_path to chado,public');

      return 'default';

    }

    else {

      db_query('set search_path to public');

      return 'chado';

    }

  }

  // if the 'chado' database is in the $db_url variable then chado is

  // not in the same Drupal database, so we don't need to set any

  // search_path and can just change the database

  elseif (array_key_exists($dbname, $databases)) {

    return db_set_active($dbname);

  }

}

----------

 

And I only see one case in which we can reach the last "elseif (array_key_exists($dbname, $databases))", it’s when the $dbname is set to a false-value and then, it means $database which is set in settings.php has that "false" key defined.

Since I may have missed some use case, could you confirm that this last elseif is useless now (since we should not have any $db_url anymore in our Drupal 7 settings)?

 

I also noticed that in some cases, that function could return no value (if $dbname is set to FALSE, 0, 0.0, '', array(),… and the $databases does not have such key).

And finally, how I understand it, this function should only allow 2 values for $dbname: 'public' or 'chado'.

 

 

So here is how I would like chado_set_active() to be (with a hook__alter):

----------

function chado_set_active($dbname = 'default') {

 

  // check if the chado_active_db has been set yet

  if (!array_key_exists('chado_active_db', $GLOBALS)) {

    $GLOBALS['chado_active_db'] = 'default';

  }

 

  $active_db = $GLOBALS['chado_active_db'];

  $search_path = 'public';

 

  // change only if 'chado' has been specified

  if ($dbname == 'chado') {

    $active_db = 'chado';

    $search_path = 'chado,public';

  }

 

  $parameters = array(

    'dbname'          => $dbname,

    'new_active_db'   => &$active_db,

    'new_search_path' => &$search_path,

  );

 

  // will call all modules implementing hook_chado_search_path_alter

  drupal_alter('chado_search_path', $parameters);

 

  // set chado_active_db

  $GLOBALS['chado_active_db'] = $active_db;

 

  // set PostgreSQL search_path

  db_query('SET search_path TO ' . $search_path);

 

  return $previous_db;

}

----------

 

This would allow contributed modules to alter the search_path but also the current connection (for instance connect on the same database and chado but using a different user account with specific access rights). What do you think?

Cheers,

 

   Val

 

 

 




------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk




_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel

 



------------------------------------------------------------------------------

_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel