Jifty::Manual::ObjectModel is an overview of the Jifty object model.
Jifty applications are generally built in a similar way. There's no reason you need to use the model we've built, but we find it a reasonably ok way to do things.
This document should serve as a roadmap to the Jifty class library, as well as an introduction to the way Jifty applications are put together.
We start with the classes in your application and move on to the bits of Jifty itself.
If you create a brand new application, let's call it MyWeblog, and create one model class called MyWeblog::Post, you'll end up with the following files and directories:
#some test files.
At least that's the scaffolding Jifty creates for you. Behind the scenes, Jifty is actually doing a lot more. Rather than create a bunch of little "stub" classes and libraries for you, Jifty generates them on the fly. It's always possible to actually create these libraries when you need to customize the default behavior, but we work really hard to make sure you don't need to.
Right now, Jifty is autocreating libraries, static web pages and web templates.
We're not 100% satisfied with how Jifty autocreates web templates and static pages and are working to redesign that.
The library you see when creating a Jifty app is:
MyWeblog::Model::Post describes the schema and business logic of your post class. It uses two namespaces, MyWeblog::Model::Post::Schema that has actual column definitions and MyWeblog::Model::Post that contains the (optional) business logic, access control and so on.
That's it. But if you look carefully at MyWeblog::Model::Post, you'll see the line:
use base qw/MyWeblog::Record/;
How can that possibly work? There is no MyWeblog::Record class in your application. And Jifty, while it tries to be a comprehensive framework, draws the line somewhat short of including application-specific base classes for every application you might possibly contrive.
The answer lies in Jifty::ClassLoader, a utility module Jifty uses to create the boring stuff for you when you need it.
It'd certainly be possible for Jifty to create every class you might need as a file on disk when you first create your application (and indeed we may decide to do so if enough people yell at us), but when the stub classes we'd provide are just little shims that inherit from or call to the Jifty core, it doesn't make much sense to create them before you need them. You could build a Jifty application without these shims by having your model classes inherit directly from Jifty::Record, but then you'll run into trouble the second you want to add application-specific code and have to go back and retrofit each and every one of your classes to use your new base class. It's a little thing, but one that can save you a bunch of pain and suffering later on.