[Catalyst] YAML Config
Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt This is a feature of YAML 1.0. But it seems that only *pure* aliases (*var) work only in YAML::Syck YAML::XS log_dir: log *var YAML dies with YAML Error: Can't define both an anchor and an alias. And it is not clear for me how to modify *var to say: (this is a syntax error in all parsers) log_dir: log *var/log How to use other variables' values in yaml config? ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
Oleg Pronin wrote: Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt This is a feature of YAML 1.0. But it seems that only *pure* aliases (*var) work only in YAML::Syck YAML::XS log_dir: log *var YAML dies with YAML Error: Can't define both an anchor and an alias. And it is not clear for me how to modify *var to say: (this is a syntax error in all parsers) log_dir: log *var/log How to use other variables' values in yaml config? Don't? I don't even know what those do. Why do you want them? whats wrong with just text values? ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
There is a var dir. There are log dir, pid dir and data dir under var dir. And a somelog.log under log dir. Do you suggest to write var_dir: __path_to(var)__ log_dir: __path_to(var/log)__ somelog: __path_to(var/log/somelog.log)__ pid_dir: __path_to(var/pid)__ data_dir: __path_to(var/data)__ ? Too many copy-pasting. And too many to change when var_dir changes. 2007/7/24, Ash Berlin [EMAIL PROTECTED]: Oleg Pronin wrote: Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt This is a feature of YAML 1.0. But it seems that only *pure* aliases (*var) work only in YAML::Syck YAML::XS log_dir: log *var YAML dies with YAML Error: Can't define both an anchor and an alias. And it is not clear for me how to modify *var to say: (this is a syntax error in all parsers) log_dir: log *var/log How to use other variables' values in yaml config? Don't? I don't even know what those do. Why do you want them? whats wrong with just text values? ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
I don't even know what those do. Why do you want them? anchors are used to define an anchor on variable. *aliases are used to insert previously defined anchor's value. For example, root_dir: root /very/long/path/to/root/dir root_dir2: *root print MyApp-config-{root_dir2}; # /very/long/path/to/root/dir ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
Oleg Pronin wrote: I don't even know what those do. Why do you want them? anchors are used to define an anchor on variable. *aliases are used to insert previously defined anchor's value. For example, root_dir: root /very/long/path/to/root/dir root_dir2: *root print MyApp-config-{root_dir2}; # /very/long/path/to/root/dir Good reason for using them. Shame it appears nothing in perl supports them. If you want to use them i suggest you submit a patch against the YAML module of your choice. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
Oleg Pronin wrote: Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt This is a feature of YAML 1.0. Can you give a specific reference to the place in the YAML spec that says this is allowed? I can only find statements about aliases to nodes (i.e. what you call pure aliases). I can't see any provision for substituting values and then adding to them. So the modules are simply implementing the YAML spec, on my reading. But it seems that only *pure* aliases (*var) work only in YAML::Syck YAML::XS log_dir: log *var YAML dies with YAML Error: Can't define both an anchor and an alias. And it is not clear for me how to modify *var to say: (this is a syntax error in all parsers) log_dir: log *var/log How to use other variables' values in yaml config? I always end up implementing $substition (a la shell or perl) in my app. But then I hate YAML, anyway. Cheers, Dave ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
YAML::Syck YAML::XS supports them. The problem is in aliases. At yaml.org specification i found only simple examples like var2: *var1. But i need to concatenate *var1 with something ($var2 = $var1 . '/subdir'). This code is a syntax error on all three parsers: var2: *var/subdir var2: *var /subdir etc I didn't find it in specification. YAML::XS is the most advanced Yaml parser supporting Yaml 1.1, but it is not used by Catalyst. 2007/7/24, Ash Berlin [EMAIL PROTECTED]: Oleg Pronin wrote: I don't even know what those do. Why do you want them? anchors are used to define an anchor on variable. *aliases are used to insert previously defined anchor's value. For example, root_dir: root /very/long/path/to/root/dir root_dir2: *root print MyApp-config-{root_dir2}; # /very/long/path/to/root/dir Good reason for using them. Shame it appears nothing in perl supports them. If you want to use them i suggest you submit a patch against the YAML module of your choice. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Jul 24, 2007, at 9:43 AM, Dave Howorth wrote: Oleg Pronin wrote: How to use other variables' values in yaml config? I always end up implementing $substition (a la shell or perl) in my app. I've used Config::General with variable interpolation to do this, in the past. Although Config::General is supported by Config::Any (and therefore by Catalyst::Plugin::ConfigLoader, which I'm assuming we're talking about), there isn't any mechanism to pass configuration to Config::General when it's instantiated, so it doesn't interpolate by default. I ended up creating my own Config::Any::General::Interpolate which loads files called .cnfi or .confi, and tells Config::General to interpolate the variables. I think it would be better to have a mechanism in Config::Any to pass configuration through to Config::General, but I never bothered to come up with a patch or suggestion on how it should work. I guess maybe I should. I think I've also seen some movement towards removing YAML as the default config type, but maybe I just dreamed that. -A ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
Can you give a specific reference to the place in the YAML spec that says this is allowed? I can only find statements about aliases to nodes (i.e. what you call pure aliases). I can't see any provision for substituting values and then adding to them. So the modules are simply implementing the YAML spec, on my reading. You right i meant anchors and alias were features of yaml 1.0 and was wondering if i could change the alias value before inserting. I hoped that yaml supports something like this. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Tue, Jul 24, 2007 at 02:43:37PM +0100, Dave Howorth wrote: Oleg Pronin wrote: Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt This is a feature of YAML 1.0. Can you give a specific reference to the place in the YAML spec that says this is allowed? I can only find statements about aliases to nodes (i.e. what you call pure aliases). I can't see any provision for substituting values and then adding to them. So the modules are simply implementing the YAML spec, on my reading. I have to second what Dave says. YAML doesn't have variables, it just has nodes. An alias just gets you another copy of the referenced node, no matter whether it's a string, an integer, a hash, a list, or whatever. This string concatenation idea you want isn't part of YAML at all. It doesn't seem like the sort of thing the YAML people would be willing to add, since alias nodes do actually define references not just copies. If repeating the value of var_dir is too much for you, I can only suggest you specify inside your application that the value of log_dir c. is appended to the value of var_dir unless it's an absolute path, so you end up with something like: --- var_dir: __path_to(var)__ log_dir: log ... and then in your code my $log_dir = $config{log_dir} =~ m!^/! ? $config{log_dir} : $config{var_dir}.'/'.$config{log_dir}; (Warning: above code may not actually work.) -- Every program eventually reaches a point where it becomes harder to make a simple change than to rewrite the program from scratch. Unfortunately, when this point is reached, it is far too late to consider rewriting it. http://surreal.istic.org/ Show, don't tell. signature.asc Description: Digital signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Tue, Jul 24, 2007 at 04:45:32PM +0400, Oleg Pronin wrote: Hi. I would like to use references to variables that have been defined in my yaml config. Something like this: var_dir: var __path_to(var)__ log_dir: log *var/log log_file: *log/file.txt Config::General definitely supports something like that, so maybe throwing the horror that is YAML out of your app early and moving to .conf would work. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical DirectorWant a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Tue, Jul 24, 2007 at 10:08:03AM -0400, Adam Herzog wrote: On Jul 24, 2007, at 9:43 AM, Dave Howorth wrote: Oleg Pronin wrote: How to use other variables' values in yaml config? I always end up implementing $substition (a la shell or perl) in my app. I've used Config::General with variable interpolation to do this, in the past. Although Config::General is supported by Config::Any (and therefore by Catalyst::Plugin::ConfigLoader, which I'm assuming we're talking about), there isn't any mechanism to pass configuration to Config::General when it's instantiated, so it doesn't interpolate by default. I ended up creating my own Config::Any::General::Interpolate which loads files called .cnfi or .confi, and tells Config::General to interpolate the variables. I think it would be better to have a mechanism in Config::Any to pass configuration through to Config::General, but I never bothered to come up with a patch or suggestion on how it should work. I guess maybe I should. I think I've also seen some movement towards removing YAML as the default config type, but maybe I just dreamed that. .conf becomes the default as of 5.80. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical DirectorWant a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Tue, Jul 24, 2007 at 05:56:26PM +0400, Oleg Pronin wrote: YAML::Syck YAML::XS supports them. The problem is in aliases. At yaml.org specification i found only simple examples like var2: *var1. But i need to concatenate *var1 with something ($var2 = $var1 . '/subdir'). This code is a syntax error on all three parsers: var2: *var/subdir var2: *var /subdir etc I didn't find it in specification. YAML::XS is the most advanced Yaml parser supporting Yaml 1.1, but it is not used by Catalyst. If you want it to be, submit patches to Config::Any. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical DirectorWant a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML Config
On Wed, Jul 25, 2007 at 12:11:24AM +0400, Oleg Pronin wrote: I ended up with using Config::Any::Perl: in /myapp.perl package MyApp::ConfigurationSet; $home = Path::Class::Dir-new(MyApp-config-{home}); ... $var_dir = $home-subdir('var'); $pid_dir = $var_dir-subdir('pid'); $log_dir = $var_dir-subdir('log'); $log_file = $log_dir-file('default.log'); .. return +{ map { $_ = ${RGames::ConfigurationSet::$_} } grep { $_ !~ /^BEGIN$/ } keys %{MyApp::ConfigurationSet::} }; : That's both utterly evil and extremely neat. Nice hack. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical DirectorWant a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML config embedded path_to mysql_read_default_file
Worked perfectly, thanks. Sorry I didn't extrapolate from the docs to just try it. Once you showed it, it seemed obvious. -Ashley On Monday, Mar 19, 2007, at 05:51 US/Pacific, Jason Kohles wrote: On Mar 18, 2007, at 7:26 PM, apv wrote: So, I would like to use a mysql connection file instead of putting the password and user in the config file. Can I get a path_to to work with this? I did Google and check the lists but couldn't find an answer. Where the __HERE__ is is where the mysql_read_default_file=(path_to) goes. Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;__HERE__; - ~ - ~ If you are using Catalyst::Plugin::ConfigLoader to load your configuration (if you aren't sure then you probably are, it's the default), then you can do this... Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;mysql_read_default_file=__path_to(configfile.cfg)__ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML config embedded path_to mysql_read_default_file
On Mar 18, 2007, at 7:26 PM, apv wrote: So, I would like to use a mysql connection file instead of putting the password and user in the config file. Can I get a path_to to work with this? I did Google and check the lists but couldn't find an answer. Where the __HERE__ is is where the mysql_read_default_file=(path_to) goes. Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;__HERE__; - ~ - ~ If you are using Catalyst::Plugin::ConfigLoader to load your configuration (if you aren't sure then you probably are, it's the default), then you can do this... Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;mysql_read_default_file=__path_to (configfile.cfg)__ -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ A witty saying proves nothing. -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] YAML config embedded path_to mysql_read_default_file
So, I would like to use a mysql connection file instead of putting the password and user in the config file. Can I get a path_to to work with this? I did Google and check the lists but couldn't find an answer. Where the __HERE__ is is where the mysql_read_default_file= (path_to) goes. Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;__HERE__; - ~ - ~ Thanks! –Ashley -- ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/