ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

November 23, 2009 11:54pm

Subscribe [46]
  • #361 / Feb 22, 2010 2:58pm

    selfkill

    3 posts

    @OverZealous

    Yeah, I figured this wasn’t exactly an officially supported way of doing that. It took a lot of trial and error to get something that worked. I really think a variable to specify the actual class name would be a nice feature. For example, what if I wanted to have a library named User to handle user functionality in my project? I would need to rename the model to something like Myuser and the table to myuser, and for a perfectionist who likes consistency, this just bugs the hell out of me. But maybe a feature like this would require a lot of reworking of the code so I don’t know.

  • #362 / Feb 22, 2010 3:07pm

    OverZealous

    1030 posts

    @selfkill

    That’s really what the model field does: it specifies the class name.  (It’s a legacy term, so I cannot change it.)

    If you need a library to manage users, you should probably name your library User_Manager.  It just makes more sense logically.  It’s a library to manage users.  If you name the library user, then it’s a user to manage user_models?  😜

    And as for controllers, the common solution of using the plural form for the controller works very well, and is usually only an issue for words that don’t have a plural form.

    In general, I am strongly averse to adding options like that: it’s like the ability to rename the id column, or not have id be an integer.  These options would benefit very few DMZ users, and would significantly modify the code (breaking a lot of simple, hard-coded strings into more itty-bitty pieces).  Plus, it wouldn’t help with the relationships, because the only short form for the relationships is to put the classname as the relationship name.  How would DMZ know which class you meant?

    But mostly, it’s that you are trying really hard to work around a self-created problem.  😉  It just doesn’t make sense to have the model and classname be different.

  • #363 / Feb 22, 2010 3:24pm

    selfkill

    3 posts

    @OverZealous

    The $model variable didn’t exactly work that way unfortunately, I tried it.

    My example with the User class probably wasn’t the best. A better example would probably be a model named Session conflicting with CI’s own library named Session or some other third party library that couldn’t be renamed.

    The other solution I thought up was instead of a variable for the class, you could have another variable for the singular version of the table (i.e. $table and $table_singular). However, if it requires too much work to implement and breaks legacy code, then it’s not worth adding such a feature like you said. I just thought otherwise, it would come in handy.

  • #364 / Feb 22, 2010 4:51pm

    emorling

    66 posts

    How do I get drop downs to work with the render_form function?

    I tried this:
    var $validation = array(
          ‘mydropdown’ => array(
            ‘label’ => ‘Pick a number’,
            ‘type’ => ‘dropdown’,
            ‘list’=>array(‘1’=>‘one’,‘2’=>‘Two’),
          )
      );

    Any help would be appreciated.

  • #365 / Feb 23, 2010 7:31am

    OverZealous

    1030 posts

    Deleted

  • #366 / Feb 23, 2010 11:49am

    NachoF

    171 posts

    Hmm, I dont know if I should upgrade or not… I dont want to have to be updating too often at the risk of hurting my app.

  • #367 / Feb 23, 2010 12:59pm

    cahva

    662 posts

    I was bold and upgraded today DMZ to one site. Cache doesnt work even after deleting previous cache files. It just gave blank page after that. Without cache it seems to work good. I didnt have time to dig deeper, but if someone else could test DMZ with cache turned on I would be gratefull..

    For the upgrade, I did the usual. Overwrite extensions and datamapper lib + empty cache dir. I upgraded from 1.6.2.

  • #368 / Feb 23, 2010 1:38pm

    beemr

    160 posts

    How do I get drop downs to work with the render_form function?

    I think if your list is less than six items or so, htmlform will default to checkbox.  You should be able to override the defaults for specific fields when you call render_form()

    var $validation = array(
            '{field name}' => array(
                'label' => 'Pick a number',
                'type' => 'dropdown',
                'list'=>array('1'=>'one','2'=>'Two')
            )
        );

    Then in the view:

    ${model name}->render_form($validation);

    Is that what you mean?

  • #369 / Feb 23, 2010 6:33pm

    OverZealous

    1030 posts

    @cahva
    I assume you mean the “Production Cache” feature?  (there’s like 3 or 4 things called cache in DMZ! 😊)  I’ll look into seeing if my changes broke that.

    @NachoF
    This release, especially, is just a release candidate.  If you don’t want to help test it, then you should probably wait.  (Of course, if there are bugs that affect your application specifically, I won’t be able to fix them for the final release.)

    However, it’s a safe update (if it doesn’t work, just replace the new DMZ with the old DMZ).  There are no changes to the language files, and the new config option is not necessary, so you probably just replace application/libraries/datamapper.php to test it.

    In general, DMZ updates will warn you if something could cause your current app to break.

  • #370 / Feb 23, 2010 6:52pm

    OverZealous

    1030 posts

    OK, I fixed the Production Cache issue.  You can’t use var_export to export a stdClass, because the stdClass doesn’t know how to re-import the data later.

    So, I changed $_field_tracking to an array, which works.

    If you need the cache functionality, just re-download the 1.7.0-RC1 lite file, replace the library, and clear your cache again.  If you don’t, then no worries until I release the final version.

  • #371 / Feb 23, 2010 7:27pm

    NachoF

    171 posts

    This question is not related to the new RC but just in general.. regarding validation errors

    how do you get the specific field error of a related field??

    for instance, Group has validation on User

    but

    echo $user->error->group;

    gives me

    Message: Undefined property: stdClass::$group

  • #372 / Feb 23, 2010 7:30pm

    OverZealous

    1030 posts

    @NachoF

    Two things are happening.  First, there is no error (in your example) for that field.

    Second, there is a bug (in some sense) in that the related items aren’t set to ‘’, leading to the error.  I’ll look into fixing it before the release of 1.7

    So, a short term fix is to use isset() before echoing them.  😊

    Update: That was easy.  If you want to manually fix 1.6.2, just go to the clear() method, and add this line to each of the $has_one and $has_many foreach loops:

    $this->error->{$related} = '';
  • #373 / Feb 23, 2010 7:42pm

    NachoF

    171 posts

    And where can I find the clear() method?

  • #374 / Feb 23, 2010 7:44pm

    OverZealous

    1030 posts

    @NachoF
    In the DataMapper library.  It’s called Edit / Find, search for function clear.

  • #375 / Feb 23, 2010 7:53pm

    NachoF

    171 posts

    function clear()
        {
            // Clear the all list
            $this->all = array();
    
            // Clear errors
            $this->error = new stdClass();
            $this->error->all = array();
            $this->error->string = '';
    
            // Clear this objects properties and set blank error messages in case they are accessed
            foreach ($this->fields as $field)
            {
                $this->{$field} = NULL;
                $this->error->{$field} = '';
            }
            
            // Clear the auto transaction error
            if($this->auto_transaction) {
                $this->error->transaction = '';
            }
    
            // Clear this objects "has many" related objects
            foreach ($this->has_many as $related => $properties)
            {
                $this->error->{$related} = ''; 
                unset($this->{$related});
            }
    
            // Clear this objects "has one" related objects
            foreach ($this->has_one as $related => $properties)
            {
                $this->error->{$related} = ''; 
                unset($this->{$related});
            }
    
            // Clear the query related list
            $this->query_related = array();
    
            // Clear and refresh stored values
            $this->stored = new stdClass();
    
            $this->_refresh_stored_values();
        }

    Thats the method… Im still getting the same error

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases