need help!

24 views
Skip to first unread message

W.S. Hager

unread,
Apr 12, 2013, 12:16:30 PM4/12/13
to persevere...@googlegroups.com
Hi,

I'm stuck on this. I really want to understand how persevere 2.0 works, but there is too much magic to just see what's going on. The main problem is in perstore/model.js, and there's no documentation or comments:

- what does initializeRoot do, and what is the addClass parameter for?
- what does createModelsFromModel do exactly?
- what does ModelsModel do? It could use a better name...

Instead of "what" I should probably also ask "how" and "when", but any feedback is appreciated.

Thanks,
Wouter

--

W.S. Hager
Lagua Web Solutions
http://lagua.nl

Kris Zyp

unread,
Apr 18, 2013, 2:55:22 PM4/18/13
to persevere...@googlegroups.com, W.S. Hager
On 4/12/2013 10:16 AM, W.S. Hager wrote:
Hi,

I'm stuck on this. I really want to understand how persevere 2.0 works, but there is too much magic to just see what's going on. The main problem is in perstore/model.js, and there's no documentation or comments:

- what does initializeRoot do, and what is the addClass parameter for?
This initializes and discovers all the data models, setting an unique id on each one and recording a map of them. The addClass parameter will create an additional meta data model that has an object corresponding to the schema for every other model. This is assigned to the "Class" property on the root data model

- what does createModelsFromModel do exactly?

This is similar to ModelsModel, in that it is a meta-level representation of other models, except in this case, it actually persists the data's schemas itself, and when new data models can be created by adding new objects/schemas to this meta-model (through the HTTP interface).

- what does ModelsModel do? It could use a better name...

This creates the reflective meta data model that essentials lists of all the other data models (and their schemas).

Anyway, let me know if there are aspects of this that you want more details on.
Thanks,
Kris

W.S. Hager

unread,
Apr 19, 2013, 10:09:14 AM4/19/13
to Kris Zyp, persevere...@googlegroups.com
Hi Kris,

Thanks for your elaborate answer. It really helps. What I'm not entirely clear on is when these functions get called. As I understand it, initializeRoot sounds like something that is meant to run only once, when the program is started in node. Other methods are clearly executed on each request, but according to my console there are other variants, e.g. when requesting a new model, specifically in persevere-example-wiki/app -> pinturaConfig.getDataModel. How does this work?

Thanks.
Wouter


2013/4/18 Kris Zyp <kri...@gmail.com>

Kris Zyp

unread,
Apr 19, 2013, 4:22:28 PM4/19/13
to W.S. Hager, persevere...@googlegroups.com
On 4/19/2013 8:09 AM, W.S. Hager wrote:
> Hi Kris,
>
> Thanks for your elaborate answer. It really helps. What I'm not
> entirely clear on is when these functions get called. As I understand
> it, initializeRoot sounds like something that is meant to run only
> once, when the program is started in node.

Yes, that is correct.
> Other methods are clearly executed on each request, but according to
> my console there are other variants, e.g. when requesting a new model,
> specifically in persevere-example-wiki/app ->
> pinturaConfig.getDataModel. How does this work?
Yes, getDataModel gets called to return the root of your data model, so
that can be called on each request. Generally you implement this as the
root part of your application (in app.js), to define your full data
model. You could use ModelsModel or createModelsFromModel to create
meta-models in your implementation in getDataModel.

Thanks,
Kris

W.S. Hager

unread,
Apr 19, 2013, 5:44:52 PM4/19/13
to Kris Zyp, persevere...@googlegroups.com
Great, thanks! But wouldn't using ModelsModel in getDataModel (i.e. per request) affect performance? Also, I noticed you use Object.defineProperty, so I think it wouldn't work in the first place?

Thanks,
Wouter


2013/4/19 Kris Zyp <kri...@gmail.com>

Kris Zyp

unread,
Apr 22, 2013, 11:58:14 AM4/22/13
to W.S. Hager, persevere...@googlegroups.com
On 4/19/2013 3:44 PM, W.S. Hager wrote:
> Great, thanks! But wouldn't using ModelsModel in getDataModel (i.e.
> per request) affect performance? Also, I noticed you use
> Object.defineProperty, so I think it wouldn't work in the first place?
Normally, you create your data model outside of getDataModel, and simply
return that data model in getDataModel. Therefore, you would only do the
creation of the data model once, and on each request you merely return a
reference to that model (or use multiple models, and use getDataModel to
choose which one to return).
Thanks,
Kris

W.S. Hager

unread,
Apr 22, 2013, 12:22:15 PM4/22/13
to persevere...@googlegroups.com
Hi Kris,

Well, I would like to re-creating the data model per request, because specific services can connect to their own MySQL databases or have their own mongo collections. I created separate folders for the datamodels, and mix in any specific models based on host or API. I copied the ModelsModel function to my app, but without the defineProperty clause. It works, so that's great.

Thanks,
Wouter


2013/4/22 Kris Zyp <kri...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Persevere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to persevere-frame...@googlegroups.com.
To post to this group, send email to persevere...@googlegroups.com.
Visit this group at http://groups.google.com/group/persevere-framework?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Sri Vidhya

unread,
May 14, 2013, 8:05:46 AM5/14/13
to persevere...@googlegroups.com, W.S. Hager
HI am sending the header information (like below)to node.js on the server side, but it is not working.
How to pass the header information to server from client. and how to get on the server side .
Pls if anyone knows... let me know
 
this is the ajax request call fron client html page:

client.html:
 
          $.ajax({
                    //  url:'http://10.163.14.52:8888/all',
                    url:'http://IPaddress:port/getTaluk/',
                    type:'POST',
                    datatype:'json',
                    data:inputVal,
                    headers : {
                                'emp_value':s,
                                'signature':hash,
                                'timestamp':t
                                },
                    complete:function(){
                        alert(":"+data);
                     
                      
                    }
                 });

on the server side am getting like this using nodejs:

  console.log("emp_value:"+req.headers['emp_value']);
but i can't able to get it.


--
You received this message because you are subscribed to the Google Groups "Persevere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to persevere-frame...@googlegroups.com.
To post to this group, send email to persevere...@googlegroups.com.
Visit this group at http://groups.google.com/group/persevere-framework?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





--
Thanks,
N. Srividhya.
Reply all
Reply to author
Forward
0 new messages