Ticket #1779 (closed enhancement: invalid)

Opened 2 years ago

Last modified 2 years ago

Proposal for improve the mapping emulation in CPS Proxies

Reported by: scamps Assigned to: fguillaume
Priority: P2 Milestone:
Component: CPSCore Version: TRUNK
Severity: normal Keywords:
Cc:

Description

Working with CPS Proxies from python code, I found myself continously writting proxy.getContent().getDataModel().has_key('key') or proxy.getContent().getDataModel().get('key', 'def'). I think with some little improvements, it could be possible to have this features directly in the proxy, being possible to write proxy.has_key('key') or proxy.get('key','def').

I attach a patch to implement this in CPS 3 trunk. I'm missing something ? What do you think about this ?

Attachments

CPSCore_ProxyBase.patch (1.9 kB) - added by scamps on 11/07/06 19:25:04.

Change History

11/07/06 19:25:04 changed by scamps

  • attachment CPSCore_ProxyBase.patch added.

11/07/06 23:28:01 changed by fguillaume

Calling proxy.getContent().getDataModel() is quite costly, so we'd rather not introduce a helper method that would actually hide things and give the false impression that your proxy.has_key(foo) (or get) is a cheap operation.

If you call it constantly, it's better to do dm = proxy.getContent().getDataModel() and then use that.

11/08/06 08:51:08 changed by scamps

  • status changed from new to closed.
  • resolution set to invalid.

Ok, understood. But that cost is similar in the getitem function, so a page template or python script with a lot of proxy/field_name or proxyfield_name? will be also very expensive, isn't it ? It would be better to obtain the datamodel and then use dm/field_name or dmfield_name?

I close the ticket, it's just to know how is better to work within CPS.

11/08/06 23:23:56 changed by fguillaume

That's true, proxyfield_name? is also expensive, but that has never been something recommended, and we don't really use it much (or if we do it's a mistake). The getitem is only here so that URL traversal to images and files works for backward compatibility.