Pattern Cards+implementation
Pattern Cards+implementation+overview
Use cases
The two most common use case for patterns are:
- we have a card and need to know a pattern-based setting.
- we are executing an action on a card and need to know which pattern-based hook or view to execute
Approach
As patterns are implemented (pattern cards created, hooks declared, etc.), they are registered in a big hash (internal or external to ruby process depending on needs) by their pattern key. To find the patterns for a given card, we generate a set of pattern keys for that card, and look up the patterns for each of those keys.
We will likely cache settings, as well as all cacheable views, on the card. When a pattern card is changes, all effected cards have their cache updated.
Pattern Cards+implementation+module outline
On 10/13/09 6:40 AM, Gerry Gleason wrote:
On 10/12/09 6:03 PM, Lewis Hoffman wrote:
On Sat, Oct 10, 2009 at 5:47 AM, Gerry Gleason gerryg@inbox.com wrote:
I like these broad categories. I'm a little fuzzy about Card storage being at the same level-- it seems like there's a lot of change/revision handling and content processing that we just wouldn't do if the card were actually stored on another wagn.So we would have these chunks to implement cards:
- Card content model (we haven't talked about this much, but I think this is where the hooks Lewis is talking about comes in. Task: catalog the content processing we do now: wiki-rendering to handle [[]] and {{}} stuff, slot based type editors, other type rendering
- Card naming model (the semantics of the virtual fields, name and key, + segmentation of names)
- Card storage model (Wagn is a flat namespace derived directly from the naming model) We have just scratched the surface in these discussions about how we might want to extend Wagn with respect to namespaces, multiple wagns refering to each others content. name resolution and scopes/contexts.
- Change model (i.e. how we handle revisions) -- I will come back to this along with Ethan's question about what I said earlier about revisions.
I agree, this is fuzzy. I'm going to address this in a separate post to keep this one shorter.
Gerry
- cards of a certain type
- cards with a certain name
- card plus a
- Get all the patterns to which the card conforms in order of pattern precedence. There are lots of
I'm not sure I fully understand the patterns proposal, but I was trying to explore the code use cases. At first I was thinking that you would just go from a card, which matches a set of patterns, each of which can have a set of attribute values (Lewis suggested thes are the plus cards of the pattern, but I'm not sure if this is best.
What I imagine instead is the patterns connected with a card as a set of resources available to configure the operation of each hook defined by the application.
- Permissions - card controller before filters are declared in a DSL where controller actions (:view, :edit ...) are mapped to an auth category (:read, :write, :comment, :create, :new_cardtype, whatever I need for my app). Now we would call card(self).patterns(:perm => auth_category) which would? Iterate through the patterns matching {|pat| path.action(:perm)(card, arg (which gets auth_category bound to the :perm action)). Someplace :perm is defined in a DSL that can access any of the patterns matching the card to find related cards with the roles and auth_categories allowed or denied for the card. The DSL also defines the return conditions (:allowed, :denieed, or :ok, :deny, :signin ?)
- Cardtype - someplace we need to declare that <card>+*Cardtype (or whatever the standard will be) is the cardtype card. Even if it stays in the cards table, this part should be explicite and configureable via patterns.
- content-type - I think that the idea of a raw, or primitive cardtype needs to be moved to the content as a "content-type" field that is part of each revision alongside the data (content). I think this will also be central to the API to add primative cardtypes. If a content-type module can handle some foreign content-types on input, they can import from that version on editto automatically convert. If it can't the old content type is still there in the revision history.
- templates - this is the most prolific part of the proto-pattern stuff in wagn. I'd like to see how you expect that to work in the patterns version. I think this is a lot like the permissions case where we need a DSL that identifies any existing related template cards based on the patterns, and decides which apply based on view, action, content-type and any other attribute available to the DSL.
--- Gerry
I came to this by thinking about what the code that uses all this would look like and where it would be situated. Below is an attempt to psuedo code a card controller:
class CardController << ApplicationController
before_filter :action_ok
def action_ok
auth = action2auth(action)
patterns { |pat| pat.permissions(self,auth) }
end
end
# posting with just the permission part so far ...
--Gerry Gleason.....Sun Oct 11 14:09:09 -0700 2009
