Re: Datasource schemas defined into models

2011-04-01 Thread Clément Hallet
Your trick would worf fine thanks. However, something still seems
wrong for me, since i'm trying not to hack the whole design.

Datasource::isInterfaceSupported() do what I would expect (it tells if
a method is implemented).

But Datasource::listSources() does actually not list the sources
(instead it caches them from its overloaded method, they don't even
have the same signature).
In the case of inherited datasources without it's own listSources
method, the Datasource::listSources() take its place through
inheritance, but it's useless because it would just try to cache
something that don't even exist.

--
Clément



On 1 avr, 04:35, "Dr. Loboto"  wrote:
> Overload DataSource::isInterfaceSupported() method to not report
> listSources() method as available if you don't like it so much.
>
> On Mar 31, 4:34 pm, Clément Hallet  wrote:
>
>
>
>
>
>
>
> > I overloaded the $mydatasource->describe() method to return the 
> > $model->_schema value ($model comes as a parameter to describe). It would
>
> > work but an other issue (at least, it seems to be for me).
>
> > My real issue is elsewhere and I wonder if it's a mistake in the
> > global design. Let's focus on it :
>
> > The function Model->setSource() is called to link a model to a table.
> > While doing it, there is the next test : 
> > "if($db->isInterfaceSupported('listSources'))" and erase the $model->_schema
>
> > from the schema if true. I guess it's done to later rely on a schema
> > coming from the datasource.
>
> > And so if no schema is coming from the datasource, the $model->_schema
> > would be used instead. But it's not ! because even when not
> > implementing the "mydatasource->listSources" method, it comes from the
> > Datasoure inheritance. It means that every one datasource (according
> > it extends DataSource) can't rely on its $models->_schema (because
> > they're always reseted).
>
> > The aim of this inherited method is to cache the sources ant it's
> > called internally by its overloading methods ("parent::listSources()")
> > but it can't be a replacement (because the cache may not be already
> > setted). So there is no point to have the same method names and get
> > inheritance.
>
> > I made the according changes herehttp://goo.gl/QTBtJandwould like
> > to have others' opinion before to make a pull request.
>
> > Please let me know if I missed something in that description.
>
> > On 30 mar, 04:43, "Dr. Loboto"  wrote:
>
> > > Model have schema() method which call describe() method of data source
> > > if supported. For manual per-model schemas you can override its
> > > schema() method. For datasource-managed schemas you should take a look
> > > into its describe() method.
>
> > > On 29 мар, 03:50, Clément Hallet  wrote:
>
> > > > Hello CakePHP,
>
> > > > Trying to implement a CouchDB datasource and to closely follow the
> > > > CakePHP guidelines,
> > > > I'm in a trick situation :
>
> > > > When saving a new record, it's required to have the fields matching
> > > > the schema 
> > > > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
> > > > So, i put a $_schema in my model to match what i want to save.
>
> > > > The problem is that this schema is automatically reseted to "array()"
> > > > at initialization 
> > > > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
>
> > > > Even when removing the "listSources" method from my Datasource, it's
> > > > still reseted because of the test 
> > > > "$db->isInterfaceSupported('listSources')"  :
>
> > > > In fact my datasource extends "Datasource" (i think it's required)
> > > > which have it's own "listSources" method for caching children ones.
>
> > > > So I would like to ask : is this Datasource->listSources method is
> > > > compatible with per-Model defined schemas ? or am I doing wrong ?
>
> > > > --
> > > > Clément

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Datasource schemas defined into models

2011-03-31 Thread Dr. Loboto
Overload DataSource::isInterfaceSupported() method to not report
listSources() method as available if you don't like it so much.

On Mar 31, 4:34 pm, Clément Hallet  wrote:
> I overloaded the $mydatasource->describe() method to return the 
> $model->_schema value ($model comes as a parameter to describe). It would
>
> work but an other issue (at least, it seems to be for me).
>
> My real issue is elsewhere and I wonder if it's a mistake in the
> global design. Let's focus on it :
>
> The function Model->setSource() is called to link a model to a table.
> While doing it, there is the next test : 
> "if($db->isInterfaceSupported('listSources'))" and erase the $model->_schema
>
> from the schema if true. I guess it's done to later rely on a schema
> coming from the datasource.
>
> And so if no schema is coming from the datasource, the $model->_schema
> would be used instead. But it's not ! because even when not
> implementing the "mydatasource->listSources" method, it comes from the
> Datasoure inheritance. It means that every one datasource (according
> it extends DataSource) can't rely on its $models->_schema (because
> they're always reseted).
>
> The aim of this inherited method is to cache the sources ant it's
> called internally by its overloading methods ("parent::listSources()")
> but it can't be a replacement (because the cache may not be already
> setted). So there is no point to have the same method names and get
> inheritance.
>
> I made the according changes herehttp://goo.gl/QTBtJand would like
> to have others' opinion before to make a pull request.
>
> Please let me know if I missed something in that description.
>
> On 30 mar, 04:43, "Dr. Loboto"  wrote:
>
>
>
>
>
>
>
> > Model have schema() method which call describe() method of data source
> > if supported. For manual per-model schemas you can override its
> > schema() method. For datasource-managed schemas you should take a look
> > into its describe() method.
>
> > On 29 мар, 03:50, Clément Hallet  wrote:
>
> > > Hello CakePHP,
>
> > > Trying to implement a CouchDB datasource and to closely follow the
> > > CakePHP guidelines,
> > > I'm in a trick situation :
>
> > > When saving a new record, it's required to have the fields matching
> > > the schema 
> > > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
> > > So, i put a $_schema in my model to match what i want to save.
>
> > > The problem is that this schema is automatically reseted to "array()"
> > > at initialization 
> > > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
>
> > > Even when removing the "listSources" method from my Datasource, it's
> > > still reseted because of the test 
> > > "$db->isInterfaceSupported('listSources')"  :
>
> > > In fact my datasource extends "Datasource" (i think it's required)
> > > which have it's own "listSources" method for caching children ones.
>
> > > So I would like to ask : is this Datasource->listSources method is
> > > compatible with per-Model defined schemas ? or am I doing wrong ?
>
> > > --
> > > Clément

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Datasource schemas defined into models

2011-03-31 Thread Clément Hallet
I overloaded the $mydatasource->describe() method to return the $model-
>_schema value ($model comes as a parameter to describe). It would
work but an other issue (at least, it seems to be for me).

My real issue is elsewhere and I wonder if it's a mistake in the
global design. Let's focus on it :

The function Model->setSource() is called to link a model to a table.
While doing it, there is the next test : "if($db-
>isInterfaceSupported('listSources'))" and erase the $model->_schema
from the schema if true. I guess it's done to later rely on a schema
coming from the datasource.

