edaros | 3 Sep 09:22
Picon
Favicon

Re: Sample of relationships


Hi!
Thank you for the answer, i managed to build a sample application based on
the addressbook sample (i had already read the various tutorial but they
where quite obscure on various stesps...) and i created a small app mySql
based with one to many relationships.
You can download it at  http://www.kendar.org/helma/addressbook.zip
Addressbook extended sample 
Everything seems to work as expected, building a Person object with child
Event objects But...
1) I did'nt found a way to put the "create.hac" into the child object
directory, that seems to me more correct from a design point of view, i had
to put the Event creation .hac  into the Person directory
2) I wish now (even to practice on the "object" keyword) to link the Person
object from the owned Event, kind of a back link. I know there are other
ways but this is a kind of a test for the usage i wish to do with Helma. The
scope is building a one to one relationship from the Event object to the
owner Person

Thank you in advance for the help

Enrico Da Ros
--

-- 
View this message in context: http://www.nabble.com/Re%3A-Sample-of-relationships-tf4351150s2589.html#a12457435
Sent from the Helma - User mailing list archive at Nabble.com.
Anton Pirker | 5 Sep 07:27

Invoking onPersist of Base-Prototype

Hi List!

I have a base prototype from which i inherit quite a bunch of other 
prototypes.
Now, if I store an object of one of the child-prototypes i want the 
onPersist()-function of the base-prototype to be called.

(Background: I don't want to implement a "if you are stored, make this 
and this" in every child-prototype. if an object has a specific 
base-prototype than some code should automatically be executed when 
storing the object.)

How can i achieve this?

Thanks,
Anton
Hannes Wallnoefer | 5 Sep 10:27
Picon
Favicon
Gravatar

Re: Invoking onPersist of Base-Prototype

Hi Anton,

2007/9/5, Anton Pirker <helma <at> gmiatlich.net>:
> Hi List!
>
> I have a base prototype from which i inherit quite a bunch of other
> prototypes.
> Now, if I store an object of one of the child-prototypes i want the
> onPersist()-function of the base-prototype to be called.

This is what should happen by default. If the parent prototype
onPersist() isn't called (and the child proto doesn't override it),
then it's a bug.

hannes
Anton Pirker | 5 Sep 10:49

Re: Invoking onPersist of Base-Prototype

Hi Hannes!
> 
> This is what should happen by default. If the parent prototype
> onPersist() isn't called (and the child proto doesn't override it),
> then it's a bug.
> 

Oh. I checked it again, and found out that the _extends was wrong. I 
fixed the Type and now it is working like expected..

It seems that at "early bird before sunrise"-coding my mind is not in 
perfect shape and i tend to overlook obvious mistakes ;)

have a nice day!
anton
Anton Pirker | 5 Sep 12:58

Adding objects to generic object reference in onPersist()

Hi List!

I have a Prototype 'Change'. This is some sort of changelog for 
HopObjects. I add it to Objects via a generic object reference (as 
described at [1])

Everythink works fine if i add the Change the normal way to my object, like:

   var venue = new Venue("Supervenue");
   var ch = new Change(u);
   venue.changes.add(ch);

But i want to add the Changelog automatically. So i wrote a onPersist() 
in HopObject.

So everytime when i store something i do the following:

function onPersist() {

   //check if we have a collection
   //to store the changes to
   if(this.changes) {
     //create the change and add it.
     var ch = new Change(u);	
     this.changes.add(ch);
   }
}

But the Change is not stored into the Database and I do not get an error 
message.
(Continue reading)

Anton Pirker | 7 Sep 10:04

Re: Adding objects to generic object reference in onPersist()

Just a little update!

I patched my local Helma and made me my own afterPersist()-Call and 
tried the same thing. Same result.

When i was debugging my Application with the debugger shipped with Helma 
i recognized, that there is some bug in the watch-window.
I was watching "this" and when the code jumped into a constructor() the 
"this" didn't change. So if i am in Venue-Code "this" is "[HopObject 
Venue]". When the code jumps into the constructor() of Change, "this" 
remained "[HopObject Venue]"! When i use app.log() to debug "this" 
changes to "[HopObject Change]".

