3

I have a App.js like this,

App = Ember.Application.create();

App.Model = Ember.Object.extend({

});

App.IndexRoute = Ember.Route.extend({
    redirect : function() {
        this.transitionTo('users');
    }
});

App.UsersController = Ember.ObjectController.extend({

        filteredContent : function() {
            var searchText = this.get('searchText'), regex = new RegExp(searchText, 'i');

            return this.get('model').filter(function(item) {
                return regex.test(item.name);
            });
        }.property('searchText', 'model')

});

App.User = App.Model.extend({
    id : null,
    firstname : null,
    email : null
});

App.UsersRoute = Ember.Route.extend({
    model : function() {
        return App.User.findAll();
    }
});

App.UserRoute = Ember.Route.extend({
    model : function(params) {
      //var everyone = this.controllerFor('users');
      return App.User.findBy('id', params.user_id);
    }
});


App.User.reopenClass({
    findAll : function() {
        return $.getJSON("http://pioneerdev.us/users/index", function(data) {
            return data.map(function(row) {
                return App.User.create(row);
            });
        });
    }
});


App.Router.map(function() {
    this.resource('users', function() {
        this.resource('user',{path: '/:user_id'});
    });
});

HTML,

<script type="text/x-handlebars" data-template-name="users">

            {{input type="text" value=searchText}}

            {{#each item in filteredContent }}
            <tr><td>
              {{#link-to 'user' item}} <p>{{item.firstname}}</p>{{/link-to}}
            </td></tr>
            {{/each}}

            {{outlet}}
        </script>


     <script type="text/x-handlebars" data-template-name="user">
    <h2>
        {{email}}
   </h2>

    </script>

and I am getting a error like this on Chrome,

Uncaught TypeError: Object #<Object> has no method 'map' 

and Firefox gives me, TypeError: data.map is not a function

Here's the Sample of JSON,

{"users":[{"id":"1","firstname":"Marilyn","lastname":"Hughes","address":"4 Johnson Alley","state":"Utah","country":"US","email":"lfreeman@skyvu.info","phone":"6471228888","experience":"5","designation":"Writer"},{"id":"2","firstname":"John","lastname":"Porter","address":"86228 Commercial Court","state":"Pennsylvania","country":"US","email":"jporter@zoomdog.net","phone":"9018889877","experience":"3","designation":"Design"},{"id":"3","firstname":"Frances","lastname":"Johnson","address":"489 Summit Lane","state":"Minnesota","country":"US","email":"fjohnson@teklist.net","phone":null,"experience":"2","designation":"Script"}]}

What might be the issue? I am pretty sure it's an issue with .getJSON.

Should I use data.users.map instead of data.map? But when I use this, I get error on this line,

return this.get('model').filter(function(item) {

saying,

Uncaught TypeError: Object #<Object> has no method 'filter'


Can't execute python script from php

Solved

Before writing a new question i search for a solution all over the web. I have a raspberry pi with apache2, php5.4,ssl. I want to execute a python script from php one. The php script is inside /var/www, which has 777 permission. Php file:

shell_exec('python /home/pi/Desktop/Python/prova.py');

Prova.py has 750 permission but his group owner is www-data, which is the user printed by shell_exec('whoami'); which works. Prova.py:

print "Hello World"

The script works directly from the command line:

php filename.php

It does not work from broswer!

Finally i succeed in execute the script from the browser. I had to add www-data user to sudoers file with its related permission:

www-data ALL=(ALL) NOPASSWD: /etc/bin/python 
4

1 に答える 1