session.param in template toolkit. How is this set?

23 views
Skip to first unread message

Joseph Carlson

unread,
May 5, 2020, 5:54:29 PM5/5/20
to biomart-users
Hello,

Basic question about the template toolkit. (I am not a user of this.) The background is that I'd like to have a filter turned on by default in the martview page. I see the code in filtercollection.tt:

[% filtercollection_paramname = "\${param_prefix}filtercollection." _ filtercollection.name %]
  <input type="checkbox" name="[% filtercollection_paramname %]" value="on"
[* IF session.param("[% filtercollection_paramname %]") == 'on' *]
checked="checked"
[* END *]

which looks like the hook I want to take advantage of. But, my question is how is session.param configured?

Thanks,
Joe

Syed Haider

unread,
May 6, 2020, 4:50:45 PM5/6/20
to Joseph Carlson, biomart-users
Hi Joe,

This should work. session keeps track of which attributes and filters are selected, so this should be automatically added to session. One way to test if its working is to press XML or Perl button after loading MartView. API query should reflect the default selected filter. You may also want to check if you can set this behaviour (default selection of filter) through MartEditor.

Best
Syed


--
You received this message because you are subscribed to the Google Groups "biomart-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biomart-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/biomart-users/f839f3f1-7635-4e1c-b678-ba8ec9e41d55%40googlegroups.com.


--
<font color="green">Please consider environment before you print this!</font>

Joseph Carlson

unread,
May 15, 2020, 11:21:27 AM5/15/20
to biomart-users
Hi Syed,

