Re: [Catalyst] So, what do we want in the -next- book?

2008-02-19 Thread Kieren Diment

On 19 Feb 2008, at 05:17, Matt S Trout wrote:

Since a fair few of you will now have John's book, I figured it was  
time

to ask what you'd want from a second book.

I guess the existing one provides a pretty good tutorial style, so  
we should

be looking at something more in-depth / intermediate to advanced.

What do you guys think?





Techniques for making your app scale.


___
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] Why use external FastCGI apps?

2008-02-19 Thread Matt Pitts
 -Original Message-
 From: Matt Pitts [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 11, 2008 11:47 AM
 To: [EMAIL PROTECTED]; The elegant MVC web framework
 Subject: RE: [Catalyst] Why use external FastCGI apps?
 
 Although I haven't had any experience yet with *external* fastcgi, I'm
 feeling this approach as well, mainly because it allows me to hang my
 hat on the starting/stopping/reloading of apache. I'm also trying to
 treat an Apache vhost like an appliance that I can drop anywhere. I
 basically have *everything* related to a single vhost organized under
a
 standard structure and I keep it all in Subversion.
 
 This way, deploying a site to a different machine is
  - get vhost appliance from subversion
  - symlink vhost conf file into apache vhosts.d
  - sync logs if necessary
  - apache reload
 
 I know my model isn't perfect, but if I use external fastcgi then it
 adds an easily looked over step - create/symlink some fastcgi init
 script.
 
 The only things that will definitively push the use of external
fastcgi
 are: if I cannot get mod_fcgid to work with PAR files; or if I'm happy
 with external fastcgi testing/memory usage and can integrate it into
my
 vhost model without too much unhappiness.

Well, external FCGI ended up winning me over, mainly because I couldn't
get mod_fcgid to launch from a PAR.
However, I must confess that I don't mind the approach now as I have
built init scripts and organized things
so that they are sane to me. As Yuval said, this does reduce the config
mess.

If anyone is interested here is my setup...

 - Apache 2.2 proxy frontend w/ proxy_balancer and its manager
interface; mod_cband for throttling and its live traffic interface
 - 2 Apache 2.2 backends each doing static file serving and external
FCGI to local Cat apps

When I do updates I just use the proxy_balancer manager interface to
disable the host I'm going to update and do the switch-a-roo.
I realize it's not perfect because it relies on my mouse clicking, so I
may still end up writing a script to do the switching
at the FCGI app, but this works for now. I'd really love to hack up a
patch to mod_proxy that allows you to switch one backend on
and another one off at the same time.

The next thing I'd like to implement is database load balancing so that
I'm not locked into a single database system. This will
probably be another thread.

Thanks to all of you who gave input to this one.

v/r

-matt

___
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] Multilingual Site

2008-02-19 Thread J. Shirley
On Feb 19, 2008 10:07 AM, Michael Schreier [EMAIL PROTECTED]
wrote:

 Hi,

 I am new to Catalyst and read alot of tutorials and the book and tried
 some small things with catalyst. It is great:-)

 I want to create a Multilingual Site, but I don't know how to begin,
 especially with catalyst.

 Where is the best place to save the language texts (DB or File)? How to
 handle templates with TT? Every link, hint and help is welcome... I need
 a thought-provoking impulse, no final solution.

 Regards and thanks
 Michael


Hi Michael,

Take a look at Catalyst::Plugin::I18N, which is a plugin that easily allows
this.

You can read the tutorial here, which has everything you need to get
started:

http://search.cpan.org/~bricas/Catalyst-Plugin-I18N-0.07/lib/Catalyst/Plugin/I18N/Manual.pod



-- 
J. Shirley :: [EMAIL PROTECTED] :: Killing two stones with one bird...
http://www.toeat.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/


[Catalyst] Multilingual Site

2008-02-19 Thread Michael Schreier

Hi,

I am new to Catalyst and read alot of tutorials and the book and tried 
some small things with catalyst. It is great:-)


I want to create a Multilingual Site, but I don't know how to begin, 
especially with catalyst.


Where is the best place to save the language texts (DB or File)? How to 
handle templates with TT? Every link, hint and help is welcome... I need 
a thought-provoking impulse, no final solution.


Regards and thanks
Michael

___
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] Multilingual Site

2008-02-19 Thread Yuval Kogman

On Tue, Feb 19, 2008 at 19:07:05 +0100, Michael Schreier wrote:
 I want to create a Multilingual Site, but I don't know how to begin, 
 especially with catalyst.

Basically it comes down to using a localization engine for all text.

How you do that is up to you.