But back to my problem: I don't have a clue how to solve the Problem. 
(Of course i could solve it somehow with database Triggers, but i would 
prefer to do it with Helma)

Does no one has a clue or a hint for me? Every help is appreciated.
I wonder if no one has dome something like this before..

Cheers,
Anton

Anton Pirker schrieb:
> Hi List!
> 
> I have a Prototype 'Change'. This is some sort of changelog for 
> HopObjects. I add it to Objects via a generic object reference (as 
> described at [1])
> 
(Continue reading)

Joshua Paine | 7 Sep 14:11

Re: Adding objects to generic object reference in onPersist()

Anton Pirker wrote:
>>   var venue = new Venue("Supervenue");
>>   var ch = new Change(u);
>>   venue.changes.add(ch);

This is probably a thread hijack, but what are you passing to these 
constructors and what does it do? I tried writing my own constructors 
before and wasn't able to do it in a way that allowed the constructed 
object to keep its HopObject nature. (Which consequently meant that the 
object would not be stored, which is the only plausible connection with 
your problem.)
Anton Pirker | 25 Sep 06:54

Re: Adding objects to generic object reference in onPersist()

Good Morning!

I got an reply to my question from Kris Leite yesterday via direct mail. 
I just wanted to post it here to have a possible solution for others 
with the same problem.

His patch works great, but i do not know how much impact it has on 
Helmas performance or other stuff i am unaware of. Could some of the 
guys knowing about the internal stuff of Helma have a look on the patch 
and give some comment?

Thanks, Anton

Kris wrote:

 > Hi Anton,
 >
 > > > I think it is because onPersist is called right before the object is
 > > > stored. So when a create a 'Change' object and add it to a
 > > > 'changes'-collection of this in onPersist this does not have an 
finale
 > > > id and so the 'Change'-Object does not know who his parent is.

 > I had the same idea of wanting to add a history of changes to a
 > HopObject. I also have very similar code in the onPersist to implement
 > that idea and got the same results.  This issue is not Helma knowing
 > how to store it, it just ignores any additional HopObject changes
 > during the commit. I added a modification to the commit routine of
 > Transactor.java to pickup any additional HopObject changes during the
 > commit operation.  The code changes are very simple, in
(Continue reading)

Kris Leite | 25 Sep 08:23

Re: Adding objects to generic object reference in onPersist()

Hi Anton,

Sorry, but I didn't intend to make that a personal response.  Took the 
wrong option by accident.

Thanks for reposting.

-Kris

Anton Pirker wrote:
> Good Morning!
>
> I got an reply to my question from Kris Leite yesterday via direct mail. 
> I just wanted to post it here to have a possible solution for others 
> with the same problem.
>
> His patch works great, but i do not know how much impact it has on 
> Helmas performance or other stuff i am unaware of. Could some of the 
> guys knowing about the internal stuff of Helma have a look on the patch 
> and give some comment?
>
> Thanks, Anton
>
> Kris wrote:
>
>  > Hi Anton,
>  >
>  > > > I think it is because onPersist is called right before the object is
>  > > > stored. So when a create a 'Change' object and add it to a
>  > > > 'changes'-collection of this in onPersist this does not have an 
(Continue reading)

Anton Pirker | 25 Sep 09:03

Deep Macro Invocation

hello all!

i just tried to use deep macros the first time, and i must admit: i am 
too dump.

i have a prototype Venue which has a object-relation to a object of the 
prototype City:

----
Venue/type.properties:

city              = Object(City)
city.local        = city_id
city.foreign      = city_id
----

Now i am in a skin of the Venue and want to call: <% this.city.name %>
where "name" is a property of the City.

----
City/type.properties:

_db         = shnitzl
_table      = cities
_id         = city_id

_parent     = venue.city, root.cities

name        = city_name
zipcode     = city_zipcode
(Continue reading)


Gmane