Branch: Tag:

2019-09-16

2019-09-16 10:35:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Variable: Move variables using DBManager to separate files.

The DBManager must not be loaded too early, as loading of it has major
side-effects, and too early load may cause Roxen to fail to start.

Fixes [WS-532].

1: - // $Id: module.pmod,v 1.114 2009/06/24 09:33:31 jonasw Exp $ + // $Id$      #include <module.h>   #include <roxen.h>
1326:    }   }    - class TableChoice - { -  inherit StringChoice; -  constant type = "TableChoice"; -  Variable db; -  -  array(string) get_choice_list( ) -  { -  return sort(DBManager.db_tables( db->query() )); -  } -  -  void create( string default_value, -  void|int flags, -  void|LocaleString std_name, -  void|LocaleString std_doc, -  Variable _dbchoice ) -  { -  ::create( default_value, ({}), flags, std_name, std_doc ); -  db = _dbchoice; -  } - } -  -  - class DatabaseChoice - //! Select a database from all available databases. - { -  inherit StringChoice; -  constant type = "DatabaseChoice"; -  -  function(void:void|object) config = lambda() { return 0; }; -  -  DatabaseChoice set_configuration_pointer( function(void:object) configuration ) -  //! Provide a function that returns a configuration object, -  //! that will be used for authentication against the database -  //! manager. Typically called as -  //! @expr{set_configuration_pointer(my_configuration)@}. -  { -  config = configuration; -  return this_object(); -  } -  -  array get_choice_list( ) -  { -  if (!functionp(config)) { -  // Some modules apparently send in a configration reference instead of -  // a function pointer when calling set_configuration_pointer(). -  report_warning("Incorrect usage of Variable.DatabaseChoice:\n\n%s", -  describe_backtrace(backtrace())); -  return ({ " none" }); -  } -  return ({ " none" }) + sort(DBManager.list( config() )); -  } -  -  protected void create(string default_value, void|int flags, -  void|LocaleString std_name, void|LocaleString std_doc) -  { -  ::create( default_value, ({}), flags, std_name, std_doc ); -  } - } -  +    class AuthMethodChoice   {    inherit StringChoice;