Catalyst's I18N plugin provides DWIM to choose the right language
based on the headers, and eventually delegates to Locale::Maketext.

I'd read this article thoroughly:

http://search.cpan.org/~jhi/perl-5.8.1/lib/Locale/Maketext/TPJ13.pod

at which point things should become clear to you.

Typically people use a 'loc' function in TT.

In the last work website which was pretty heavily i18nized the
'loc' function in TT delegated to a method of an object that then
based on the arguments decided what to do. It handled everything
from objects that can be displayed, to text messages (using
Locale::Maketext::Lexicon, .po files and ::Slurp for larger bits of
text), to DateTime objects, and it worked out pretty well.

 Where is the best place to save the language texts (DB or File)? How to 
 handle templates with TT? Every link, hint and help is welcome... I need 
 a thought-provoking impulse, no final solution.

Locale::Maketext will help make the storage of the language text
irrelevant wrt the usage... If you find you need to move the data to
a database it should be trivial to do that post factum, but I'd
start with gettext files which are good enough for 90% of the cases.

One clever trick with gettex/maketextt is that you can do %foo(...)
to call method calls on the localization handle, so the formats can
localize their arguments properly without you having to localize
them before passing them in. This is both cleaner and more language
independant.

Good luck

-- 
  Yuval Kogman [EMAIL PROTECTED]
http://nothingmuch.woobling.org  0xEBD27418


___
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] So, what do we want in the -next- book?

2008-02-19 Thread Francesc Romà i Frigolé
John's book has been very useful, and still is, as I'm now using it as a
reference, even though as others have pointed out it's more of a tutorial
than a reference.

Still, there are some topics I wish they were covered at more depth: the
fundamental stuff and the more advanced stuff.

Fundamental: knowledge of TT and DBIx::Class are needed to really take
advantage of catalyst. While there is a book on TT, afaik there is none on
DBIx::Class. I know that those are independent projects and it is possible
to use catalyst with other views and ORMs, but this two are the de facto
standards in this community. OTH I prefer thin books, so maybe, what I'm
actually asking for is a DBIx::Class book :)

Advanced: AJAX and forms. dynamic web pages are more than hot web topics.
There are many options available for catalyst, and none of them seem nearly
as standard as TT or DBIC, so it would be nice to have a book explaining
the different options for building complex interactive forms. Since those
are in fact hot topics there is a lot of literature that covers them, I just
don't know how relevant they are when it comes to developing with catalyst.
If there are relevant books I'd be happy to hear about them.


On Feb 18, 2008 7:17 PM, Matt S Trout [EMAIL PROTECTED] wrote:

 Since a fair few of you will now have John's book, I figured it was time
 to ask what you'd want from a second book.

 I guess the existing one provides a pretty good tutorial style, so we
 should
 be looking at something more in-depth / intermediate to advanced.

 What do you guys think?

 --
  Matt S Trout   Need help with your Catalyst or DBIx::Class
 project?
   Technical Director
 http://www.shadowcat.co.uk/catalyst/
  Shadowcat Systems Ltd.  Want a managed development or deployment
 platform?
 http://chainsawblues.vox.com/
 http://www.shadowcat.co.uk/servers/

 ___
 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/


Re: [Catalyst] Multilingual Site

2008-02-19 Thread Michael Schreier
That sounds great and I'll check this for my template work, but now I 
have an additional question.


What about user generated content? For example: I have a site with three 
languages en,de,fr and the user can make input in one or all of these 
languages.


Is it ok, if I have a row in the DB for each language?

Table article:
id, year, month, author, ...

Table article_content:
article_id, language, content
1, de, hallo
1, en, hello

Or is there a better way to do such things? Other table structure?

The solution to have each language in a seperate column sounds like 
high-maintenance to me, if I need a new language.


And how is the best way, to fetch multilingual content with DBIx::Class?

What is your know-how there?

Thanks
Michael

Yuval Kogman schrieb:

On Tue, Feb 19, 2008 at 19:07:05 +0100, Michael Schreier wrote:
  
I want to create a Multilingual Site, but I don't know how to begin, 
especially with catalyst.



Basically it comes down to using a localization engine for all text.

How you do that is up to you.

Catalyst's I18N plugin provides DWIM to choose the right language
based on the headers, and eventually delegates to Locale::Maketext.

I'd read this article thoroughly:

http://search.cpan.org/~jhi/perl-5.8.1/lib/Locale/Maketext/TPJ13.pod

at which point things should become clear to you.
  



___
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] Multilingual Site

2008-02-19 Thread Joshua McAdams
 What about user generated content? For example: I have a site with three
 languages en,de,fr and the user can make input in one or all of these
 languages.

 Is it ok, if I have a row in the DB for each language?

