agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)

8 messages Options
Embed this post
Permalink
Kees Hink () agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)
Reply Threaded More More options
Print post
Permalink
Thought i'd make this known here:

When generating with the current ArchGenXML 2.3, an ImageField will get
        storage=AnnotationStorage(),
set on it.

However this doesn't work in my setup (Plone 3.2.1, Archetypes 1.5.10-dev). The
result is that i can upload an image without error, but it will not show,
neither in the base_view nor in the base_edit mode.

The right kind of storage is AttributeStorage, setting the tagged value
storage=AttributeStorage in the UML fixes it, at least for me.

How to repeat:
1 Create a new class in UML
2 Add an ImageField (called 'image' in this example)
3 Generate code using archgenxml 2.3
4 Observe the generated schema looks like this:
    ImageField(
        name='image',
        widget=ImageField._properties['widget'](
            label='Image',
            label_msgid='OPSB_label_image',
            i18n_domain='OPSB',
        ),
        storage=AnnotationStorage(),
    ),
5 Install the product in a site, create an instance of the new class
6 Set the 'image' field on the class by uploading an image
7 Observe that the uploaded image isn't viewable. Clicking the link on the image
field (which is supposed to take you to the image) gives a 404.

Are the good AGX folks reading this list as well, or is there a separate list
where i can put this?

Regards,

Kees

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Raphael Ritz () Re: agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)
Reply Threaded More More options
Print post
Permalink
Kees Hink wrote:
> Thought i'd make this known here:
>
> When generating with the current ArchGenXML 2.3, an ImageField will get
> storage=AnnotationStorage(),
> set on it.

I'd call that a bug in AGX as AT still doesn't support
Annotation Storage for images.

I'm sure Jens can tell you a lot about that ;-)

[..]

>
> Are the good AGX folks reading this list as well,

I think so.

Raphael


> or is there a separate list
> where i can put this?
>
> Regards,
>
> Kees
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Jens W. klein-2 () Re: agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)
Reply Threaded More More options
Print post
Permalink
In reply to this post by Kees Hink
Am Thu, 12 Mar 2009 16:14:08 +0100 schrieb Kees Hink:

> Thought i'd make this known here:
>
> When generating with the current ArchGenXML 2.3, an ImageField will get
> storage=AnnotationStorage(),
> set on it.
>
> However this doesn't work in my setup (Plone 3.2.1, Archetypes
> 1.5.10-dev). The result is that i can upload an image without error, but
> it will not show, neither in the base_view nor in the base_edit mode.
>
> The right kind of storage is AttributeStorage, setting the tagged value
> storage=AttributeStorage in the UML fixes it, at least for me.
>

Its the truth, AT still has no native support for this.

OTOH using AttributeStorage for Images and Files slows down your site,
increases memory consumption and usally will make Plone slow. so Products
generated with AttributeStorage for Images are not ready for production.
Its weak code.

I decided to make AnnotationStorage the default. You have two options to
make this work:

1) use archetypes.fieldtraverser  (see pypi) which just solves the
problem.

2) copy the Products.ATContentTypes.content.image.__bobo_traverse__
method to your class and adjust it to your needs. ATImage and every sane
AT-based Products uses AnnotationStorage for its files and images.


I prefer (1) and to make it work we could make archetypes.fieldtraverser
a dependency for AGX generated products. This need to be documented (any
volunteers?). It results in mature code.

(Just for completeness: using plone.app.blob would be the most mature
solution).

IMO archetypes.fieldtraverser needs to get into core Archetypes to solves
the problem of accessing non-attribute-based storages.

regards

Jens
--
Jens W. Klein, BlueDynamics Alliance, http://bluedynamics.com


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Raphael Ritz () Re: agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)
Reply Threaded More More options
Print post
Permalink
Jens W. Klein wrote:
>

Hi Jens,

[..]

> IMO archetypes.fieldtraverser needs to get into core Archetypes to solves
> the problem of accessing non-attribute-based storages.