I've made a bit of progress in my quest here. I was unable to set anything with marteditor that set a filter on by default. But it was a minor mod to Web.pm that allowed me to do it. When creating a new session, I set a session param for the filtercollection to be 'on' if any of the associated filters in the collection had defaultOn set:

  if($session->is_new()) {
      #### If the URL string does not contain a session ID or an inexistent session ID then a
      #### new session gets created and stored and script returns with out doing anything.
      #### Then comes back again and tries to restore this session ID,
      #### and this time around, finds it and restores it. weirdoooo

      #### We will turn on any filter collection if one of the filters has defaultOn set.
      foreach my $vs (@{$self->get_mart_registry->getAllVirtualSchemas}) {
         foreach my $mt (@{$vs->getAllMarts()}) {
            foreach my $ds (@{$mt->getAllDatasets()}) {
               foreach my $ct (@{$ds->getAllConfigurationTrees()}) {
                  foreach my $ft (@{$ct->getAllFilterTrees()}) {
                     foreach my $gp (@{$ft->getAllFilterGroups()}) {
                        foreach my $cl (@{$gp->getAllCollections()}) {
                           foreach my $fi (@{$cl->getAllFilters()}) {
                              if ($fi->defaultOn) {
                                $session->param($ds->name.'__filtercollection.'.$cl->name,'on');
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }

this almost worked. I also needed to comment out some code in save_session:

   # added this as now turned off checkboxes have no CGI param rather
   # than value = "off" to save on the huge CGI object having to be sent
   # across from client browser for every attribute and filter

   my %session_hashref = %{$session->param_hashref()};
   foreach my $param_name (keys %session_hashref){
       if (($session->param($param_name) and $session->param($param_name) eq 'on') &&
      !($cgi->param($param_name))){
      $session->param($param_name,'off');
       }
   }

I wanted to ask about the thinking behind this block. (I know: it's hard for me to remember why I put some things in code last week. Forget about something as old as this.)
Was the thinking to remove some clutter in session parameters? The comment seems to hint that the problem lies in session parameters set to 'off' yet the code works with parameters set to 'on'.

Or was there some other implications that required this?

Thanks again,
Joe

On Wednesday, May 6, 2020 at 1:50:45 PM UTC-7, Syed Haider wrote:
Hi Joe,

This should work. session keeps track of which attributes and filters are selected, so this should be automatically added to session. One way to test if its working is to press XML or Perl button after loading MartView. API query should reflect the default selected filter. You may also want to check if you can set this behaviour (default selection of filter) through MartEditor.

Best
Syed


On Tue, 5 May 2020 at 22:54, Joseph Carlson <jwca...@lbl.gov> wrote:
Hello,

Basic question about the template toolkit. (I am not a user of this.) The background is that I'd like to have a filter turned on by default in the martview page. I see the code in filtercollection.tt:

[% filtercollection_paramname = "\${param_prefix}filtercollection." _ filtercollection.name %]
  <input type="checkbox" name="[% filtercollection_paramname %]" value="on"
[* IF session.param("[% filtercollection_paramname %]") == 'on' *]
checked="checked"
[* END *]

which looks like the hook I want to take advantage of. But, my question is how is session.param configured?

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "biomart-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biomar...@googlegroups.com.

Joseph Carlson

unread,
May 19, 2020, 2:10:42 PM5/19/20
to biomart-users
A minor correction: The previous code did result in the martview page showing the filter was checked on, but the filter was not applied when doing a query. It turns out one more line of code was needed:
      #### We will turn on any filter collection if one of the filters has defaultOn set.
      foreach my $vs (@{$self->get_mart_registry->getAllVirtualSchemas}) {
         foreach my $mt (@{$vs->getAllMarts()}) {
            foreach my $ds (@{$mt->getAllDatasets()}) {
               foreach my $ct (@{$ds->getAllConfigurationTrees()}) {
                  foreach my $ft (@{$ct->getAllFilterTrees()}) {
                     foreach my $gp (@{$ft->getAllFilterGroups()}) {
                        foreach my $cl (@{$gp->getAllCollections()}) {
                           foreach my $fi (@{$cl->getAllFilters()}) {
                              if ($fi->defaultOn) {
                                $session->param($ds->name.'__filtercollections',$ds->name.'__filtercollection.'.$cl->name);

Syed Haider

unread,
May 19, 2020, 3:12:54 PM5/19/20
to Joseph Carlson, biomart-users
Hi Joseph,

thanks for relaying this back to the community, I am certain others will benefit from this. 

RE your question on why the implementation is rather busy with code; I think (relying on not-so-good memory as this was implemented back in 2008ish) it was meant to cover additional filter types. Some of these were specialised filters focused on specific BioMarts, and others although part of design, never got implemented.

Best wishes,
Syed




To unsubscribe from this group and stop receiving emails from it, send an email to biomart-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/biomart-users/2690060d-47e0-4617-9a88-7f35a5e8d0f7%40googlegroups.com.

Joseph Carlson

unread,
May 19, 2020, 5:59:34 PM5/19/20
to biomart-users
Hi Syed,

Again, thanks for your work and I hope I'm not taxing your long term memory too much. I understand all of this is from a long time ago.

I was also wondering about PushActions. I've been going through the code and thinking that this would be something that I'd like to use but have been so unsuccessful when implementing it.

By way of background, what we want to do is to have a column in the main table which flags data as being under Ft. Lauderdale standards or unrestricted. I wanted to have the filter on by default so that people would see unrestricted data only by default, but could see restricted data after taking the action unchecking the filter button. That part works now. But the next step would be to change a different filter select menu so that when the restriction filter is selected, only a subset of the options are presented. The select menu would be updated if the filter is turned off. From the looks of it the PushAction see to be the hook I want to use but I cannot figure it out.

I'm looking at the marteditor code and there seems to be a typo that causes an array index out of bounds when I try to add a push action in it. (want to see details?) I was wondering if this was another design feature that did not get implemented or if there is a workaround to using it?

Thanks,
Joe

Joseph Carlson

unread,
May 22, 2020, 12:34:33 PM5/22/20
to biomart-users
<sheepishly> Never mind. I figured out PushActions </sheepishly>

I ended up constructing the config xml by hand and inserting it. Am happy.

There are still some issues with PushActions in the marteditor, but I'm not needing that anymore.

Joe

Syed Haider

unread,
May 22, 2020, 12:54:17 PM5/22/20
to Joseph Carlson, biomart-users
Hi Joseph,

Glad it worked out for you. The only other advice I may have on this is to read (reverse engineer features) by loading Ensembl's config in marteditor (this would certainly require increasing the java memory requirements -Xms, -Xmx in marteditor.sh). Ensembl's MySQL server is publicly available on:
port: 5316
mart: ensembl_mart_98
schema: ensembl_mart_98
user: anonymous
password: "leave it blank".

You can relate the marteditor configuration for push actions to how they appear on ensembl's biomart web interface (martview).

Hope this is useful.

Best,
Syed


To unsubscribe from this group and stop receiving emails from it, send an email to biomart-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/biomart-users/cd4c67d7-723b-48d4-91dc-16c46664d2a3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages