.

User records

Users in Ensembl

From Release 42 (Dec 2006), users of Ensembl can create new accounts and login to customise their usage of the browser. Ensembl includes a standard way of easily storing and retrieving a user's data, with the EnsEMBL::Web::User::Record module.

Persistent user data

Allowing users to customise views, bookmark pages, record blast tickets and the like, requires a method of making user data persitent. In Ensembl, the EnsEMBL::Web::User::Record class is responsible for saving, loading and modifying data saved by the user. The module can handle multiple types of data, and can store all Perl data types (strings, arrays and hashes) along with blessed objects.

User::Record is automagical

User::Record only has three predetermined parameters, all of which should be set before save is called: Other than these three parameters, User::Record can be used to access any other parameter automatically just by calling a method of the same name on the object. All parameters will be repopulated when the user data is retrieved from the database (typically with a find_by class method call), and can be accessed again, with a method call.

In the bookmark example above, the bookmark name and url are being automatically set via the $record->name and $record->url methods. No additional accessor glue code is required.

Likewise, the find_by method automatically retrieves the record objects based upon the available saved parameters and supplied predicate. Whilst in the example above we return bookmarks by user id, we could also access a specific bookmark record via its own unique identifier:
  sub get_bookmark {
    my ($self, $id) = @_; 
    return EnsEMBL::Web::User::Record->find_bookmark_by_id($id); 
  }
  

Footnotes


 

© 2024 Inserm. Hosted by genouest.org. This product includes software developed by Ensembl.

                
GermOnline based on Ensembl release 50 - Jul 2008
HELP