Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default Unanswered: Model phantom stays true after load()

    Unanswered: Model phantom stays true after load()


    Code:
    Ext.application({
        userModel = Ext.create('App.model.User'),
    
    
        Ext.ModelManager.getModel('App.model.User').load(2, {
          success: function(user, operation) {
            //userModel is populated by load but phantom is true (so is user.phantom)
          }
        })
    });
    Documentation for Ext.data.Model.phantom states

    Any record which has a real database pk set as its id property is NOT a phantom -- it's real.

    This should imply that any record load()'ed from the server should NOT be phantom, since I specify a pk with which load returns and populates the Model.

    -

    Ext.create acts as the authority for deciding on the phantom by detecting if it has an ID, and it never gets updated after load(), when it clearly does have an id (populated by the server).

    The only way I see around this is to horribly and redundantly instead do

    Ext.create('App.model.User', { id: 2 })
    and then
    Ext.ModelManager.getModel('App.model.User').load(2, {});

    This should be unnecessary. Am I missing something in the paradigm of how to work with Sencha Touch or is this just bad behavior as it currently seems?

  2. #2
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    As I understand it, in Touch, when a MODEL INSTANCE IS CREATED, it is a phantom (until save() I think)... but load() doesn't make it NOT a phantom

    I think this is a bug



    Summary of: touch/src/data/Model.js

    Code:
    Ext.define('Ext.data.Model', {
        alternateClassName: 'Ext.data.Record',
    
        phantom : false,
    
        constructor: function(data, id, raw, convertedData) {
            // If it does not have an id at this point, we generate it using the id strategy. This means that we will treat this record as a phantom record from now on
            id = me.data[idProperty];
            if (!id && id !== 0) {
                me.phantom = true;

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    As an aside...

    I was a bit surprised to see it populate the userModel, but load() does seem to populate automatically just like save() does with a response from the server.

    It's just that with save() you call it on modelInstance.save() and with load you called it on App.model.ModelDefinition.load(id)


    perhaps App.model.ModelDefinition is a singleton of some sort
    so userModel just references the singleton

    ...and data gets stored IN THE MODEL definition?


    This seems like great, clean behavior, minus phantom being true on a load() that pulls from, and with, a record that has an id. Clearly wrong.

  4. #4
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    I would propose a fix:

    Code:
    Ext.define('Ext.data.Model', {
        alternateClassName: 'Ext.data.Record',
    
        inheritableStatics: {
            /**
             * Asynchronously loads a model instance by id. Sample usage:
             */
            load: function(id, config, scope) {
    
                callback = function(operation) {
                    if (operation.wasSuccessful()) {
                        record = operation.getRecords()[0] || null;
                        record.phantom = false;
                        Ext.callback(config.success, scope, [record, operation]);
                    } else {
    With this change userModel.phantom = false after load(), meeting the expectations of "phantom" as a record which has a real database pk set as its id property in accordance with what the documentation states/provides.

  5. #5
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    *bump*

    Looking for someone from Sencha to weigh in on this, I've provided a lot of detail...

  6. #6
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Looking in Model source code one can say that:
    1) Any new instance of Model which didn't receive in constructor a not null id != 0 will be a phantom.
    2) On a successful load, the proxy is performing the read operation and the operation will process the read

    processRead: function(resultSet) {
    var records = resultSet.getRecords(),
    processedRecords = [],
    Model = this.getModel(),
    ln = records.length,
    i, record;

    for (i = 0; i < ln; i++) {
    record = records[i];
    processedRecords.push(new Model(record.data, record.id, record.node));
    }

    this.setRecords(processedRecords);
    resultSet.setRecords(processedRecords);
    return true;
    }

    so the only chance that record = operation.getRecords()[0] to be phantom is that the server returned answer doesn't translate in something with an id.
    Latest thoughts on the subject: http://joy2share.com/senchatouch/

  7. #7
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    Thank you for the response! This seemed like a simple and well illustrated example that was bizarrely not receiving even a moment of attention or consideration on this forum (maybe most questions don't).

    In the example of my first post both userModel and user were populated with an id, so I'm assuming the server provided one (as far as I'm aware, it should have).

    As evidenced by the details in my post, I had attempted to comb the source and determine how "phantom" is managed by load(), and I didn't find any indication of load() or operation altering the records phantom property.

    I'll use your response to delve further and follow-up after doing so.

  8. #8
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    @bluehipy: You've helped me confirm the problem, though I still don't understand it.

    What bluehipy is saying is that when doing a read, Operation populates the resultSet property by running the returned data (record) through new Model(record.data, record.id, record.node), and by what we already know, a new Model starts with phantom: false and only sets true within the constructor if (!id && id !== 0).

    However,

    I've confirmed that WITH a record.id present (2), directly after:

    Code:
    processedRecords.push(new Model(record.data, record.id, record.node));
    processedRecords[0].phantom IS true.

    I know it's hard to believe, but try it for yourself, my code is extraordinarily straight forward.

  9. #9
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Hey ikean, it's a large community and a busy forum
    If you are sure that the server responds as expected, I think you can file a bug report. Sencha guys are very responsive actually.
    But before that be sure the server side is responding as described in docs. I remember that the server response has to be in a specific format so the proxy / model can determine if the records are newly created or updated.
    Latest thoughts on the subject: http://joy2share.com/senchatouch/

  10. #10
    Sencha User
    Join Date
    Jan 2013
    Posts
    19
    Vote Rating
    0
    ikean is on a distinguished road

      0  

    Default


    I should also note this detail...

    Within the constructor

    Code:
    new Model(record.data, record.id, record.node);
    this.phantom is set to false since my server is providing Operation a record.id from the read (so the constructor doesn't flag it as phantom).

    But, confusingly, once it returns to the Operation scope for

    Code:
    processedRecords.push(
    
    processedRecords[0].phantom is true

    I can't even wrap my head around this fact.

Thread Participants: 1

Tags for this Thread