Help Upload plugin: validation rules

2012-06-30 Thread Matteo Landi
Hi all, is anybody using Jose Gonzalez's upload plugin [1]? I have a couple of open issues regarding its integration inside my web app, but before filing a bug I wanted to be sure I was doing things the right way. I attached a couple of validation rules to my Model's attachment property and they

Re: i

2012-05-16 Thread Matteo Landi
html tags were rendered properly! Mea culpa! Cheers, Matteo On Sat, May 5, 2012 at 12:01 PM, Matteo Landi mat...@matteolandi.net wrote: Hi everybody, Could you tell me what is the right way to display html formatted content extracted from the database?  Taking the blog tutorial

i

2012-05-05 Thread Matteo Landi
Hi everybody, Could you tell me what is the right way to display html formatted content extracted from the database? Taking the blog tutorial as example, how is possible to let users create posts containing html tags such as `strong`, `em`, `ul` and so forth? Thanks, Matteo --

Display unescaped html elements

2012-05-05 Thread Matteo Landi
On May/05, Matteo Landi wrote: Hi everybody, Could you tell me what is the right way to display html formatted content extracted from the database? Taking the blog tutorial as example, how is possible to let users create posts containing html tags such as `strong`, `em`, `ul` and so

Re: Mock and test uploads

2012-04-28 Thread Matteo Landi
I asked more or less the same question some months ago, and the best solution I come up with was to populate $_FILES by hand and wrap move_uploaded_file into a controller method, so that it can be easily mocked inside your tests. Matteo On Apr/26, jeremyharris wrote: I would take cues from the

Re: HABTM Fixture

2012-01-23 Thread Matteo Landi
On Jan/22, Thiago Silva wrote: Hi, How can I create a fixture for a HABTM table? Imagine an app where users are linked together (friendship): you should have a Model named `UsersUser' and the fixture `UsersUserFixture'. At this point inside your tests you should be able able to use the

Use Vagrant to develop CakePHP applications

2012-01-08 Thread Matteo Landi
Hi guys, I would like to share with you a small article [1] I wrote which describes how to use Vagrant to create a customized development virtual environment for CakePHP: hope this doesn't get tagged as spammy! If you have any comments, advices or whatever you want, don't be shy: I will try my

Re: campo id

2012-01-06 Thread Matteo Landi
On Jan/05, Laerte M. Rodrigues wrote: se a tabela possui chave primaria no modelo declare var $primary = nomeCampo; assim, será a chave primária, caso seja composta, utilize array var $primary = array(Campo1,Campo2); Em 5 de janeiro de 2012 16:14, Filippi Rizzi

Re: Test controllers throwing exceptions

2012-01-06 Thread Matteo Landi
On Jan/02, AD7six wrote: On Dec 28 2011, 4:22 pm, Matteo Landi mat...@matteolandi.net wrote: Hi everybody, I have a custom exception handler for all the exceptions raised inside controllers; when I run the controllers' testsuite, I noticed that exceptions are propagated

Re: REST Error Handling

2012-01-03 Thread Matteo Landi
On Jan/02, Will wrote: Hi all, I'm looking for a way to return a generic error every time something goes wrong with a REST request. So for example, I would like to return a simple, XML response like: error There was a problem processing your request. /error Anytime something goes

Re: Test controllers throwing exceptions

2012-01-02 Thread Matteo Landi
Bump! On Dec/28, Matteo Landi wrote: Hi everybody, I have a custom exception handler for all the exceptions raised inside controllers; when I run the controllers' testsuite, I noticed that exceptions are propagated to the tests instead of being handled by my handler. Is this the normal

Re: Extend ControllerTestCase

