[Catalyst] Retrieve all users belong to a category and all its sub categories

2010-12-09 Thread linuxsupport
I have 3 tables, users, user_cat, and cat, table structure and relationship
are setup as follows.

User.pm

__PACKAGE__-add_columns(
  id,
  { data_type = integer, is_nullable = 0 },
  username,
  { data_type = text, is_nullable = 1 },
  password,
  { data_type = text, is_nullable = 1 },
  email_address,
  { data_type = text, is_nullable = 1 },
  first_name,
  { data_type = text, is_nullable = 1 },
  last_name,
  { data_type = text, is_nullable = 1 },
  active,
  { data_type = integer, is_nullable = 1 },
);
__PACKAGE__-set_primary_key(
id);

__PACKAGE__-has_many(usercats, Example::Schema::Result::UserCat,{
foreign.user_id = self.id },);
__PACKAGE__-many_to_many(cats = 'usercats', 'cat');

UserCat.pm

__PACKAGE__-add_columns(
  user_id,
  { data_type = integer, is_nullable = 0 },
  cat_id,
  { data_type = integer, default_value = 0, is_nullable = 0 },
);
__PACKAGE__-set_primary_key(user_id, cat_id);

__PACKAGE__-belongs_to(user, Example::Schema::Result::User, { id =
user_id },{ join_type = LEFT },);
__PACKAGE__-belongs_to(cat, Example::Schema::Result::Cat, { id =
cat_id },{ join_type = LEFT },);

Cat.pm

__PACKAGE__-add_columns(
  id,
  { data_type = integer, is_nullable = 0 },
  cat_name,
  { data_type = text, is_nullable = 0 },
 parent_id,
  { data_type = integer, is_nullable = 0 },
);
__PACKAGE__-set_primary_key(id,parent_id);

__PACKAGE__-has_many(usercat,Example::Schema::Result::UserCat,{
foreign.cat_id = self.id },);
__PACKAGE__many_to_many(allcat, usercat', cat);

I am able to retrieve all users in any particular category using allcat
many_to_many relationship.

In cat table I have both category and sub category, if a row have parent_id
 0 then it is sub category.

How can I get all users belong to one category and its sub categories?

Thanks in advance.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] FormHandler -- pro or con?

2010-12-09 Thread Octavian Rasnita
From: Toby Corkindale t...@dryft.net

 On 7 December 2010 18:03, Octavian Rasnita orasn...@gmail.com wrote:
 From: Toby Corkindale t...@dryft.net

 On 1 December 2010 02:34, will trillich will.trill...@serensoft.com wrote:
 Anybody else *dissing* FormHandler? We've started developing based on
 FormHandler lately and haven't had troubles... yet?

 I'm running it, and have been very happy with it.
 It's nice that you can put all your common form elements into roles
 and then combine them.
 I'm familiar with Moose, so HFH's syntax came fairly naturally to me,
 but I guess it could be confusing to others?

 Performance is reasonable - and a lot faster compared to FormFu.

 Cheers,
 Toby


 Is there a way of making H::FH beeing more elegant?

 I mean, is there a way of doing something to not need using Perl code for 
 creating the forms, but only using some configuration files like in H::FF's 
 case?
 
 I guess there is more than one way to do everything..
 I didn't like having to write YAML for H:FF, since YAML is ugly, and
 then one needed to take multiple YAML files and merge them a lot,
 and.. ugh.

I agree. That's why I never use yaml. But H::FF can use other config formats. I 
use the Apache-style format...
 
 Using Moose Roles for forms is awesome.

I also agree with this idea, but the fact that the most used constraints, 
filters and validators should be also manually specified using Perl code is not 
so nice.
It would be nice to have a form processor like H::FF that provides many default 
HTML elements, constraints, filters and validators, and to be able to create 
custom elements, constraints, filters and validators using Moose roles, then to 
specify that those roles are used... using config files.
Actually, I guess that is possible to create them using Moose with H::FF 
although I am not sure.

Ideally, the web designers that don't know Perl at all should be able to change 
the design of the forms at least.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Retrieve all users belong to a category and all its sub categories

