On 11/07/2011 05:37 PM, Henrik Pauli wrote:
> Back to my config issues :)
>
> I've been trying to tackle the following problem:
>
> There's a production system and some development systems, which differ
> in particular in URLs.  For example the RPC is behind a different URL,
> and so is for example UploadMgr's server-side handler.
>
> I'd like to have as few as possible occurrences of these URLs in the
> source, and it would be especially nice if it were a separate config
> file slurped up during generation time.  Optional bonus points if the
> same config file can be used everywhere, but depending on eg. the system
> hostname, something different happens :)
>
> So far, I read that it's possible to include an external JSON file into
> the config, and I guess it could have some custom environment keys
> defined for the application to use.  Does anyone have any suggestions,
> recommendations, corrections?  I do kinda feel disoriented with this.

I think you're on the right track, use custom environment keys. E.g. in 
your config.json you can have

{
   "name" : ...,
   "include" : [
      { "path" : "server_settings.json" },
      ...

and in server_settings.json you have

{
   "jobs" : {
      "server-settings" : {
         "environment" : {
               "myuplodmgr" : "http://.....";
         }


Now back in your config.json you have to use the new "server-settings" 
job, to inject its settings. E.g.

{
    ...
    "jobs" : {
       "source-script" : {
          "extend" : ["server-settings"]
        },
        "build-script" : {
           "extend" : ["server-settings"]
        }

This will make sure your environment settings are used when creating the 
app in source and build version.

It will not be that straight-forward to integrate site-specific 
settings, but you can use macros for that. Let's suppose the uploadmgr 
URL just differs in the name of the server, you could do in 
server_settings.json

  {
    ...
    "let" : {
        UPLOADMGR_SERVER : "<some default server name>"
     },
    "jobs" : {
       "server-settings" : {
          "environment" : {
               "myuploadmgr" : "http://${UPLOADMGR_SERVER}/path/to/handler";
          }
        }

and then pass a suitable binding for the macro on the development 
machine when invoking the generator, like

   generate.py -m UPLOAD_SERVER:server1.mydom.ain source

Of course you could maintain those macro bindings in yet another config 
file which would be machine-specific. Automatic evaluation of the host 
name is not possible currently (though support of OS environment keys is 
in the making :).

HTH,
T.


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to