What I've done in the past with some degree of success is just to use
a phrasebook table.  Basically I have three tables in the system for
phrase lookups:

create table phrase_key (
  id int unsigned primary key auto_increment,
  key varchar(255) not null unique key
);

create table language (
  id smallint unsigned primary key auto_increment,
  language varchar(100) not null unique key
);

create table phrase (
  phrase_key_id int unsigned not null references phrase_key(id),
  language_id smallint unsigned not null references language(id),
  phrase varchar(255) not null,
  primary key (phrase_key_id, language_id)
);

Then, for each column that needed to be fed from the phrasebook I
would store the phrase key instead of the actual phrase.  For
instance, instead of having a book.title column, I would have a
book.title_pb column and then create a method in my DBIC wrapper
called 'title' that actually did the lookup.

Also, I put something like this in my main schema file:

code
sub fetch_phrase {
my ( $self, $phrase_key, $language ) = @_;

get_logger-error_die('a phrase key is required')
  unless defined $phrase_key;

my $phrase = $self-resultset('Phrases')-search(
{
'phrase_key.name' = $phrase_key,
'language.id'   =
  ( $language || $self-{__language__} ||
get_logger-error_die(language_id is required) )
},
{ join = [qw/phrase_key language/] }
)-first;

if ( not defined $phrase ) {

get_logger-warn(no phrase returned for phrase key [$phrase_key]);
return q{};
}

return $phrase-phrase;
}
/code

I'm not sure how 'correct' this was, but it worked.

___
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] Doing work inside the DBIx::Class model

2008-02-19 Thread Toby Corkindale
On Wed, Feb 20, 2008 at 01:10:12PM +1000, Cian Barclay wrote:
 Hello Catalysters,
 
 I'm using Catalyst with a DBIx::Class model generated by
 DBIx::Class::Schema::Loader.
 
 I want to make my model do more work, rather than having my
 controllers fiddling around with model objects doing things to them.
 But I'm stuck on the bit where I want to get a resultset inside the
 model's subroutines. In a controller I use $c-model(Foo::Bar) to
 get the resultset. How can I get a resultset when I'm in the model?
 
 I could pass $c in to the model, but then the model wouldn't be
 usable without Catalyst. I'd like to be able to use the model
 for other things, but from reading the DBIx::Class manual, it
 seems like I'd need the $schema object to get resultsets.
 
 Since I'm stuck, I thought it would be a good time to ask for some
 help on this please. Is there a way to make a DBIx::Class model
 which is usable both for Catalyst and something else? How do you
 get resultsets inside the model which could either be from the
 Catalyst model, or from the database connection if Catalyst wasn't
 being used?

I think you're looking for the $self-resultsource-schema method, inside your
Model?

tjc.

___
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] So, what do we want in the -next- book?

2008-02-19 Thread Mojo Nichols

Matt S Trout wrote:

Since a fair few of you will now have John's book, I figured it was time
to ask what you'd want from a second book.

I guess the existing one provides a pretty good tutorial style, so we should
be looking at something more in-depth / intermediate to advanced.

What do you guys think?

  
Yeah a massive reference manual of TT, TTSite, Catalyst and as many of 
useful plugins you can resonablly and coherently pack into it, and 
DBIx::Class. It should have  good examples/explanations of using all of 
the above together in depth.  Ie creating resultsets for models... etc.  
Really dig into some of that magic. Hmm perhaps throw in ajax and a 
javascript toolkit.  And then make sure it is well indexed, hmm perhaps 
even do something like the perl CD book collection. 

Rather then just collect manual pages it would be nice to see it in the 
context of Catalyst, how do you use X with catalyst and add Y or X::Y..  
For example ash helped me get DBIx::Class::Cursor::Cached working under  
Catalyst which naturally wasn't particularly clear from the 
Cursor::Cached manual page. Now perhaps that is just not main stream 
enough of a problem to make the cut, but you get the idea.  


mojo

___
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] Doing work inside the DBIx::Class model

2008-02-19 Thread Cian Barclay
On Feb 20, 2008 1:18 PM, Toby Corkindale [EMAIL PROTECTED] wrote:

 On Wed, Feb 20, 2008 at 01:10:12PM +1000, Cian Barclay wrote:
  which is usable both for Catalyst and something else? How do you
  get resultsets inside the model which could either be from the
  Catalyst model, or from the database connection if Catalyst wasn't
  being used?

 I think you're looking for the $self-resultsource-schema method, inside
 your
 Model?


I don't have one of those, do you mean $self-_source_handle-schema? Is
it okay to use with the leading underscore?
___
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/