Re: [Catalyst] Re: question for mst : using $c-config-{blah} ...
On Mon, Aug 4, 2008 at 11:14 AM, Matt S Trout [EMAIL PROTECTED] wrote: On Sun, Aug 03, 2008 at 06:30:02PM +0200, Daniel McBrearty wrote: wait, it is on $self not $c, so my reservations don't really apply. but what about reall config stuff that can change from one installation to another? then you have to do $c-config-{my_var}, right? How isn't something like connect_info real config? By real config, I mean stuff which is entirely specific to the app, and not generic for a particular Cat component. An example might something like email addresses that input from a certain form is sent to. Maybe real wasn't the best word. Put the config in a block specific to the model/view/controller that needs it and access stuff from within that component via $self-{whatever}, for preference. $self-config is broken since it only gives you the class level defaults which is why you should never call it. $c-config is an acceptable workaround for the fact we don't have a seperate app object so you can't do $c-app-my_var yet, but you should try and avoid needing it wherever possible. In my app, I have done it rather differently - anything that is config is in the config file - class level or whatever. And everything is accessed using $c-config-{whatever} The reason I like this is simplicity - if it says config, I know where to find it, end of story. Just a personal preference. I guess if it isn't broken or likely to cause issues (it's been like that for a year and half now) I'm not going to worry about it. Thanks for the clarification. ___ 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] question for mst : using $c-config-{blah} ...
(snip from another thread ...) You should never, ever EVER access $self-config in a model, view or controller object. Your config value will be in $self-{key}. It's considered normal to do package My::Controller::Foo; use strict; use warnings; use parent qw(Catalyst::Controller); __PACKAGE__-mk_accessors(qw(foo bar)); __PACKAGE__-config( foo = 'default_for_foo', bae = { default = 'for_bar' }, ); then later in your code just call $self-foo to get the runtime value. (/snip) Why is that Matt? I wasn't aware and have done it a fair bit. Not hard to change, but I'd like to know why. Not really a big deal, but I actually prefer the explicit use of config, for two reasons: 1. There is no chance of accidentally stomping on something else in $c namespace 2. It let;s you know where to go look for that particular bit of $c later in you need to cheers Daniel ___ 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] Re: question for mst : using $c-config-{blah} ...
wait, it is on $self not $c, so my reservations don't really apply. but what about reall config stuff that can change from one installation to another? then you have to do $c-config-{my_var}, right? On Sun, Aug 3, 2008 at 6:16 PM, Daniel McBrearty [EMAIL PROTECTED] wrote: (snip from another thread ...) You should never, ever EVER access $self-config in a model, view or controller object. Your config value will be in $self-{key}. It's considered normal to do package My::Controller::Foo; use strict; use warnings; use parent qw(Catalyst::Controller); __PACKAGE__-mk_accessors(qw(foo bar)); __PACKAGE__-config( foo = 'default_for_foo', bae = { default = 'for_bar' }, ); then later in your code just call $self-foo to get the runtime value. (/snip) Why is that Matt? I wasn't aware and have done it a fair bit. Not hard to change, but I'd like to know why. Not really a big deal, but I actually prefer the explicit use of config, for two reasons: 1. There is no chance of accidentally stomping on something else in $c namespace 2. It let;s you know where to go look for that particular bit of $c later in you need to cheers Daniel -- There's an infinite supply of time, we just don't have it all yet. ___ 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] Squatting::On::Catalyst
The usual way to make things like this work is by having a standardised api. In the case of membership for a website, it might look something like: get_unique_user_id # of logged in user get_username_for_id( id ) Then if a forum has tables such as: thread - references username post - ditto and maybe methods like send_pm( user ) find_posts( user ) if you are prepared to sacrifice the actual foreign key relationship, not that big a thing IMHO, you can do it all through the API. The person that writes the forum code/schema can actually have two install options - with and without the user table. Cat almost has this in place at present. -- There's an infinite supply of time, we just don't have it all yet. ___ 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] Squatting::On::Catalyst
my 0.05 (possibly a bit OT) : I looked previously at a few ways of adding forums etc to the site using 3rd party code, indeed there are many possibilites (some perl, some not) The thing that was always a sticker for me was getting some kind of logical integration, ie: 1. letting users keep existing member and login creds 2. being able to cross ref to other parts of the site eg. for a certain node, easily have a discussion link, and the reverse link from the forum I haven't yet seen a way to do this that looks easier than doing it from scratch (well, lets say some heavy porting of existing db structures and code from existing stuff ...) IMO getting these kind of features right are where the real meat is. Looking at the summary, I guess that's not what the focus of this project is, so if this is post is basically just noise, please forgive that. ___ 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] Squatting::On::Catalyst
I've been meaning to dig into the everything2 code (which powers perlmonks I think, amongst other things ..) and see how they do the cross ref stuff. They seem to have a pretty nice node abstraction which is the core of the problem, I think. the membership stuff relies on a common API, I guess. Doesn't claco have a project that addresses that? On Tue, Jul 29, 2008 at 3:08 PM, Chisel Wright [EMAIL PROTECTED] wrote: On Tue, Jul 29, 2008 at 02:21:10PM +0200, Daniel McBrearty wrote: 1. letting users keep existing member and login creds 2. being able to cross ref to other parts of the site eg. for a certain node, easily have a discussion link, and the reverse link from the forum If you ever think of a good way of doing this, please let me know! -- Chisel Wright e: [EMAIL PROTECTED] w: http://www.herlpacker.co.uk/ What do you call a chav in a box? Innit. ___ 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/ -- There's an infinite supply of time, we just don't have it all yet. ___ 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] Preventing simultaneous logins
Thanks Matt, I'll definitely try this when I get round to trying to solve this issue. Where does MyApp::set_athenticated get called from? when the user logs in? no, that can't be it ... you're way ahead of me here :-) ... 1. checking whether there is an existing session associated this username Session::PerUser ? I looked briefly at this, but I'm a bit wary because C::P::Session::Store::Fastmmap warns against being used with it. What is PerUser doing that is special in that respect, and what is a good backend for it? REading the docs for it, it seems like something slightly different - keeping the same session in place, even if the user logs in in the middle of it, if I understand correctly? You want: login from elsewhere to log out the same user anywhere else It wants: any login by the same user claims the user's session so, if you add in your root auto if ($c-user_exists) { unless ($c-user_session-{sid} eq $c-sessionid) { $c-logout; $c-forward('/auth/logged_out'); return 0; } } and in MyApp sub set_authenticated { my $self = shift; $self-next::method(@_); $self-user_session-{sid} = $self-sessionid; } then you should pretty much be done. So far as I can tell, this is perfect for you. You just sometimes get persistent session data as well (it warns against fastmmap because in the persistent session use case fastmmap is lossy - in yours the lossyness is irrelevant, you don't care about the persistence feature) -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Directorhttp://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/ -- There's an infinite supply of time, we just don't have it all yet. ___ 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] Preventing simultaneous logins
1. checking whether there is an existing session associated this username Session::PerUser ? I looked briefly at this, but I'm a bit wary because C::P::Session::Store::Fastmmap warns against being used with it. What is PerUser doing that is special in that respect, and what is a good backend for it? REading the docs for it, it seems like something slightly different - keeping the same session in place, even if the user logs in in the middle of it, if I understand correctly? ___ 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] Preventing simultaneous logins
I'm using Cat with a pretty standard configuration of : Catalyst::Plugin::Authentication Catalyst::Plugin::Session Catalyst::Plugin::Session::State::Cookie Catalyst::Plugin::Session::Store::FastMmap to handle login and session management. My login code looks like this: my $u = $params-{username}; if ($c-authenticate( { username = $u, password = $params-{'password'} } )){ my $user = $c-user; $user-last_login(DateTime-now); $user-update(); $c-response-redirect( $forward, 301); } else { # login failed $c-stash-{login_failed} = 1; } What I'd like to do is check if this user is already logged in at some other computer, and deny access if so. I guess that means : 1. checking whether there is an existing session associated this username 2. Being sure that the associated session is cleared when the user hits 'logout' I did a quick search and didn't get anything on the list - any quick clues about the easy way to do this, before I start digging into the guts of the plugins to see how? many thanks Daniel -- There's an infinite supply of time, we just don't have it all yet. ___ 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] Preventing simultaneous logins
indeed, it is use case dependent. The use case here is a common one, free content, paid content, you don't want users giving their creds to all their friends and using it simultaneously. (It is at best a first order solution, obviously if it becomes obvious that a fair percentage are using the system 24/7, something better is needed (say, bw capping). Not to hard to do, if needed.) As for the other points : 1. hadn't considered people closing the browser, without logging out - thanks. I guess a short session time is needed - say 10 minutes. The idea of pinging using javascript is quite neat, but I dislike the idea of making the server handle say 2 unproductive req's per minute per logged in user. I'd even rather something as ugly a js popup saying If you close without logging out ... when the user closes while logged in to that, I think. 2. the issue of someone leaving work with their browser left logged in is pretty insoluble (after all the browser could well be left open, so you still rely on session timeout). If they do it, they have to wait the 10 minutes, or go back to that computer and log out. K-I-S-S ... If you do all that, so that logout will always happen, couldn't you then solve it like this? (There may be a big fat hole in this ... this is hardly my specialist area ...): 1. On successful login (ie good U/P), get last session key for that user which you left in the db last time. 2. Look in the store for that key, see if it has timed out 3. If so, actually log in and write the new key to the db. 4. Otherwise, fail and leave the db alone. 5. On a real actual logout, nullify the key in the db and take it out the session store. That has only one db write per login (and I store last_login time anyhow, so no real increase), and the session store stays out of the db. Regarding volume, well, it's hardly an issue today, but you never know ... thanks for the excellent quality of feedback Daniel -- There's an infinite supply of time, we just don't have it all yet. ___ 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: [Dbix-class] Re: [Catalyst] untainting utf8 text for db
thanks! I've wondered about that. I'd like to see a formal definition of what does get through that filter. Hard to test it on, say, Mandarin CHinese when you don't know the language yourself. But I've a decent database of existing content, I could see if any of that fails this test. Thanks! [\w]+ works pretty well iirc, if your locale includes UTF-8. ___ 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: [Dbix-class] Re: [Catalyst] untainting utf8 text for db
of course. But how do you regex an inclusive list for any character in any human language ? On Fri, Jun 6, 2008 at 7:46 PM, Mesdaq, Ali [EMAIL PROTECTED] wrote: No escape sequence should get through if you reject any characters outside of the allowed characters. For example you could just reject the input and prompt for another input if this regex matches (?:[^a-zA-Z0-9 _]+) So escape sequences shouldn't affect this test. Thanks, -- Ali Mesdaq (CISSP, GIAC-GREM) Security Researcher II Websense Security Labs http://www.WebsenseSecurityLabs.com -- -Original Message- From: Daniel McBrearty [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2008 11:07 PM To: The elegant MVC web framework Cc: DBIx::Class user and developer list Subject: [Dbix-class] Re: [Catalyst] untainting utf8 text for db Thanks for the suggestions. Indeed, specifying a list of chars which is clean (e.g. [a-zA-Z0-9_] for a username in English) is optimum, and I prefer that. But when you are working with fully multilingual material, this becomes pretty much impossible. As the site in question is all about language learning and could eventually handle any language, that is the issue. Rejecting some of the suspicious chars you suggest is something I will do - but even that is not foolproof as there are various ways (more than one, IIRC, but I'm not sure what they all are) of using escape sequences to get through. Of the list you suggest, I'd need to keep (, ), ? - all the rest I could kill quite happily. Again, thanks for the input. I'm going to forward this to the DBIx::Class list (as that is probably where it should have gone in the first place). ___ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED] Protected by Websense Messaging Security -- www.websense.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/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] untainting utf8 text for db
Thanks for the suggestions. Indeed, specifying a list of chars which is clean (e.g. [a-zA-Z0-9_] for a username in English) is optimum, and I prefer that. But when you are working with fully multilingual material, this becomes pretty much impossible. As the site in question is all about language learning and could eventually handle any language, that is the issue. Rejecting some of the suspicious chars you suggest is something I will do - but even that is not foolproof as there are various ways (more than one, IIRC, but I'm not sure what they all are) of using escape sequences to get through. Of the list you suggest, I'd need to keep (, ), ? - all the rest I could kill quite happily. Again, thanks for the input. I'm going to forward this to the DBIx::Class list (as that is probably where it should have gone in the first place). ___ 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] untainting utf8 text for db
yes, that's what I meant. but does using the DBIx::Class construct sanitise, provide safety and prevent unwanted babies though? IIRC it does for creating records. On Thu, Jun 5, 2008 at 8:10 PM, Ash Berlin [EMAIL PROTECTED] wrote: On 5 Jun 2008, at 19:05, Daniel McBrearty wrote: database contains text fields which can be in any language and contain any text and punctuation 1. I am getting params back via a web form to create new records. What do I do to validate input (apart from length check)? 2. I want to take a param and do a like(%$param%) search returning matching records. How do I protect this? You mean foo LIKE '%$param%' and its done by $rs-search({ col = { -like = %$param% } }) -ash ___ 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/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Anybody who fancies some LWP poking ...
I think there was some discussion over the same error in the POE HTTP client over on perlmonks that included a this is the line of code that is wrong. I can't find the link offhand though. well, I see really three places to look at this: 1. in HTTP::Message - IMO the check on the content is fine, but there is really no need to die on failure, at least not until the rest of the codebase gets fixed. Hence my short term fix of just removing that. Bah. 2. in Test::WWW:Mechanize::Catalyst , you get: # For some reason Test::WWW::Mechanize uses $response-content everywhere # instead of $response-decoded_content; $response-content( $response-decoded_content ); which is the line that causes problems up the chain (I think that the content check that happens in HTTP::Message-new() is not an issue). So here, the question is, *why*? Is the right fix for T:W:M to change to using decoded_content and remove this line? Or just remove this line anyway? Or is there another issue? I'd like Leon's opinion on this. Forwarding to him again. ___ 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] Anybody who fancies some LWP poking ...
Not sure who that's pointed at Matt, but if you mean me, sorry for that. In all honesty, if I could've worked out *what* needed fixing and where, I would have done so. What I did was at least try to indicate to people where the error was coming from and why, and what they might do temporarily in order to get a workaround. In the absence of any actual understanding of *why* the changes which triggered the problem were made, trying to actually implement a fix didn't seem a very good idea. At any rate, the suggestion of some kind of stable/testing rating for module releases sounds like a pretty good idea. Not when you're that far down the dependency chain. Anyway, this thread was started to try and help get the fallout fixed, not for you to posture. Either write code, shut up, or start a separate thread so I can safely killfile it. ___ 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] Anybody who fancies some LWP poking ...
If you don't want new versions of modules, then *don't upgrade them*. and when you (or a total newcomer to the language/framework) do a *new* install? and the latest greatest is broken right out of the box? looks great, hey? The code may have been broken - but not so broken that it couldn't work (acceptably) well in the last N releases. But, hey, all of a sudden, it must be changed *now*. Dogmatism. ___ 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] Multi-language and REST
Haven't been looking in here for a while, just saw this thread. I have a multilingual app at http://www.engoi.com which uses Chained to do this. It works really well, and makes Do Not Repeat Yourself quite easy to achieve. In fact, for many actions, *two* languages are selected - the native and target language of the user. You can see the way this maps to URI's easily enough by looking around. Browser detection happens if you go to the domain root, and redirects you straight to the home page in your language. It's pretty simple. BTW don't let the fact that many pages are actually served static fool you. All content is developed in Catalyst, I use a script to generate html pages for stuff which is not actually dynamic in behaviour, and some shennaigans with URL's and server config to make it all work together. Cat is very powerful and flexible and lets you do things many, many ways. Daniel ___ 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] Anybody who fancies some LWP poking ...
yeah, I started setting up cat on a new system yesterday and hit this :-( The salient line seems to be : HTTP::Message content not bytes at lib/Test/WWW/Mechanize/Catalyst.pm line 88 I will spend an hour or two on it now, as I hate force installing, but am starting almost from scratch and don't have much intuition yet as what this is about. Any pointers welcome ... D ___ 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] Anybody who fancies some LWP poking ...
OK, I walked through the code and found out roughly what is going on. Hard to say where the real source of the bug is (could be at least two modules) but I have a workaround which I am using (basically just to remove the croak in HTTP::Message, a bit dirty but probably harmless). http://rt.cpan.org/Public/Bug/Display.html?id=34802 I forwarded this to Leon also. HTH D On Sun, May 4, 2008 at 9:30 PM, Daniel McBrearty [EMAIL PROTECTED] wrote: yeah, I started setting up cat on a new system yesterday and hit this :-( The salient line seems to be : HTTP::Message content not bytes at lib/Test/WWW/Mechanize/Catalyst.pm line 88 I will spend an hour or two on it now, as I hate force installing, but am starting almost from scratch and don't have much intuition yet as what this is about. Any pointers welcome ... D -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Re: [Dbix-class] Re: utf8 / pg double encoding problem
Thanks Ashley, that did indeed fix the JSON problem! (wish I'd remembered to write a test *before* I fixed it like this though ;-) cheers Daniel On Jan 7, 2008 9:28 PM, Ashley Pond V [EMAIL PROTECTED] wrote: This may or may not be germane: try installing JSON::XS and updating your JSON and JSON::Any. JSON::XS is one of, if not the, fastest serializers in all data classes and its utf8 handling is better. JSON now, IIRC, calls it if it's present instead of its older Perl version. -Ashley On Jan 7, 2008, at 7:57 AM, Daniel McBrearty wrote: Data is actually sent in URI encoded utf8 (looks like ab%C3%A7 ), which is fine. The string is then picked up, decoded and stored in the db just fine. The problem is that what gets sent back the other way (via Catalyst::View::JSON ) is not getting encoded. I don't know quite why just now (according to the docs it should do). Manually adding the Encode::encode_utf8( $result ) step fixes it for now. I may try peeking to see why it doesn't get handled by the View. ___ 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/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Re: [Dbix-class] Re: utf8 / pg double encoding problem
well, the moral is probably never work on your code when recovering from flu. It was pretty much a self-induced problem. I have a system where the user submits a value, and the value is copied back to them. If there is a network problem with corruption of the data, they will see it, as the returned string should show the problem. I had a problem where the string being returned was in pure unicode code points (not utf8). Somehow I convinced myself that the problem was on the source side, and added a utf8 encoding in the sending js. Oops. The result was obvious ... Data is actually sent in URI encoded utf8 (looks like ab%C3%A7 ), which is fine. The string is then picked up, decoded and stored in the db just fine. The problem is that what gets sent back the other way (via Catalyst::View::JSON ) is not getting encoded. I don't know quite why just now (according to the docs it should do). Manually adding the Encode::encode_utf8( $result ) step fixes it for now. I may try peeking to see why it doesn't get handled by the View. there is still a slight oddity that now, the $edit parameter shows just fine in the debug screen, is confirmed as being yes its UTF8, but $c-log-debug( $edit ) does not print ok. Odd, but not really any worry right now. Some kind of argument between perl and the terminal? but why OK in the usual debug output, but not with $c-log-debug? thanks to those who pointed in the right direction, anyhow. ___ 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] utf8 / pg double encoding problem
I don't follow this. The way I understand it, C::P::Unicode should have already gotten the input into Perl's internal format, which is utf8. So, for us to see a sequence of chars encoded as utf8, with the flag on, here, is what I expect. What am I misunderstanding? On Jan 6, 2008 12:28 AM, Andrew Rodland [EMAIL PROTECTED] wrote: On Saturday 05 January 2008 04:54:59 pm Daniel McBrearty wrote: well I'm damned, I thought I had this stuff working squeaky clean. But I was wrong. I actually had two bugs cancelling each other out - usually. [snip] --' [debug] abçöeü [debug] $VAR1 = ab\x{c3}\x{a7}\x{c3}\x{b6}e\x{c3}\x{bc}; [debug] it's UTF8! Looks like the problem is here... the utf8 flag is on, indicating that $edit is a string of characters, rather than bytes -- but the dumper output seems to show that these characters correspond to UTF-8 encoded bytes, instead of the actual characters of the data -- meaning that the bytes actually stored in the string are along the lines of ab\x{c3}\x{83}\x{c2}\x{a7}... not good. Somewhere, your data got the utf8 flag set by assumption instead of by decoding. $edit = decode(UTF-8, $edit) should clear it up, although finding the original problem is probably a better idea. :) Andrew ___ 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/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Re: [Dbix-class] Re: utf8 / pg double encoding problem
because it is utf8? shouldn't it be? On Jan 6, 2008 1:29 AM, Aristotle Pagaltzis [EMAIL PROTECTED] wrote: * Daniel McBrearty [EMAIL PROTECTED] [2008-01-06 00:00]: [debug] abçöeü [debug] $VAR1 = ab\x{c3}\x{a7}\x{c3}\x{b6}e\x{c3}\x{bc}; [debug] it's UTF8! Err, why doesn't Dumper say ab\x{e7}\x{f6}e\x{fc}? Strange that the first line looks correct, though. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/ ___ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED] -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Re: [Dbix-class] Re: utf8 / pg double encoding problem
so do you mean that Dumper should be seeing and outputting this as a char sequence? (what it actually shows is a mix of chars and hex bytes, in fact ...) On Jan 6, 2008 2:08 PM, Aristotle Pagaltzis [EMAIL PROTECTED] wrote: * Daniel McBrearty [EMAIL PROTECTED] [2008-01-06 13:30]: On Jan 6, 2008 1:29 AM, Aristotle Pagaltzis [EMAIL PROTECTED] wrote: * Daniel McBrearty [EMAIL PROTECTED] [2008-01-06 00:00]: [debug] abçöeü [debug] $VAR1 = ab\x{c3}\x{a7}\x{c3}\x{b6}e\x{c3}\x{bc}; [debug] it's UTF8! Err, why doesn't Dumper say ab\x{e7}\x{f6}e\x{fc}? Strange that the first line looks correct, though. because it is utf8? shouldn't it be? What Dumper outputs is the UTF-8 byte sequence; but the next line says that the Unicode flag is set, so this is a character string, not a byte string. So it's already double-encoded. I don't understand why the first line looks correct though. In any case the raw HTTP request that leads to all this would be interesting. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/ ___ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED] -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Re: [Dbix-class] Re: utf8 / pg double encoding problem
In any case the raw HTTP request that leads to all this would be interesting. I can tell you that the data in the raw request is just the 9 bytes of UTF8, exactly as shown by Dumper. I looked at it with wireshark to be sure. To give some background, this is getting pulled out of a form by javascript (which sees unicode), converted to UTF8, and then submitted as a POST to the cat controller. The $edit param is just another CGI parameter as far as Cat is concerned though. ___ 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] javascript in Catalyst using Template Toolkit
My experience is that every time I think I -can- make that assumption, later I end up really wishing I could deploy my app to a sub-URL for testing or similar. You may not have such bad luck, but I don't like to take that chance these days :) If I hit that one (needing to test code on the real server while an existing version runs) I typically just run a second server on port 8080 or something. That makes it completely independent of the running version (as long as you make sure you use a test database) and lets you deploy at /. ___ 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/
[Catalyst] [OT] stupid Universal:CAN warnings in make test
this is really bugging me. It happens almost every time I update some modules or install cat ... Called UNIVERSAL::CAN as a function, not a method ... at Template::Iterator blah blah about 1000 times in a typical make test. I did once look for what causes it, it seems to be a rather pernickity warning that pisses more people off than it helps ... is there a way to get rid of this annoyance other than forever patch the damn thing again and again? D ___ 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] [OT] ASP.NET MVC#
i'm not completely following the new syntax that you are proposing, so please forgive if I am wide of the mark here ... but ... IMO the existing syntax is really not *that* bad - the only mild crit I have is that Args() really means I'm an endpoint, which it doesn't say. For me, a simple improvement would be to allow an alternative name such as EndpointArgs that is a bit more obvious, and keep the rest just as it is. I worry a bit that two syntaxes, achieving the same thing but looking quite different to each other, and both coexisting in docs, mailing lists, and code, are just going to add more potential confusion than they clear up. Assuming that is what would happen - that's what I gather from Zbigniew's first description. D On 12/21/07, Zbigniew Lukasiak [EMAIL PROTECTED] wrote: Or maybe a better idea would be to use IsParent (or Parent) for those actions that can have children (logical isn't it?). Then we could use Args all the time instead of CaptureArgs (with EndPoint). Z. On Dec 20, 2007 12:31 PM, Matt S Trout [EMAIL PROTECTED] wrote: On Wed, Dec 19, 2007 at 02:18:17PM +, Zbigniew Lukasiak wrote: On Dec 18, 2007 2:00 AM, Matt S Trout [EMAIL PROTECTED] wrote: On Mon, Dec 17, 2007 at 08:39:29PM +, Zbigniew Lukasiak wrote: Yeah - some time ago I proposed to add an EndPoint attribute and get rid of the CaptureArgs one that is not very intuitive (and use Args in both cases). I don't remember seeing the code - if you update your patch to work against 5.80 trunk we can have a look ... A proof of concept implementation is in Catalyst::Controller::PathPart. It replaces the attributes at parsing time, I guess this would not be appropriate for the core of Catalyst. I am now going to port that change into lib/Catalyst/DispatchType/Chained.pm. I am not sure I'll be able to do it though. Remember you can't break backcompat in the process either ... -- 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/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/ -- Zbigniew Lukasiak http://brudnopis.blogspot.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/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] [OT] stupid Universal:CAN warnings in make test
please excuse my muttering to myself here. the issue seems to be that they did the bugfix with ref not blessed ... aargh. chromatic's doc does say quite clearly though. seems to be in two places in TT. the main reason i'm twittering about it is that if anyone can see that i am about to make an utter tit of myself in front of an even wider audience, they might save me from myself ... otherwise i'm going to try a patch later and risk yet another bug report on this later. ___ 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] [OT] stupid Universal:CAN warnings in make test
in fact, it's done since some time ... http://rt.cpan.org/Public/Bug/Display.html?id=25468 ___ 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] Re: javascript in Catalyst using Template Toolkit
heh. i'm picturing how that request would have gone over with the firewall group at the last fortune 500 i worked for. yes kevin, under those circumstances you likely wouldn't do it that way. on the other hand, if you are running your app on a server that you own and do admin for, and don't have such admin problems to negotiate, it would be fine, eh? horses for courses and all that. cheers, D ___ 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] [OT] ASP.NET MVC
The chained thing is probably the single most useful thing in cat IMO (if it's possible to even make such a dumb call ;) The way I have come to see it (it took a while, reading discussions here helped me grasp this) is that the way you design your URI space is very very fundamental to design of a web app. Chained helps you to remember this and try to get it right at the start. It also makes the decision about what actions go in what controllers separate from decisions about URI namespace. (I haven't really figured out if that is entirely a good thing or not, but it seems helpful.) The syntax *is* a bit hard to get used to at first - I find that the important thing is to remember that Args() defines an endpoint (hope I am remembering that right), other than that take a good look at what the debug server tells you when it starts up. (Without that info it'd be a royal PITA) Centralised routing stuff might be nice to have, but the way Chained flies now is pretty darn neat, once you get used to it. For me, I think I might prefer to be able to see the routing info right there in the action definition - where you need it. There isn't much cause to use anything other than Chained, as far as I can see (except the odd private helper method). BTW I talked about this a bit at the (first) Brussels Perl Mongers group a month or two back, and I have someone coming round for a beer later this evening - they have been wanting to port their Mason app to Catalyst, and I'm gonna see if I can help them get started. cheers Daniel ___ 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] [OT] ASP.NET MVC
I'd love to *get* reaction, but last time I tried (admittedly a long time back) I had to scrape my brains off the ceiling ... (and I don't really have enough to go round for that kind of thing) ... ___ 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] Web hosting?
I used bytemark.co.uk for several years, had great service and zero downtime. I'd recommend them. Then I found linode.com for about the same price and twice as much memory (about 300MB, which I did really need after porting to catalyst), and also great refs. Been there for several months now, also very impressive. The web interface is also neat and hadny for quick checks. These virtual servers are so good and cheap that you'd be nuts to do it any other way, unless you are very budget constrained indeed. -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ 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] Web hosting?
On Dec 16, 2007 7:15 PM, Matt Rosin [EMAIL PROTECTED] wrote: What distro are you using I'm curious. I use a Debian 4.0 image that they had. It's been very good so far. I always use Deb/Ubuntu pretty much. ___ 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/
[Catalyst] backward compatibility problem with new C::P::Authentication (for info only)
Hi, I don't consider this a bug, it's just by way of feedback to the list and module authors. I just updated to the latest C::P::Authentication and now get errors in my login code in some places. My code looks basically like this (simplified a bit) : sub login Chained('/') Args(0) : { # first check that username and password are supplied if ( $c-login) { my $user = $c-get_user( $username ); $user-last_login( DateTime-now ); # ... etc } } What seems to happen under some circumstances (haven't quite figured out why this happens sometimes and not others, yet) is this: [debug] Restored session 8d0c0673cde8a3ed970944917a9d77d5 [debug] Successfully authenticated user ''. [error] Caught exception in Engoi::Controller::Member-login Can't call method last_login on an undefined value at /home/daniel/work/engoi/trunk/Engoi/script/../lib/Engoi/Controller/Member.pm line 48. This is a bit odd, as a username *is* supplied (note the empty username which seems to have been authenticated in the debug output). My config looks like this: authentication: dbic: user_class: 'Schema::Members' user_field: 'username' password_field: 'password' password_type: 'crypted' I figure the best is to update to a setup with a default realm, which looks like it shouldn't be too hard, I hope, and use the authenticate method. As I did not check compatibility when the module was announced (I know, I know, sorry, mea culpa, ideal time of year to cut me off the Christmas card list ... ), I have no problem with this :-) cheers Daniel ___ 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] backward compatibility problem with new C::P::Authentication (for info only)
I still had -Authentication::Credential::Password -Authentication::Store::DBIC in the modules list, from the old setup. Removing these seems to have fixed the problem. ___ 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/