Re: [Catalyst] Paging problem
Alex Povolotsky wrote: On 04/28/12 00:05, Kenneth S Mclane wrote: ok, I tried this: my ($self, $c, $page) = @_; and my template code is issueing uri's like this: http://localhost:3000/accountview/list?page=4 http://localhost:3000/accountview/list?page=4 Do I need to remove this line: my $page = 1; It depends on what do you need. If you want paging to work, you'd better don't hardcode 1st page. Kenneth, Note that parameters come from the request: my $page = $c-req-param('page') || 1; The form you suggested would be if you were using a page in the path (/accountview/list/4) rather than in the query params (/accountview/list?page=4). hth. -- Cory G Watson http://www.onemogin.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] General Web- and OO-question
2009/3/27 Rodrigo rodrigol...@gmail.com But I can't instatiate the object because it throws an exception because age is not valid, isn't it? Or does Moose check constraints only on provided attributes. This can't be true with required attributes, can it? As long as the attribute is not required = 1, no exception is thrown. I think you are missing his point. He wants to instantiate an object from the form, but if he uses his Moose object then the things he wants to validate (errors) will prevent him from getting an instance of his class. If name is required or isa 'Str' then if it gets an arrayref, he can't use the object (as either it missing or being the wrong type throws an exception). I don't know if this is a good idea yet, but it's fairly easy to create a proxy object for a given class, less all the validation: http://www.pastie.org/429140 YMMV, but it would do what you want, as you could promote it to a real value iteratively after validation... -- Cory 'G' Watson http://www.onemogin.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] General Web- and OO-question
On Fri, Mar 27, 2009 at 1:10 PM, Cory Watson jheep...@gmail.com wrote: I don't know if this is a good idea yet, but it's fairly easy to create a proxy object for a given class, less all the validation: http://www.pastie.org/429140 Oops, that doesn't work, but you get the idea. -- Cory 'G' Watson http://www.onemogin.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] General Web- and OO-question
2009/3/27 Rodrigo rodrigol...@gmail.com I think you are missing his point. He wants to instantiate an object from the form, but if he uses his Moose object then the things he wants to validate (errors) will prevent him from getting an instance of his class. If name is required or isa 'Str' then if it gets an arrayref, he can't use the object (as either it missing or being the wrong type throws an exception). Well, if the object gets an arrayref when it was expecting an Str then he can't use the object and it should throw an exception. Picking this one to respond to, since Scott said the same thing. I think the OPs point was to it's really easy to go from request params to a constructed object. He seems to think this a great Way To Do Thingsā¢. His problem was that you can't do that if the object throws an exception when he tries to instantiate it. This short-circuits his intent to use the type constraints in Moose implicitly through the constructor. The replies all point to the idea of mating the params to their attributes and checking the constraints before instantiating. These are all great, but they don't solve his problem of using the object back on the form, think: input type=text value=[% obj.attribute %]... As for the OPs stated question: There's no one true way. There's a bunch of opinions. :) -- Cory 'G' Watson http://www.onemogin.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] So, what do we want in the -next- book?
On Tue, Apr 29, 2008 at 9:51 AM, J. Shirley [EMAIL PROTECTED] wrote: Dare I say, an Enlightened Perl Development book? Being in the middle of 5 or 6 apps that all use the 'enlightened' stack of perl libraries I can personally say that I would _love_ to have this book to recommend to our developers or to others. I love DBIC, Catalyst, Moose and friends because they don't force me into a particular way of doing things. The problem with this approach is that, for the newb, there are so many choices to make. It's not always clear which is the best. I know I've made -- and continue to make -- bad choices that I later have to undo. A guide into this area of perl would likely be very helpful. -- Cory 'G' Watson http://www.onemogin.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] Alphabetical Paging based on First Letter
On Wed, Feb 27, 2008 at 6:01 PM, Ashley [EMAIL PROTECTED] wrote: On Feb 27, 2008, at 3:50 PM, Matt Knesi wrote: I would like to implement a page navigation based on the first letter of the items, e.g. first letter of last names, so all last names with 'A' will display when you click on 'A' (instead of page 1) and all last names starting with 'M' appear when you click on 'M' and so on... Only the initials that are actually present in the database should be displayed for paging navigation, so if there is NO last name starting with 'X', 'X' shouldn't show up in the navigation line. I've done this with a dictionary application. You could do a relationship to a letter. So say name has_one letter, letter has_many names. Or what I've done a couple of times is make letter a field in the target table (word for me, name for you) and just keep the letter or # for a leading number/special and make it an index so it's fast to lookup. I'm not a fan of munging data unless there's a need for high performance. Unless this is a gigantic table you could probably just do: # I didn't syntax test this, ymmv my $rs = $schema-resultset('Person')-search(undef, { select = \'SUBSTR(name, 1, 1)', as = 'letter', group_by= \'SUBSTR(name, 1, 1) }); my @letters = $rs-get_column('letter')-all(); $c-stash-{'letters'} = [EMAIL PROTECTED]; and in TT: [% FOREACH letter = letters %]a href...[% letter %]/a[% END %] Then you'd have your list and not have to do any column adding or name munging. I'd also add a custom resultset and a method that did something like: sub starts_with { my ($self, $str) = @_; return $self-search({ name = { '-like' = $str\% } }); } So that you can do $rs-starts_with($c-req-param('letter')). -- Cory 'G' Watson http://www.onemogin.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] Stacked bar graphs
On Dec 3, 2007 9:33 AM, Matthias Zeichmann [EMAIL PROTECTED] wrote: never used it, looks nice tho (and AFAIR was advertised here on the list) http://search.cpan.org/~gphat/Chart-Clicker-1.4.1/ http://www.onemogin.com/clicker/examples And it quite happily handles stacked bar charts. Outputs png or svg. -- Cory 'G' Watson http://www.onemogin.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/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Directory layout
On Nov 8, 2007, at 8:47 AM, Gerda Shank wrote: The templates are not in the View directory, because the lib hierarchy is just for Perl code. Is that right? Yes. The Model, Controller and View directories house the respective perl classes that handle those functions. Is root kind of the equivalent of htdocs? What else would go in the static subdirectory besides images? Would you put css files in here? Does javascript go in static, or does it get a directory underneath root? Before I say anything, let me say: The short answer is that you can set things up however you want. The 'static' directory is similar to htdocs. The TT view is configured by default to use the 'root' directory as it's path for templates. The static directory is a best practice, I usually put 'css', 'javascript' and 'images' in there. It's a good idea to put all your static files under a common directory when using mod_perl because then you can tell apache to use the default handler for all files under that path. Using mod_perl to serve images is Bad Mojo. It's probably also a good idea for a bunch of other reasons. Are any parts of the layout created by catalyst.pl changeable, or would it break Catalyst to rename them? If, for example, root was changed to htdocs, or you didn't use the static directory? You probably could to this, but the default layouts are sort of a best practice. I'd use the defaults until you understand them better. Sorry for all the questions. I've been studying the documentation, but haven't had much like finding explanations for these things, and I'm not sure where to look in the code. No worries. It's better than doing things wrong and then complaining. ;) -- Cory 'G Watson http://www.onemogin.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/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/