On Oct 12, 4:18 am, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> As I said, the problem is not the names or when they should be called.
> The problem is. What should be input and the output of each of these
> functions?

Whenever I'm in a problem with a full stack web framework, I think to
myself "what would cakePHP do?"
OK, that's really NOT the way you should think, but they did some job
on the input and output of some of these functions (they don't have
migrates, so the migration events I'd like to see, are not there), and
we should learn from it:

afterDelete( ) - cake API allows you delete only one row at the time,
and it's data is part of the object delete is ran upon (like our
delete_record() method). Retuens a void, but the object stil contain
the deleted record.
afterFind( $results, $primary = false ) -  I'm not sure what primary
means, but the results, contain a list of all results. Returns a list
of modified results.
afterSave( $created ) - The created row. This method runs on create
and on update. When I worked with it, I really wanted 2 seperate
functions. returns void.
beforeDelete( $cascade = true ) - Again, has the data of the deleted
record. The cascade is like  to web2py recursive deletes. Returns a
boolean that suggests wether delete should continue.
beforeFind( $queryData ) = That's a bit more problematic for us.
cakePHP has an array of all the joins and conditions, that can be used
in $queryData. I'm not sure web2py has one we can create. But... what
do I know? returns either boolean or modified query.
beforeSave( $options ) - I have no idea what the options are, and I'm
not sure I'm keen on exploring it. Returns true if save should
continue, false if not.
beforeValidate( $options ) - same as beforeSave

beforeFilter and afterFilter - Well... I'm not sure how relevant it is
for our case. This is where you find user auth logic.
beforeRender() - This function is called, so you can change some vars
before a view is presented. This one applies on a paticular controller
(can be applied to all controllers using inharitance, but that's the
way cake works, not really relevat to web2py).

The cake API is not 100% relevant to web2py, but we can use it to get
some idea how others solved it.

Reply via email to