Sorry for abusing this thread a bit but while we are at this:

I strongly support this.

What's actually the status on that? I know that you had
checked that in and merged to the current release line
once but got asked to revert because it was considered
too intrusive a change?

Is that still the status or has there been progress?

Is there anything I can do to help? (write a PLIP
or bribe some people, ...)

Cheers from Sweden to Austria,

        Raphael


>
> regards
>
> Jens


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Jens W. klein-2 () archetypes.fieldtraverser (was: Re: agx-generated code: archetypes ImageField not showing (due to incorrect Storage type))
Reply Threaded More More options
Print post
Permalink
Am Fri, 13 Mar 2009 12:53:43 +0100 schrieb Raphael Ritz:

> Jens W. Klein wrote:
>>
>>
> Hi Jens,
>
> [..]
>
>> IMO archetypes.fieldtraverser needs to get into core Archetypes to
>> solves the problem of accessing non-attribute-based storages.
>
> Sorry for abusing this thread a bit but while we are at this:
>
> I strongly support this.
>
> What's actually the status on that? I know that you had checked that in
> and merged to the current release line once but got asked to revert
> because it was considered too intrusive a change?

After hannes wrote a bunch of tests at.fieldtraverser is mature. It is in
use at a some big customer project made by BlueDynamics.

Its indeed an intrusive change, because it adds new behaviour to
archeytypes. But it solves a common problem!

> Is that still the status or has there been progress?

Its the state. At the moment its just an addon.

> Is there anything I can do to help? (write a PLIP or bribe some people,
> ...)

Yes, if you can bring this up and help me and Hannes to write a PLIP it
would be awesome. For me at the moment its enough for our projects to
have this addon, but I really think its core stuff. And its stable now.
We need monkey-patching as add-on product, but if it would go into AT
itself or as a dependency of AT (what would you prefer?) this isnt needed
any longer.

for more info hannes summarized fieldtraverser at
http://bluedynamics.com/articles/johannes/archetypes.fieldtraverser-
released

greetz

Jens
--
Jens W. Klein, BlueDynamics Alliance, http://bluedynamics.com


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Kees Hink () Re: agx-generated code: archetypes ImageField not showing (due to incorrect Storage type)
Reply Threaded More More options
Print post
Permalink
In reply to this post by Jens W. klein-2
As performance may become an issue, I'm currently using your suggested method
1), which works, and i take your word for it that it's faster. :)

Thanks for following up on this,

Kees

Jens W. Klein wrote:

> Am Thu, 12 Mar 2009 16:14:08 +0100 schrieb Kees Hink:
>
>> Thought i'd make this known here:
>>
>> When generating with the current ArchGenXML 2.3, an ImageField will get
>> storage=AnnotationStorage(),
>> set on it.
>>
>> However this doesn't work in my setup (Plone 3.2.1, Archetypes
>> 1.5.10-dev). The result is that i can upload an image without error, but
>> it will not show, neither in the base_view nor in the base_edit mode.
>>
>> The right kind of storage is AttributeStorage, setting the tagged value
>> storage=AttributeStorage in the UML fixes it, at least for me.
>>
>
> Its the truth, AT still has no native support for this.
>
> OTOH using AttributeStorage for Images and Files slows down your site,
> increases memory consumption and usally will make Plone slow. so Products
> generated with AttributeStorage for Images are not ready for production.
> Its weak code.
>
> I decided to make AnnotationStorage the default. You have two options to
> make this work:
>
> 1) use archetypes.fieldtraverser  (see pypi) which just solves the
> problem.
>
> 2) copy the Products.ATContentTypes.content.image.__bobo_traverse__
> method to your class and adjust it to your needs. ATImage and every sane
> AT-based Products uses AnnotationStorage for its files and images.
>
>
> I prefer (1) and to make it work we could make archetypes.fieldtraverser
> a dependency for AGX generated products. This need to be documented (any
> volunteers?). It results in mature code.
>
> (Just for completeness: using plone.app.blob would be the most mature
> solution).
>
> IMO archetypes.fieldtraverser needs to get into core Archetypes to solves
> the problem of accessing non-attribute-based storages.
>
> regards
>
> Jens

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Raphael Ritz () Re: archetypes.fieldtraverser
Reply Threaded More More options
Print post
Permalink
In reply to this post by Jens W. klein-2
Jens W. Klein wrote:
[..]