2012-01-02 Thread Matteo Landi
Bump! On Dec/28, Matteo Landi wrote: Excuse me for bringing up this old topic, but I have one more question. My TestController wrapper object contains a method which tests the authentication layer (it's a custom layer, not the one shipped within cakephp); consequently all the controllers

Re: Extend ControllerTestCase

2011-12-28 Thread Matteo Landi
this? (other than workarounds like $this-_testAuthKeys..) Regards, Matteo On Dec/11, Matteo Landi wrote: Thank for the fast response: - placed the wrapper inside app/Lib/Test - added App::uses('MyWrapper...', 'Test') on top of all my controllers tests - changed 'extends ControllerTestCase

Test controllers throwing exceptions

2011-12-28 Thread Matteo Landi
Hi everybody, I have a custom exception handler for all the exceptions raised inside controllers; when I run the controllers' testsuite, I noticed that exceptions are propagated to the tests instead of being handled by my handler. Is this the normal behaviour? What if I want to make some

Re: Problem with transaction in version 2.0

2011-12-21 Thread Matteo Landi
On Wed, Dec 21, 2011 at 9:52 AM, socrates socrates.alessan...@gmail.com wrote: Thanks all for the help, I solved in this way: Are you telling us that now transactions are working properly? 1) I move the code form the controller to the model. (I don't really know if this help!) 2) I used the

Re: Problem with transaction in version 2.0

2011-12-20 Thread Matteo Landi
On 12/20, socrates wrote: I found a possible solution here! Transaction Commit and Rollbackhttp://ask.cakephp.org/questions/view/rollback_and_commit Tnx. Let us know if that solves your problems. Regards, Matteo -- Our newest site for the community: CakePHP Video Tutorials

Re: Problem with transaction in version 2.0

2011-12-20 Thread Matteo Landi
On 12/20, socrates wrote: No in fact it does not solve my problem, but maybe i don't understand very well. This is my piece of code: $this-StadiobingoBet-query('SET AUTOCOMMIT = OFF'); debug($this-StadiobingoBet-begin()); if (!$this-StadiobingoBet-saveAll(null, array('atomic' = true,

Re: CakePHP and Sqlite

2011-12-19 Thread Matteo Landi
On 12/19, NaeiKinDus wrote: Hi there, Sorry for the thread hijacking / bump, but a little more information on this topic could help some people. Is there anything else to do/ check to get it working ? In my case, CakePHP cannot connect to the database, even though I have the PDO installed

Re: Locked tables in transactions

2011-12-16 Thread Matteo Landi
Bump! On Tue, Dec 13, 2011 at 12:18 AM, Matteo Landi mat...@matteolandi.net wrote: Hi everybody, could someone tell me what tables get locked during an explicit CakePHP transaction? $dataSource = $this-getDataSource(); $dataSource-begin(); // transaction logic $dataSource-commit

Re: Testing image upload

2011-12-13 Thread Matteo Landi
On Tue, Dec 13, 2011 at 3:49 AM, leigh phpnote...@gmail.com wrote: Hello Matteo, Looks like the only way is to wrap the functions, on a second look Sebastian Bergmann's php-test-helpers is only for user created functions. kind regards, Leigh Leigh, thanks for the hint. I made a quick

Re: Testing image upload

2011-12-12 Thread Matteo Landi
On Mon, Dec 12, 2011 at 4:46 AM, leigh phpnote...@gmail.com wrote: Hi Matteo, Wrap move_uploaded_file and is_uploaded_file inside the controller function moveUploadedFIle($filename, $destination) {  return move_uploaded_file($filename, $destination); } function moveUploadedFIle($filename,

Locked tables in transactions

2011-12-12 Thread Matteo Landi
Hi everybody, could someone tell me what tables get locked during an explicit CakePHP transaction? $dataSource = $this-getDataSource(); $dataSource-begin(); // transaction logic $dataSource-commit(); // or $dataSource-rollback(); Imagine to update a Post if and only if it exists; we can use

Extend ControllerTestCase

2011-12-11 Thread Matteo Landi
Hi, where is the right place to put a class which extends and add some functionalities to ControllerTestCase so that I can it inside all my controllers tests? Imagine all my controllers tests implement a testAction wrapper: it would be handy to extend ControllerTestCase, implement such wrapper in

Re: Testing image upload

2011-12-11 Thread Matteo Landi
bump! On Sat, Dec 3, 2011 at 8:01 PM, Matteo Landi landima...@gmail.com wrote: Hi list, what is the right way (if any) to test a controller which handles file uploads? At the moment I fill $_FILES with an array containing the fields expected by the controller (i.e. 'tmp_name', 'size', etc

Re: Extend ControllerTestCase

2011-12-11 Thread Matteo Landi
On 11 Dez., 11:30, Matteo Landi mat...@matteolandi.net wrote: Hi, where is the right place to put a class which extends and add some functionalities to ControllerTestCase so that I can it inside all my controllers tests? Imagine all my controllers tests implement a testAction wrapper

Re: Edit an object without creating it

2011-12-08 Thread Matteo Landi
Thank you guys for the precious information you shared with me. Reading the link euromark posted, I found a lot of similarities with our controller implementation: first of all we call a function validateInput (we are better off changing its name to something more compatible with cakephp use of

Re: Edit an object without creating it

2011-12-07 Thread Matteo Landi
On Wed, Dec 7, 2011 at 9:03 AM, Geoff Douglas drdouglas...@gmail.com wrote: I think what you are looking for is the Model-exists() method. Please see a baked Cake 2.0 edit method. /**  * edit method  *  * @param string $id  * @return void  */ public function edit($id = null) {

Re: Edit an object without creating it

2011-12-07 Thread Matteo Landi
On Wed, Dec 7, 2011 at 9:35 AM, AD7six andydawso...@gmail.com wrote: On Dec 3, 7:43 pm, Matteo Landi landima...@gmail.com wrote: Hi everybody, is there a way, given an id, to invoke Model-save() (or anything else) to update the relative record if and only if the id is valid? yes, you only

Re: Edit an object without creating it

2011-12-07 Thread Matteo Landi
your definition of validate appears to differ from the frameworks. The conclusion I was leading you towards was to always start with the code bake gives you - and you are not. You are right, in the previous sentence with ``validate'' I meant I needed to make sure that given id points to a

Re: Edit an object without creating it

2011-12-06 Thread Matteo Landi
On Mon, Dec 5, 2011 at 1:54 PM, phpMagpie p...@webbedit.co.uk wrote: You should never get to the point of editing a record's data before first displaying a form for that record.  It's at this point you should check if a record with the given ID exists and act accordingly. I don't agree with

Re: Edit an object without creating it

2011-12-06 Thread Matteo Landi
On Tue, Dec 6, 2011 at 8:48 PM, phpMagpie p...@webbedit.co.uk wrote: You gave no indication this was to be a REST enabled application and as 99% of apps are not REST then the replies were valid. I gave no indication because the problem I mentioned apply on both REST and not-REST applications.

Edit an object without creating it

2011-12-03 Thread Matteo Landi
Hi everybody, is there a way, given an id, to invoke Model-save() (or anything else) to update the relative record if and only if the id is valid? Imagine I want to edit a Post and change its body; if I erroneously call the edit action passing an id which does not exist, Model-save($data) will

Testing image upload

2011-12-03 Thread Matteo Landi
Hi list, what is the right way (if any) to test a controller which handles file uploads? At the moment I fill $_FILES with an array containing the fields expected by the controller (i.e. 'tmp_name', 'size', etc.) and then invoke testAction() passing $_FILES as well, but the whole mechanism fails

Re: Using REST In CakePHP 2.0

2011-11-15 Thread Matteo Landi
-- http://www.matteolandi.net On Nov 15, 2011 6:09 PM, Will 000w.s.s@gmail.com wrote: For the benefit of anyone else reading this, you can format the result of a call to $this-Model-find('all) with the following function: /** function _get_xml_array * * This function takes in an

Re: CakePHP and Sqlite

2011-11-13 Thread Matteo Landi
On Sun, Nov 13, 2011 at 5:25 AM, zer0_gravity zr...@hotmail.com wrote: Having trouble setting up CakePHP to work with Sqlite? could you explain or point me to where I can get info in rewards to this. thanks FWIW a couple of weeks ago I wrote a mini-tutorial about how to setup a SQLite

Re: running tests from the command line

2011-10-28 Thread Matteo Landi
Hi, I don't know about plugins but on my machine I am able to run app tests with `cake testsuite app AllController' (supposed you have a test inside 'app/Test/Case/AllControllerTest'), or `cake testsuite app Case/PostsController' (supposed you have 'app/Test/Case/Controller/PostsControllerTest').

Re: Multiple testAction inside a single test

2011-10-22 Thread Matteo Landi
Bug resolved: https://github.com/cakephp/cakephp/commit/c5ca10ca6932b76f505fec39f6e78b34dfcc5b9e Cheers, Matteo On Fri, Oct 21, 2011 at 11:38 AM, Matteo Landi landima...@gmail.com wrote: Hi everybody, I'm implementing a test for a controller, and I'm experiencing a strange problem

Re: How do you go about making a ReST service filterable (search via ReST)

2011-10-21 Thread Matteo Landi
On Fri, Oct 21, 2011 at 2:38 AM, Greg gsker...@gmail.com wrote: Still a bit stuck here with ReST. I have the index displaying as XML, and JSON - so its a good start... however the list could end up being quite large, so I want to condition it by fields. Conceptually something like:

Multiple testAction inside a single test

2011-10-21 Thread Matteo Landi
Hi everybody, I'm implementing a test for a controller, and I'm experiencing a strange problem: it seems that if I call ``testAction`` multiple time inside the same test function, assertions start to fail as if requests were not properly sent to controllers. The example below shows a successful

Re: SQLite and database exceptions.

2011-10-20 Thread Matteo Landi
On Tue, Oct 18, 2011 at 7:07 PM, José Lorenzo jose@gmail.com wrote: Use try-catch. Alternatively, override save() in AppModel and tor try { parent::save()} catch (Exception $e) { //do something } For some reason I have not thought about that: thank you so much! Regards, Matteo --

Re: Runnin tests on CakePHP 2.0

2011-10-20 Thread Matteo Landi
One last question: while testing SQLite databases with cake, where are they supposed to be found? Each time I run `Console/cake testsuite app etc.' from the app directory, I always end up with an error (unable to connect to one of the tested tables); moreover two databases are created in the

Re: Testing a RESTful controller

2011-10-20 Thread Matteo Landi
On Mon, Oct 17, 2011 at 11:58 PM, Matteo Landi landima...@gmail.com wrote: Hi everybody. I am looking for some advice on how to test RESTful controllers exchanging JSON data (I'm using $this-request-input() on all requests methods to fetch data coming from clients). Here is the test I

Re: cakephp url rewriting and domain name with accents

2011-10-20 Thread Matteo Landi
On Thu, Oct 20, 2011 at 9:27 PM, whatsnew jgu...@gmail.com wrote: Hi, Does anyone know if cakephp url rewriting handles properly domains names with accents? Correct me if I'm wrong, but if you speak about URL rewrite you are talking of the web-server and not of CakePHP; however I guess both

Re: $fields not honored inside hasMany relation

2011-10-17 Thread Matteo Landi
. Cheers, Matteo HTH, Paul On Oct 16, 11:42 am, Matteo Landi landima...@gmail.com wrote: On Tue, Oct 11, 2011 at 6:23 PM, Matteo Landi landima...@gmail.com wrote: On Tue, Oct 11, 2011 at 6:15 AM, Angad Nadkarni angad.nadka...@gmail.com wrote: Hi Matteo, this is not a bug. Cake requires

Re: Runnin tests on CakePHP 2.0

2011-10-17 Thread Matteo Landi
On Mon, Oct 17, 2011 at 12:48 AM, majna majna...@gmail.com wrote: try to uncomment this line https://github.com/cakephp/cakephp/blob/2.0/app/Config/core.php#L95 or play with Configure::write('App.baseUrl', env('SCRIPT_NAME')); in test.php, I don't know... I started to read TestSuite

Testing a RESTful controller

2011-10-17 Thread Matteo Landi
Hi everybody. I am looking for some advice on how to test RESTful controllers exchanging JSON data (I'm using $this-request-input() on all requests methods to fetch data coming from clients). Here is the test I started to write: ?php class UsersControllerTest extends ControllerTestCase {

Runnin tests on CakePHP 2.0

2011-10-16 Thread Matteo Landi
Hi everybody, I'm having some troubles trying to run tests (both browser and cli): on the one hand if I open http://localhost:3000/test.php (I'm using cakephp-instaweb) I get a blank page and I am unable to select tests to run; on the other, if I run ./Console/cake testsuite core

SQLite and database exceptions.

2011-10-16 Thread Matteo Landi
Hi everybody, I'm developing a test application on top of a SQLite database. As you probably may know, by default *integrity checks* on SQLite database are disabled, and in order to activate them you need to issue the following query once the connection with the database has been enstablished:

Re: $fields not honored inside hasMany relation

2011-10-16 Thread Matteo Landi
On Tue, Oct 11, 2011 at 6:23 PM, Matteo Landi landima...@gmail.com wrote: On Tue, Oct 11, 2011 at 6:15 AM, Angad Nadkarni angad.nadka...@gmail.com wrote: Hi Matteo, this is not a bug. Cake requires the post_id field  to fetch the associated Post associated array as well, hence even when you

Re: Runnin tests on CakePHP 2.0

2011-10-16 Thread Matteo Landi
On Sun, Oct 16, 2011 at 3:47 PM, majna majna...@gmail.com wrote: maybe there's issues with your python web server, try using wamp, mamp, xampp etc. for your stack Check PHPunit install and required version from CLI first. You saved my day: when I installed PHPUnit with apt, didn't notice that

Re: Runnin tests on CakePHP 2.0

2011-10-16 Thread Matteo Landi
On Mon, Oct 17, 2011 at 12:10 AM, majna majna...@gmail.com wrote: I think your web server is hardcoded to rewrite only index.php. https://github.com/lamby/cakephp-instaweb/blob/master/cakephp_instaweb.py try suggested apps above :( I think you are wrong: I'm able to load the summary page of

Re: Approve data changes

2011-10-11 Thread Matteo Landi
I suggest you to store different versions of user information using a ``revision`` column; this way you could show the user the last _accepted_ version, while the admin is able to accept the last _modified_ one. Cheers, Matteo On Tue, Oct 11, 2011 at 7:25 AM, nOLL hasnolm...@gmail.com wrote:

Re: $fields not honored inside hasMany relation

2011-10-11 Thread Matteo Landi
? If so, are there any particular reasons behind that choice? Regards, Matteo On Oct 10, 3:26 am, Matteo Landi landima...@gmail.com wrote: Hi everybody, I'm trying to create a simple cakephp application which handles posts and comments (like the one presented in the tutorial); I have a Post

$fields not honored inside hasMany relation

2011-10-10 Thread Matteo Landi
Hi everybody, I'm trying to create a simple cakephp application which handles posts and comments (like the one presented in the tutorial); I have a Post model which *hasMany* Comments, and I have a Comment which *belongsTo* to a Post. I would like to use Post-hasMany['fields'] variable to reduce