|
satest3 posted:I'm not sure if that is true Gotcha. I was hoping the "fastest, aka best" would give me away.
|
# ? Aug 21, 2009 20:04 |
|
|
# ? Apr 25, 2024 23:26 |
|
Thanks to this thread I've started fooling around with Moose. So far I like it. But I'm not too up to date on OO programming. I've run into one issue I'm not sure how to tackle. I have an object named Conf that is extended by another object named Admin. I pull data from a database query and dump that into the Conf object. The admin row of the query returns an index number for another table. How would I setup the Admin object to take the index number it gets from the query and load it's self from another query? I initially replaced the new function, but I get an Type Constraint error. Which makes sense. I hope I'm explaining this well enough. code:
Puck42 fucked around with this message at 19:00 on Aug 23, 2009 |
# ? Aug 23, 2009 18:57 |
|
Puck42 posted:How would I setup the Admin object to take the index number it gets from the query and load it's self from another query? I'm not quite sure what you mean here. Since this is the heart of your question, I don't know how to help you with this without more information. Puck42 posted:I initially replaced the new function, but I get an Type Constraint error. Which makes sense. With Moose, replacing new is usually a last resort. We have plenty of hooks and functionality to let you avoid replacing new. In your case, BUILDARGS is what you want. code:
code:
|
# ? Aug 23, 2009 22:55 |
|
Filburt Shellbach posted:I'm not quite sure what you mean here. Since this is the heart of your question, I don't know how to help you with this without more information. Sorry, it's a horrible way to phrase it. I have the BUILDARGS run a query and it returns a number for admin, like 4. I then want that number to run through the Admin object as a DB query and setup the Admin object inside of Conf using the hash returned from the Admin query. Basically the same way I have Conf setup to run the number it receives as a query and create the object. Speaking of BUILDARGS... code:
code:
Thanks Edit: Never mind, I should of check the version of Moose installed, 0.17 is not up to date... Puck42 fucked around with this message at 01:48 on Aug 24, 2009 |
# ? Aug 24, 2009 01:20 |
|
Speaking of has-a relationships, is there a better way to refer to a parent object in Moose than just like this?code:
|
# ? Aug 25, 2009 03:21 |
|
I hate this redesign of perldoc.org. Why would someone think that shoehorning perlguts into a 600px wide box was a good idea? And that aggravating header bar that sticks at the top of the page... what's up with that? There's a preference to turn it off but it only works in IE for me. ok I'm done.
|
# ? Aug 26, 2009 12:38 |
|
Yeah they're wasting a ton of space on either side, idg why they did that
|
# ? Aug 26, 2009 12:47 |
|
The usual blogs have been pretty serious about reshaping Perl's image to be more modern. Apparently any change is better than no change.
|
# ? Aug 26, 2009 12:47 |
|
shorter columns are easier to read (especially when everyone's got a big screen now, with content sprawling over it) that said I don't think the redesign is somehow 'modern' or nice either
|
# ? Aug 26, 2009 14:03 |
|
Wow, you guys know nothing. That facelift is yards better than the design before it. And yes, that gluey top bar is executed oddly.
|
# ? Aug 26, 2009 14:27 |
|
Otto Skorzeny posted:Yeah they're wasting a ton of space on either side, idg why they did that http://www.maxdesign.com.au/presentation/em/ Studies have shown that columns of roughly 30-35em width aid the user by providing optimal reading speed. (Something that personal experience has confirmed.) As such their overall page design is not bad. The real WTF is why the hell they enforce it in pixels and not in em.
|
# ? Aug 26, 2009 15:35 |
|
Triple Tech posted:Wow, you guys know nothing. That facelift is yards better than the design before it. And yes, that gluey top bar is executed oddly. I can't recall what it looked like before, but it now looks like 'if slashdot did man pages' p.s. a little bit more whitespace would be nice too
|
# ? Aug 26, 2009 15:53 |
|
Mithaldu posted:http://www.maxdesign.com.au/presentation/em/ I don't know if I'm some weirdo or whatever but I find the cpan.org style of presenting perldoc (which I believe is nearly identical to what perdoc.perl.org used to use) to be more usable, as there's more info on the screen, it looks nicer and there aren't dark blobs flanking the information on either side and providing a visual distraction. I guess this is pretty much bikeshedding though, i can always type perldoc at a command prompt and see poo poo rendered Correctly e: (i should mention i'm on a 1400x1050 laptop screen so there's way more empty space when i load the page than in tef's screenshot (im too lazy to take a screenshot of my own (i'm not sure i have a screenshot program installed atm and i forget the hotkey (nil )))) Blotto Skorzany fucked around with this message at 16:25 on Aug 26, 2009 |
# ? Aug 26, 2009 16:22 |
|
Otto Skorzeny posted:e: (i should mention i'm on a 1400x1050 laptop screen so there's way more empty space when i load the page than in tef's screenshot (im too lazy to take a screenshot of my own (i'm not sure i have a screenshot program installed atm and i forget the hotkey (nil )))) I cropped it, I'm on a 1920x1200 display.
|
# ? Aug 26, 2009 16:30 |
|
I agree that the graphical style of the remake is totally balls. My comment was only on the column width. For anyone doubting i seriously urge to simply try reading an actual book-like full-text at screen-spanning width to see how annoying that is in practice. Also, if you have such a huge screen, make use of it properly and throw a sidebar on there.
|
# ? Aug 26, 2009 16:43 |
|
Otto Skorzeny posted:I don't know if I'm some weirdo or whatever but I find the cpan.org style of presenting perldoc (which I believe is nearly identical to what perdoc.perl.org used to use) to be more usable, as there's more info on the screen, it looks nicer and there aren't dark blobs flanking the information on either side and providing a visual distraction. I feel the same way. After I posted this morning, I wrote this stylesheet to get that cpan.org feel back. It's a quick 10-minute rush job and could be improved, but you know... code:
|
# ? Aug 27, 2009 00:52 |
|
That's one narcissistic stylesheet you have there.
|
# ? Aug 27, 2009 04:44 |
|
Regarding error handling, How is everyone here handling error handling in a OO perl situation? I've been using Moose pretty heavily in a very OO-oriented situation, and started using Exception::Class to handle fatal errors. However, I've run into gotchas with the two ways I found to use an eval{} block to provide error handling. Method 1: code:
Method 2: code:
More subtle was some debugging code causing the error handling code to always trigger, making a false positive: code:
Method 3 code:
Alternately, I've been staying away from the various try-catch routines on CPAN due to them saying that they're in alpha, reccommendations to stay away from source filter ones, etc. Is there a stable, bulletproof CPAN module that will do what I want? I'm not a java/C coder, so I'm comfortable enough with eval{} to not be thinking that I -HAVE- to try or catch exceptions. How does everyone here code this sort of thing? Roseo fucked around with this message at 23:45 on Aug 27, 2009 |
# ? Aug 27, 2009 23:40 |
|
There's no problem with using $@ as long the first thing you do is assign it to a lexical and then only refer to that lexical from then on. If you keep referring to $@ in your post-eval if() you run the risk of your exception handling code over-writing your exception. Also don't forget that if you're dealing with an hierarchy of exception classes you may need to test for the most specific subclass first, to ensure your handlers operate as expected:code:
|
# ? Aug 28, 2009 08:04 |
|
I've finished a few chapters on perl, enough that I'm comfortable writing a couple of little scripts, understand scalars, hashes etc. I'm guessing I can automate an annoying online task with perl. Once a week, I have to fill out a webform (timesheet). Are there any tutorials for doing this with a perl script ran on client side? So I want a script that will access website, populate selected fields and hit the submit button. Anybody got links to examples where something like this is done?
|
# ? Sep 1, 2009 00:53 |
|
This is the bread and buffer of WWW::Mechanize. If its own documentation isn't enough, I'm sure you could easily find a dozen blog posts explaining how to automate form submission with it.
|
# ? Sep 1, 2009 00:55 |
|
I'm getting into Moose and I am looking to make a simple object for a User, but I'm not sure the best way to go about implementing Rose::DB::Object into it. Would anyone be willing to throw me a few pointers on where to start?
|
# ? Sep 8, 2009 02:36 |
|
Where are you going to be using this user class? If I were doing it in Catalyst, for example, I'd create a new model which consumes the RDBO schemas and loads the row from the database on your behalf, before packing it into the attribute of a Moose object and returning that. Then you call high level methods on the Moose object and it operates on your RDBO row under the hood.
|
# ? Sep 8, 2009 08:58 |
|
atomicstack posted:Where are you going to be using this user class? If I were doing it in Catalyst, for example, I'd create a new model which consumes the RDBO schemas and loads the row from the database on your behalf, before packing it into the attribute of a Moose object and returning that. Then you call high level methods on the Moose object and it operates on your RDBO row under the hood. I'm writing it for use within my own framework. The current method I've gone about it is as such, though I plan on expanding the fields that 'rose' handles out to include all of the row's fields. Possibly I'll be doing that through more logic in BUILD? I'm not too familiar and if this seems like an obtuse way of getting what I need, please let me know. code:
|
# ? Sep 8, 2009 15:42 |
|
You can add delegates at run-time, but you'll have to pay the toll of mutability, and to be honest database schemas don't really change all that frequently. Unless you need to do it that way, you might be best off hacking some meta-code into your toolchain so that when you update your schema files, a complete Moose role will pop out that contains a correct has 'rose' declaration, with the table's column names listed as delegates under handles. Then you can replace your existing has 'rose' declaration with, err, with.
|
# ? Sep 8, 2009 18:09 |
|
atomicstack posted:You can add delegates at run-time, but you'll have to pay the toll of mutability, and to be honest database schemas don't really change all that frequently. Unless you need to do it that way, you might be best off hacking some meta-code into your toolchain so that when you update your schema files, a complete Moose role will pop out that contains a correct has 'rose' declaration, with the table's column names listed as delegates under handles. Then you can replace your existing has 'rose' declaration with, err, with. Did just what you described, took all of 5 minutes to do. Clarifies and compartmentalizes the objects properly with little effort. Moose rules.
|
# ? Sep 8, 2009 18:51 |
|
It does. I'm considering making a Moose-ified branch of Net::DRI, we use it pretty heavily at work and there's a lot of cruft related to validation and introspection that would be better off dead, and roles would be perfect for handling the bizarro EPP extensions that pop up at the registry and TLD levels. (Which doesn't help at all when someone like Nominet comes along and decides to adopt the protocol for the .uk registry and then go on to ignore RFC and implement 90% of their system in the protocol's extension space, resulting in some sort of weird quantum state of simultaneously being both EPP and not-EPP and making my class hierarchy all wonky at the bottom.)
|
# ? Sep 10, 2009 19:03 |
|
Say, I'm building an object like so:code:
Now in the ESP::Objects::Events I have: code:
|
# ? Sep 10, 2009 19:12 |
|
Another small Moose question. Is it possible to extend an object and have the extension replace one attribute with another. For example: code:
|
# ? Sep 11, 2009 02:49 |
|
Fenderbender posted:What would be the proper way to predicate or what-have-you to make it so that if the value passed to these is undef it goes to the default value? Puck42 posted:Is it possible to extend an object and have the extension replace one attribute with another. code:
|
# ? Sep 11, 2009 05:11 |
|
How come in a for loop over a tied array, FETCH gets called twice for each index? Seems kind of... redundant. I would look for the reason why in the source myself but I don't know how to navigate it.
|
# ? Sep 11, 2009 22:54 |
|
Triple Tech posted:How come in a for loop over a tied array, FETCH gets called twice for each index? Seems kind of... redundant. That doesn't sound right. Are you sure the array element is really only being accessed once? You may have something like this going on... code:
|
# ? Sep 14, 2009 18:28 |
|
You know what, nevermind. It was probably something gay in my implementation of the tied class. vv
Triple Tech fucked around with this message at 19:04 on Sep 14, 2009 |
# ? Sep 14, 2009 18:50 |
|
Let's say I have an idea for a framework. Should I publish immediately to CPAN so people can start toying with it or should I hold back until it's "complete"? I know what you're thinking. Triple Tech, you always have ideas! I know. But this time I actually made some proof of concept code, so I know this works somewhat. The idea is to have LINQ for Perl. If you don't know LINQ, it's a query language for C#. It's like having SQL for lists/arrays or really any collection (trees, graphs, other data providers). Here's what I would think it would look like in Perl: code:
|
# ? Sep 14, 2009 23:06 |
|
I think I'd write an RFC on Perlmonks first.
|
# ? Sep 14, 2009 23:11 |
|
Triple Tech posted:Let's say I have an idea for a framework. Should I publish immediately to CPAN so people can start toying with it or should I hold back until it's "complete"? I know what you're thinking. Triple Tech, you always have ideas! I know. But this time I actually made some proof of concept code, so I know this works somewhat. I don't know LINQ, but most of it looks to be redundant in perl. Perl already has map, grep, and sort. All you'd be doing is changing the syntax.
|
# ? Sep 15, 2009 05:53 |
|
Tim Berners-Lee posted:I don't know LINQ, but most of it looks to be redundant in perl. Perl already has map, grep, and sort. All you'd be doing is changing the syntax. That's like saying LINQ is redundant because SQL exists. Which is only partially true. The point of making a language-integrated query ... language. is so that other people can implement data providers. So of course LINQ for local collections looks like it could be done better with map, grep, and sort. But you can use the remote collections version for both remote and local collections. Then, you could mix and match local and remote collections. It's like doing a join at runtime between an array and an XML document, without writing a lick of SQL or XPath.
|
# ? Sep 15, 2009 13:32 |
|
Any mod_perl gurus around, how hard is it to dynamically configure an Apache+FastCGI vhost? I'd like to completely decouple Catalyst from our front end web servers so we can run different revisions simultaneously on the same boxes, for staging/QA, and so that we can promote a new version into production with no down-time. Mostly I'd like to be able to update the FastCGI endpoints (we're currently using TCP/IP for the back-end channel) on the fly without having to resort to writing out a new config file to disk and then reloading it.
|
# ? Sep 16, 2009 05:14 |
|
I've been given the task to write the new perl DB Backup management script at work, as clients now want database backups every half hour or 15 minutes instead of the 1 hour we had beforehand. Now, there are about 30 websites on the server, each with a db size of about 300mb. If I accomplish this using good 'ol fork and exec where the parent management script forks 30 times and calls the script that does the actual backing up, what issues would I run into?
|
# ? Sep 21, 2009 02:22 |
|
|
# ? Apr 25, 2024 23:26 |
|
TheHeadSage posted:what issues would I run into? Locking all tables from writes every 15 minutes to insure consistency? Are you using innodb with transactions? Edit: Er, sorry, I'm assuming you're using mysql, is that correct? Ninja Rope fucked around with this message at 07:02 on Sep 21, 2009 |
# ? Sep 21, 2009 06:54 |