>> Is that still the status or has there been progress?
>
> Its the state. At the moment its just an addon.
>

Thanks for the update Jens!

>> Is there anything I can do to help? (write a PLIP or bribe some people,
>> ...)
>
> Yes, if you can bring this up and help me and Hannes to write a PLIP it
> would be awesome. For me at the moment its enough for our projects to
> have this addon, but I really think its core stuff. And its stable now.
> We need monkey-patching as add-on product, but if it would go into AT
> itself or as a dependency of AT (what would you prefer?) this isnt needed
> any longer.

I would prefer this to go into AT proper.
But at the moment that's just me.
Dependency would also be OK I guess as long as we can avoid
monkey patching (as you say).

>
> for more info hannes summarized fieldtraverser at
> http://bluedynamics.com/articles/johannes/archetypes.fieldtraverser-
> released

This sounds excellent.

Before looking at the implementation I've two quick
questions:

1. I assume this honors permission settings on fields,
   correct? (not that we open up any security holes here).

2. Does it require any migration in order to be applicable
   to legacy data? I would assume yes for persistent schemata
   on instances but no for "regular" ones - any insights?

Let's see where we get with this ...

Raphael


>
> greetz
>
> Jens


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Jens W. klein-2 () Re: archetypes.fieldtraverser
Reply Threaded More More options
Print post
Permalink
Am Fri, 13 Mar 2009 14:42:11 +0100 schrieb Raphael Ritz:
[..]

>>> Is there anything I can do to help? (write a PLIP or bribe some
>>> people, ...)
>>
>> Yes, if you can bring this up and help me and Hannes to write a PLIP it
>> would be awesome. For me at the moment its enough for our projects to
>> have this addon, but I really think its core stuff. And its stable now.
>> We need monkey-patching as add-on product, but if it would go into AT
>> itself or as a dependency of AT (what would you prefer?) this isnt
>> needed any longer.
>
> I would prefer this to go into AT proper. But at the moment that's just
> me.
> Dependency would also be OK I guess as long as we can avoid monkey
> patching (as you say).

Integration into AT imo is to apply the patches to code and templates
directly to AT and remove patch.py profile and skins from fieldtraverser.
Then we have a configure.zcml and fieldtraverser.py left, those can be
moved into Products.Archetypes and we can trash the current egg.

>
>> for more info hannes summarized fieldtraverser at
>> http://bluedynamics.com/articles/johannes/archetypes.fieldtraverser-
>> released
>
> This sounds excellent.
>
> Before looking at the implementation I've two quick questions:
>
> 1. I assume this honors permission settings on fields,
>    correct? (not that we open up any security holes here).

It calls field.checkPermission for 'r' (read) and raises Unauthorized if
False was returned. This is how current Archetypes do it as well.
 
> 2. Does it require any migration in order to be applicable
>    to legacy data? I would assume yes for persistent schemata on
>    instances but no for "regular" ones - any insights?

Theres no data migration needed.

fieldtraverser is fully transparent to schema or storage at all. It works
fine even with schemaextender.

As long as the field.getStorage returns the value for the field
everythings fine. ReferenceField is the only field I know about which
does not use a storage implementation. But you wouldnt ever traverse to a
Reference.

some custom widgets may want to get adjusted to make use of
fieldtraverser, but they dont start working if fieldtraverser drops in.

greetz Jens
--
Jens W. Klein, BlueDynamics Alliance, http://bluedynamics.com


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users