2010-12-09 Thread David Schmidt
On Thu, Dec 9, 2010 at 9:37 AM, linuxsupport lin.supp...@gmail.com wrote:
 I have 3 tables, users, user_cat, and cat, table structure and relationship
 are setup as follows.

 User.pm

 __PACKAGE__-add_columns(
   id,
   { data_type = integer, is_nullable = 0 },
   username,
   { data_type = text, is_nullable = 1 },
   password,
   { data_type = text, is_nullable = 1 },
   email_address,
   { data_type = text, is_nullable = 1 },
   first_name,
   { data_type = text, is_nullable = 1 },
   last_name,
   { data_type = text, is_nullable = 1 },
   active,
   { data_type = integer, is_nullable = 1 },
 );
 __PACKAGE__-set_primary_key(
 id);

 __PACKAGE__-has_many(usercats, Example::Schema::Result::UserCat,{
 foreign.user_id = self.id },);
 __PACKAGE__-many_to_many(cats = 'usercats', 'cat');

 UserCat.pm

 __PACKAGE__-add_columns(
   user_id,
   { data_type = integer, is_nullable = 0 },
   cat_id,
   { data_type = integer, default_value = 0, is_nullable = 0 },
 );
 __PACKAGE__-set_primary_key(user_id, cat_id);

 __PACKAGE__-belongs_to(user, Example::Schema::Result::User, { id =
 user_id },{ join_type = LEFT },);
 __PACKAGE__-belongs_to(cat, Example::Schema::Result::Cat, { id =
 cat_id },{ join_type = LEFT },);

 Cat.pm

 __PACKAGE__-add_columns(
   id,
   { data_type = integer, is_nullable = 0 },
   cat_name,
   { data_type = text, is_nullable = 0 },
  parent_id,
   { data_type = integer, is_nullable = 0 },
 );
 __PACKAGE__-set_primary_key(id,parent_id);

 __PACKAGE__-has_many(usercat,Example::Schema::Result::UserCat,{
 foreign.cat_id = self.id },);
 __PACKAGE__many_to_many(allcat, usercat', cat);

 I am able to retrieve all users in any particular category using allcat
 many_to_many relationship.

 In cat table I have both category and sub category, if a row have parent_id
 0 then it is sub category.

 How can I get all users belong to one category and its sub categories?

 Thanks in advance.


 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/



That's entirely a DBIx::Class question. You might want to ask in
#dbix-class on irc.perl.org or at the DBIx::Class mailinglist
http://lists.scsys.co.uk/mailman/listinfo/dbix-class

david

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Static MultiViews?

2010-12-09 Thread Lists

Hello,

I'm trying to find an a plugin or something that does some rudimentary  
content negotiation, i.e. multiviews, i.e. serving static files  
without their extensions. Can't seem to find anything despite having  
scoured for hours. Clearly my search-fu is not up to snuff. Pointers?


--
Dorian Taylor
Make things. Make sense.
http://doriantaylor.com


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] FormHandler -- pro or con?

2010-12-09 Thread Sir Robert Burbridge

On 12/09/2010 03:24 AM, Octavian Rasnita wrote:

From: Toby Corkindalet...@dryft.net

   

On 7 December 2010 18:03, Octavian Rasnitaorasn...@gmail.com  wrote:
 

From: Toby Corkindalet...@dryft.net

   

On 1 December 2010 02:34, will trillichwill.trill...@serensoft.com  wrote:
 

Anybody else *dissing* FormHandler? We've started developing based on
FormHandler lately and haven't had troubles... yet?
   

I'm running it, and have been very happy with it.
It's nice that you can put all your common form elements into roles
and then combine them.
I'm familiar with Moose, so HFH's syntax came fairly naturally to me,
but I guess it could be confusing to others?

Performance is reasonable - and a lot faster compared to FormFu.

Cheers,
Toby
 


Is there a way of making H::FH beeing more elegant?

I mean, is there a way of doing something to not need using Perl code for 
creating the forms, but only using some configuration files like in H::FF's 
case?
   

I guess there is more than one way to do everything..
I didn't like having to write YAML for H:FF, since YAML is ugly, and
then one needed to take multiple YAML files and merge them a lot,
and.. ugh.
 

I agree. That's why I never use yaml. But H::FF can use other config formats. I 
use the Apache-style format...

   

Using Moose Roles for forms is awesome.
 

I also agree with this idea, but the fact that the most used constraints, 
filters and validators should be also manually specified using Perl code is not 
so nice.
It would be nice to have a form processor like H::FF that provides many default 
HTML elements, constraints, filters and validators, and to be able to create 
custom elements, constraints, filters and validators using Moose roles, then to 
specify that those roles are used... using config files.
Actually, I guess that is possible to create them using Moose with H::FF 
although I am not sure.

Ideally, the web designers that don't know Perl at all should be able to change 
the design of the forms at least.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
   


Hrm.  I thought I was following what you wanted until the last line:

   Ideally, the web designers that don't know Perl at all should be able to 
change the design of the forms at least.
  

Maybe I'm being naive, but what does the HFH form have to do with the 
design?  If you give them meaningful ids and class names, the designers 
can do whatever they need with CSS and the templates, right?


-Sir

















___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Transferring control via root/auto

2010-12-09 Thread Thompson
How would you use a chained dispatch to solve a problem like this?  
Something that needs to be checked before allowing anything else 
(besides logging in) to happen and if so force them to a specific page?  
A simple example would help.  I'm still have it in my head that this 
logic should be done in the root controller since it would supersede any 
action in my other controllers.


Thanks,
Rob

On 12/8/2010 8:31 AM, Tomas Doran wrote:


On 7 Dec 2010, at 16:11, Ben van Staveren wrote:

You want to $c-detach('end') -- unless that's the default these 
days. I use this pattern a lot and the only difference I see is that 
I do:


The end action will _always_ be run, there is no need to detach to the 
end action.


However I'm not sure what doing $c-detach in auto will do (I guess 
the same as returning 0 - i.e. stop further actions from running), but 
I'm not sure - you should probably return 0 (to stop further dispatch) 
rather than detaching in the auto action..


However as noted elsewhere in this thread, I'd seriously recommend 
using Chained dispatch rather than auto for this (if for no other 
reason then it avoids the re-entering auto in the next request after 
you redirect issue).


Cheers
t0m


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/

Dev site: http://dev.catalyst.perl.org/





___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/