-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/28/2013 04:01 AM, Ahmed wrote:
> Hello all, I have a design question, pertaining to the use of the
> component registry.
> 
> I have recently implemented some @model decorators that I will use to
> keep track of my sqlalchemy models. These decorators will be added to
> the registry on a Configurator.scan() and queried by name where name
> will be in my case the lower() of the model class name. The decorators
> registers these with an config.add_model() method which registers them
> as named utilities in the registry in a new category "models", which I
> can lookup by name.
> 
> Now I want to do the same for my form classes. The problem is that
> form lookup is more complex than model lookup because it depends on
> lots of criteria like the action of the form e.g. create forms, edit
> forms, listing forms ... plus the model e.g. create Employee, create
> Manager, create Product forms etc. There may be also extra criteria
> for some form types .. e.g. create child model form, with additional
> criteria of a relationship or a parent or child class etc..
> 
> The problem is that this does not conform to the utility or adapter 
> functions of the component registry.
> 
> So do I abandon the pyramid registry for this job and just cache them
> in a dictionary with perhaps tuples containing all possible criteria
> acting as keys? Or is there a way to make for the component registry
> to hold this data in some way.

Pyramid view configuration handles this kind of use case by using an
adapter lookup (based on the model aka resource type and the request
type) to a "multi-view" object which then evaluates predicates using the
non-type-based predicates:


https://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/viewconfig.html


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlF9ghcACgkQ+gerLs4ltQ7MaACgjTFiEH2NQwHEESa8dBU8p+Bv
Fe8An3CT9rAL0YxBNtIMQXIqUbQx2kbI
=KrPN
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to