And so if no schema is coming from the datasource, the $model->_schema
would be used instead. But it's not ! because even when not
implementing the "mydatasource->listSources" method, it comes from the
Datasoure inheritance. It means that every one datasource (according
it extends DataSource) can't rely on its $models->_schema (because
they're always reseted).

The aim of this inherited method is to cache the sources ant it's
called internally by its overloading methods ("parent::listSources()")
but it can't be a replacement (because the cache may not be already
setted). So there is no point to have the same method names and get
inheritance.

I made the according changes here http://goo.gl/QTBtJ and would like
to have others' opinion before to make a pull request.

Please let me know if I missed something in that description.









On 30 mar, 04:43, "Dr. Loboto"  wrote:
> Model have schema() method which call describe() method of data source
> if supported. For manual per-model schemas you can override its
> schema() method. For datasource-managed schemas you should take a look
> into its describe() method.
>
> On 29 мар, 03:50, Clément Hallet  wrote:
>
>
>
>
>
>
>
> > Hello CakePHP,
>
> > Trying to implement a CouchDB datasource and to closely follow the
> > CakePHP guidelines,
> > I'm in a trick situation :
>
> > When saving a new record, it's required to have the fields matching
> > the schema 
> > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
> > So, i put a $_schema in my model to match what i want to save.
>
> > The problem is that this schema is automatically reseted to "array()"
> > at initialization 
> > :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
>
> > Even when removing the "listSources" method from my Datasource, it's
> > still reseted because of the test 
> > "$db->isInterfaceSupported('listSources')"  :
>
> > In fact my datasource extends "Datasource" (i think it's required)
> > which have it's own "listSources" method for caching children ones.
>
> > So I would like to ask : is this Datasource->listSources method is
> > compatible with per-Model defined schemas ? or am I doing wrong ?
>
> > --
> > Clément

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Datasource schemas defined into models

2011-03-29 Thread Dr. Loboto
Model have schema() method which call describe() method of data source
if supported. For manual per-model schemas you can override its
schema() method. For datasource-managed schemas you should take a look
into its describe() method.

On 29 мар, 03:50, Clément Hallet  wrote:
> Hello CakePHP,
>
> Trying to implement a CouchDB datasource and to closely follow the
> CakePHP guidelines,
> I'm in a trick situation :
>
> When saving a new record, it's required to have the fields matching
> the schema 
> :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
> So, i put a $_schema in my model to match what i want to save.
>
> The problem is that this schema is automatically reseted to "array()"
> at initialization 
> :https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model
>
> Even when removing the "listSources" method from my Datasource, it's
> still reseted because of the test "$db->isInterfaceSupported('listSources')"  
> :
>
> In fact my datasource extends "Datasource" (i think it's required)
> which have it's own "listSources" method for caching children ones.
>
> So I would like to ask : is this Datasource->listSources method is
> compatible with per-Model defined schemas ? or am I doing wrong ?
>
> --
> Clément

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Datasource schemas defined into models

2011-03-29 Thread Clément Hallet
Hello CakePHP,

Trying to implement a CouchDB datasource and to closely follow the
CakePHP guidelines,
I'm in a trick situation :

When saving a new record, it's required to have the fields matching
the schema : 
https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model.php#L1308
So, i put a $_schema in my model to match what i want to save.

The problem is that this schema is automatically reseted to "array()"
at initialization : 
https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model.php#L776

Even when removing the "listSources" method from my Datasource, it's
still reseted because of the test "$db-
>isInterfaceSupported('listSources')"  :
In fact my datasource extends "Datasource" (i think it's required)
which have it's own "listSources" method for caching children ones.


So I would like to ask : is this Datasource->listSources method is
compatible with per-Model defined schemas ? or am I doing wrong ?


--
Clément

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Datasource schemas defined into models

2011-03-29 Thread Clement Hallet
Hello CakePHP,

Trying to implement a CouchDB datasource and to closely follow the CakePHP 
guidelines, 
I'm in a trick situation : 

When saving a new record, it's required to have the fields matching the schema 
: https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model.php#L1308
So, i put a $_schema in my model to match what i want to save.

The problem is that this schema is automatically reseted to "array()" at 
initialization : 
https://github.com/cakephp/cakephp/blob/master/cake/libs/model/model.php#L776

Even when removing the "listSources" method from my Datasource, it's still 
reseted because of the test "$db->isInterfaceSupported('listSources')"  :
In fact my datasource extends "Datasource" (i think it's required) which have 
it's own "listSources" method for caching children ones.


So I would like to ask : is this Datasource->listSources method is compatible 
with per-Model defined schemas ? or am I doing wrong ?


-- 
Clément


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php