reworked FileHandler for exyus

2007-09-18 @ 22:02#

i spent a block of time today reworking the FileHandler module for the exyus engine and i like the results.

first, i added flags to control whether DELETE, POST, or PUT (create) are allowed. while this *could* be controlled by overriding the handler and adding custom traps for the methods, the flags make it easier to re-use the class i typical scenarios. not all, but typical.

second, i used a bit of reflection code to eliminate the need to declare a LocationUri for each resource. now, if none is declared, the UriPattern attribute is used for the LocationUri, too. that just makes sense. in fact, i might not need to expose the LocationUri anymore, but i'll hold off on that for now.

finally (resource-wise), i updated the class to fully support regular expressions for CacheUriTemplates. this kinda closes the loop on the whole UriPattern, LocationUri, CacheUriTemplates pattern. it's all leveraging RegEx and that's a good thing 'cuz that's another engine[grin]!

so a typical resource declaration now looks like this:

// example xmlfile handler
[UriPattern(@"/users/(?<uid>[^/]*)(?<tail>\.xcs)")]
public class userFile : FileHandler
{
    public userFile()
    {
        this.AllowPost = false;
        this.AllowCreateOnPut = true;
        this.DocumentsFolder = "~/documents/users/";
        this.StorageFolder = "~/storage/users/";
        this.XHtmlNodes = new string[] { "//notes" };
        this.LocalMaxAge = 600;
        this.ImmediateCacheUriTemplates = new string[]
            {
                "/users/",
                "/users/{uid}"
            };
    }
}

i did another major update to the engine by cleaning up my use of XSLT/XSD. that's in my next post.

code