How is the development going?

Asked by Bruno Cassol on 2009-08-07

First of all, great piece of code!

I'd like to know how the development is going. Is there support for many-many relations? How?

I'd like to suggest a cleanup in the download file or at least 2 versions: normal.tgz and dev.tgz (with testing etc...) files.

Thanks for attention!

Question information

Language:
English Edit question
Status:
Solved
For:
CoughPHP Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Cassol
Solved:
2009-08-10
Last query:
2009-08-10
Last reply:
2009-08-10
Anthony Bush (awbush) said : #1

Hi Bruno,

Thanks for your questions. Development is slow, but not stopped. Some of the things we have planned for a 1.4 release can be seen at:

https://blueprints.launchpad.net/coughphp/+milestone/1.4

One of the items there is "many-to-many" related:

https://blueprints.launchpad.net/coughphp/+spec/finish-m2m-api

As mentioned in the 2008 meeting minutes, we moved away from previous many-to-many behavior for a couple reasons. We plan to restore some support, but in the meantime you can use the existing support.

Many-to-many is really just one-to-many-to-one, i.e. "one-to-many" & "one". In other words, if you have a schema (user, user2bookmark, bookmark), then you might think a user can have many bookmarks or a bookmark can be marked by many users. You might construct the user2bookmark table to have user_id and bookmark_id. But this may not be enough. You also may want the date the user added the bookmark, their rating for it, how many times they've visited it, etc. This data would also live on the join table.

The question then is how do you get a user's bookmarks AND the extra meta data (e.g. rating)? As CoughPHP works now, you could do it like this:

 <?php
 $user = User::constructByKey($userId);
 $joins = $user->getUser2bookmark_Collection();
 foreach ($joins as $bookmarkMeta)
 {
  $bookmark = $bookmarkMeta->getBookmark_Object();
  $rating = $bookmarkMeta->getRating();
  // both the bookmark object and the join data are available
 }

In old versions of CoughPHP, you'd get/set join fields on other side of the join:

 <?php
 $user = User::constructByKey($userId);
 foreach ($user->getBookmark_Collection() as $bookmark)
 {
  $rating = $bookmark->getJoinField('rating');
  // both the bookmark object and the join data are available
 }
 // going backwards using `$bookmark->getUser_Collection()` and calling `getJoinField()` on the user objects also worked.

Anthony Bush (awbush) said : #2

Bruno,

Can you elaborate a little more on the cleanup / 2 different download versions? We used to not include the "tests" folder, but added it after users requested it. While it can be easily deleted, it does more than double the size of the release; is this the problem?

I don't see the need in a "dev" download as the true developer package is in version control: things get removed during the release process. Here's what were running in the versioned checkout to make a release:

http://bazaar.launchpad.net/%7Ecoughphp/coughphp/1.3/annotate/head%3A/scripts/make_release

Thank you for helping us make CoughPHP better!

Bruno Cassol (brunocassol) said : #3

Hey Antony! I'm shocked by the attention you give to people here! Thank you!

Thanks for taking the time to spoon-feed me with examples on many-many relations!

About the "cleanup". Well, looking better the package is okay. 2 types of packages might confuse people. And the test is a good practice.

Keep the good work. It's good that you slowed it, otherwise you could get burned by too much work. As time goes I'm sure you will find some time to get things going again.

Thanks!