Re: Changing datasources to support web services.

2007-05-24 Thread shmit

On May 23, 7:44 pm, gwoo [EMAIL PROTECTED] wrote:
 then create a connection in database.php that can be used.
 you could use the xml class to get the web service.

This is the part I'm missing. I can't for the life of me figure out
how to get the data source loaded. The docs turn up nothing. Google
turns up nothing, and I can't pick apart the source enough (yet) to
figure out how to load it.

The only thing I've found was this comment:

 * @param string $name The name of the DataSource, as defined in app/
config/connections


Of course, the file doesn't exist, and I can't even tell if its
getting loaded at all, nor what format it's supposed to be in.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Changing datasources to support web services.

2007-05-24 Thread shmit

Because I like to answer my own questions, I found the solution to
this.

Here's how you set up the map for your new service:

name your file 'app/models/datasources/type_source.php' (e.g.,
'web_services_source.php')
your class name will be the StudlyCaps version of that (e.g.,
'WebServicesSource'), defined in the above file.

Set up a map for that datasource to a name in database.php's
DATABASE_CONFIG class:

var $whatever = array('datasource' = 'type'); (e.g.: var
$web_services = array('datasource' = 'web_services'))

The datasource value is the name of your datasource file w/o the
'_source.php' at the end. The name of the variable ($web_services),
can be whatever you want.

In your model, tell it to use your new data source. I did this in the
constructor with:

$this-setDataSource('whatever');

Where 'whatever' is the name of your variable in the DATABASE_CONFIG
class.

I'm probably doing that last part wrong, but it seems to work for me.

On May 24, 11:01 am, shmit [EMAIL PROTECTED] wrote:
 On May 23, 7:44 pm, gwoo [EMAIL PROTECTED] wrote:

  then create a connection in database.php that can be used.
  you could use the xml class to get the web service.

 This is the part I'm missing. I can't for the life of me figure out
 how to get the data source loaded. The docs turn up nothing. Google
 turns up nothing, and I can't pick apart the source enough (yet) to
 figure out how to load it.

 The only thing I've found was this comment:

  * @param string $name The name of the DataSource, as defined in app/
 config/connections

 Of course, the file doesn't exist, and I can't even tell if its
 getting loaded at all, nor what format it's supposed to be in.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Changing datasources to support web services.

2007-05-24 Thread djiize

instead of doing:
$this-setDataSource('whatever');

you can do that:
class MyModel extends AppModel {
  $useDbConfig = 'whatever';
  //...
}

On 24 mai, 17:37, shmit [EMAIL PROTECTED] wrote:
 Because I like to answer my own questions, I found the solution to
 this.

 Here's how you set up the map for your new service:

 name your file 'app/models/datasources/type_source.php' (e.g.,
 'web_services_source.php')
 your class name will be the StudlyCaps version of that (e.g.,
 'WebServicesSource'), defined in the above file.

 Set up a map for that datasource to a name in database.php's
 DATABASE_CONFIG class:

 var $whatever = array('datasource' = 'type'); (e.g.: var
 $web_services = array('datasource' = 'web_services'))

 The datasource value is the name of your datasource file w/o the
 '_source.php' at the end. The name of the variable ($web_services),
 can be whatever you want.

 In your model, tell it to use your new data source. I did this in the
 constructor with:

 $this-setDataSource('whatever');

 Where 'whatever' is the name of your variable in the DATABASE_CONFIG
 class.

 I'm probably doing that last part wrong, but it seems to work for me.

 On May 24, 11:01 am, shmit [EMAIL PROTECTED] wrote: On May 23, 7:44 pm, 
 gwoo [EMAIL PROTECTED] wrote:

   then create a connection in database.php that can be used.
   you could use the xml class to get the web service.

  This is the part I'm missing. I can't for the life of me figure out
  how to get the data source loaded. The docs turn up nothing. Google
  turns up nothing, and I can't pick apart the source enough (yet) to
  figure out how to load it.

  The only thing I've found was this comment:

   * @param string $name The name of the DataSource, as defined in 
  app/
  config/connections

  Of course, the file doesn't exist, and I can't even tell if its
  getting loaded at all, nor what format it's supposed to be in.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Changing datasources to support web services.

2007-05-23 Thread shmit

I've seen this question asked in this group a few times, but I
couldn't really parse out an answer, so I'm asking again.

From what I've read of the source code, it /appears/ as though you
can set the datasource for a model to, for instance, use a web
service.

It appears as though it's not much harder than overriding create/read/
update/delete in a subclass of DataSource. However, I can't seem to
get the data source in use at all. I suspect this has to do with which
files get loaded when (h00ray for file-based source code!).

I'm also not quite sure where to put the code for this. I've shoved
it in app/vendors now, but that doesn't seem quite right, since it
ain't third party, but a first-party generic library.

So, I have this data source defined in 'app/vendors/
web_services_data_source.php', and I have a model which require()s it
(again, not very pretty, and I'd like to not have to do that in every
model), and that's fine, but when I try to load the page I get:

[SNIP]
Fatal error: ConnectionManager::getDataSource - Non-existent data
source WebServicesDataSource in /home/bjc/src/cake_test/htdocs/cake/
libs/model/connection_manager.php on line 110
[SNIP]

And I can't figure out why. By this point, my model has been loaded
and the data source module has been loaded by require() (I know,
because if I change the arg to require, it barfs without displaying
the message above). So why can't ConnectionManager find it?

I specify $this-setDataSource('WebServicesDataSource') in the
constructor of the model I'm using. I've also tried
'web_services_data_source', but it has the same error.

Can anyone give me any pointers?

-bjc


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Changing datasources to support web services.

2007-05-23 Thread gwoo

you would put a class that extends DataSource in /app/models/
datasources
then create a connection in database.php that can be used.
you could use the xml class to get the web service.

here is a datasource I started on for imap. never completed beyond
making the initial connection, but it provides a good skeleton for
your own datasource. http://bin.cakephp.org/view/1531034840

I know someone was working on an xml datasource. He was in the IRC
channel a little while ago, but I have not heard from him in a little
while.

hope this helps.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---