fromString for updating objects?

Author Message

Peter Keung

Monday 18 July 2011 12:56:14 pm

We've been using datatypes' fromString methods for years now, for imports and updates.

The "ezuser" datatype's fromString method does a check to make sure that the username and e-mail address don't already exist (see here for a bit of context: http://issues.ez.no/IssueView.php?Id=17836&activeItem=3). This makes it unsuitable to be used for updates to existing users. We use some simple workaround code to capture updates to "ezuser" attributes and update them directly -- not really a problem.  However, this brings up a general framework question:

Was the intention around fromString for it to be used on new object creation only?  If it was also intended to be used in updates, then perhaps ezuser's fromString method should be modified to put the onus on the script using that method to do its own checks on the username or e-mail address. This way, the actual update process is more standardized: you are forced to do all of the necessary preparation on the attributes before they are passed through.

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Gaetano Giunta

Tuesday 19 July 2011 11:49:24 am

I fully agree that the fromString method, while extremely useful, is not good enough.

  1. It is not supported by 100% of the datatypes
  2. It does not involve all of the validation done when editing content via the browser

Point 2 is especially important, as there is currently no other method (afaik) that does it - datatype validation is sadly tied to variables being there in $_POST. This has the nasty effects that a lot of import scripts do create inconsistent data (inconsistent wrt. content class definition).

Let's hope that this will be fixed in the new content-management API currently in the works...

Principal Consultant International Business
Member of the Community Project Board

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.