Examples

Remote Resolver

In Genro Web the transport of a page source use an XML rapresentation. Like every other Ajax tecnologies the building process can be at the page loading or during an user interaction.

We have just seen this case in the section about remote() handler but we haven't explained that the use of this handler implies the Remote Resolver usage.

GnrRemoteResolver is a Javascript Bag Resolver implementation that get a value through a RPC dialogue with the server. This allows a lazy loading of remote Data and Source.

Eg: Lazy Loading Tree

In the following example we use Dojo tree to represent a directory tree on the server. The code to do this tremendous feature is:

# -------into main-------
    tree = root.tree(datasource='directory', 
                     gnrId='dirTree')
#------define serverside resolver ----
    dirRes = DirectoryResolver('/workspace/Genro/')
#------lo inseriamo nel Data model---------
    tree.data('directory', dirRes)

The XML excanged is:

<Tree_0 gnrId="dirTree" tag="Tree" datasource="directory">
    <data_0 _resolver="{"resolverclass": "DirectoryResolver", 
                       "args": ["\/workspace\/Genro\/"], 
                       "kwargs": {}}" path="directory" 
                        tag="data"/>
</Tree_0>

So the GenroClient parse the XML, and fills the Data Bag and the Source Bag. In the Data Bag is inserted a Remote Resolver as value corresponding to the treenode's datapath.

So, when you expand a treenode, Remote Resolver does the RPC to get the new Data from the serverside DirectoryResolver.

This is the XML exanged during the Ajax dialog:

<GenRoBag>
    <caller>
       <method>resolverRecall</method>
       <params>
           <resolverPars>
               {"resolverclass": "DirectoryResolver",
                "args": ["\/workspace\/Genro\/gnrpy\/test",
                        "gnrpy\/test"],
                "kwargs": {
                       "readOnly": true,
                       "cacheTime": 500, 
                       "ext": "xml", 
                       "dropext": false,
                       "relocate": "gnrpy
                       "invisible": false, 
                       "exclude": "", 
                       "path": "\/workspace\/Genro\/gnrpy",
                       "include": ""}}
           </resolverPars>
       </params>
    </caller>
    <result>
        <gnr 
           _resolver="{"
                 resolverclass": "DirectoryResolver", 
                 "args": ["\/workspace\/Genro\/gnrpy\/test\/gnr",
                         "gnrpy\/test\/gnr"],
                 "kwargs": {"readOnly": true,
                     "cacheTime": 500,
                     "ext": "xml",
                     "dropext": false,
                     "relocate": "gnrpy\/test",
                     "invisible": false, 
                     "exclude": "", 
                     "path": "\/workspace\/Genro\/gnrpy\/test", 
                     "include": ""}}" 
            file_name="gnr" 
            file_ext="directory" 
            abs_path="/workspace/Genro/gnrpy/test/gnr" 
            rel_path="gnrpy/test/gnr"/>
    </result>
</GenRoBag>

Attachments