|
leedo posted:I don't think that is possible. You would probably have to do an svn checkout and install that way. I don't really see the point in doing that, I can't imagine much is changing on the userspace end of things.
|
# ? Sep 9, 2008 02:57 |
|
|
# ? Apr 24, 2024 05:42 |
|
You can subclass ResultSets too. This allows me to call $db->rs('domains.domain_names')->search_by_domain('foo.com') and still use indexes/joins properly. It's nice to encapsulate larger, reusable queries into one callable name, instead of copy and pasting the same SQL query in 13 different files code:
Mario Incandenza fucked around with this message at 11:28 on Sep 9, 2008 |
# ? Sep 9, 2008 11:07 |
|
Well, I couldn't figure out how to get any of this crap to work in my Catalyst's dbic schemas haha
|
# ? Sep 10, 2008 02:14 |
|
Are you putting them inside your DBIC Schema, (e.g. MyDB/Schema/Table.pm), or MyApp/Model/MyDB/Table.pm? The model is just a wrapper around the schema, you'll need to place your custom methods in the schema if you want to reuse them properly outside of Catalyst.
|
# ? Sep 10, 2008 09:47 |
|
SpeedFrog posted:Are you putting them inside your DBIC Schema, (e.g. MyDB/Schema/Table.pm), or MyApp/Model/MyDB/Table.pm? The model is just a wrapper around the schema, you'll need to place your custom methods in the schema if you want to reuse them properly outside of Catalyst. Could I use __PACKAGE__->resultset_class('Game:B::Schema::Table'); inside Game:B::Schema::Table itself? I'd like to keep everything inside the schema files if possible
|
# ? Sep 10, 2008 16:22 |
|
Yup, that works just fine, in fact I believe that's the recommended place, as it sits nicely alongside your relationship definitions (you mean resultset_class('Game::DB::ResultSet::Table'), yeah?). Also, I know it's in the docs, but it's useful enough to bear repeating... if you ever need a plain hashref, you can do this (though keep in mind the keys still will be lowercased): code:
|
# ? Sep 10, 2008 16:33 |
|
SpeedFrog posted:Yup, that works just fine, in fact I believe that's the recommended place, as it sits nicely alongside your relationship definitions (you mean resultset_class('Game:B::ResultSet::Table'), yeah?).
|
# ? Sep 10, 2008 23:44 |
|
Inflation happens at the very end of the process, so as long as you define your join conditions by chaining calls to the resultset (as opposed to calling relations like $row->relation), your choice of inflator shouldn't impact the data you get back - just the form you receive it in. The HashRefInflator doesn't do much more than pass through a hashref after fiddling with its values a little - ordinarily it will be blessed into DBIx::Class::Row and packed inside an object's private _column_data attribute. The class is really small, just two subs. Mario Incandenza fucked around with this message at 10:50 on Sep 11, 2008 |
# ? Sep 11, 2008 10:41 |
|
I've been having this issue for a few weeks now and it's driving me up a wall. I'm writing a web app using Mason and I have a custom module that contains a lot of common functions. For some reason now, when ever I add any new function or edit an existing one mod_perl decides that the function doesn't exist and tells me that the subroutine is undefined when I know it is. Once I remove the added lines the function works fine once again. Anyone ever have a similar issue?
|
# ? Sep 11, 2008 17:30 |
|
Puck42 posted:I've been having this issue for a few weeks now and it's driving me up a wall. Tried turning off code caching ?
|
# ? Sep 11, 2008 23:50 |
|
Empty Threats posted:Tried turning off code caching ? I have, same thing happens.
|
# ? Sep 12, 2008 01:24 |
|
Ok I could use a little help regarding dbix::class and relationships. Right now I have it setup so a nation can have any number of resource_ids (which is joined on Resources, so I can add more resources later with a DB update instead of changing code). I believe I mentioned it earlier, but its a clone of the Role's tutorial from the Catalyst Manual (if that makes it any easier to understand?). So I can call $resultset->nation->resources to get each resource object a nation has linked to it (foreach $a $resultset->nation->resources { print "resource name: $a->name resource id: $a->id"; }) (at this point i'm still probably not very clear, but I didnt even know what a database relationship was until recently so try and bear with me) What I want to do at this point is add another relationship. Each nation can have many Trades. The trade table/schema would simply be 2 columns, id1 and id2. This is where I get really lost, because I dont know how to set a relationship with id1 OR id2. The only solution I can think of is to set a seperate relationship for id1 and id2 (2 seperate belongs_to). Then again maybe my idea is flawed to begin with, as ultimately I just want to get the Resources of all the nations that share a trade with x-nation. A clearcut example would be nice, but even some direction in where to go as far as this whole relationship thing is concerned would be wonderful code:
code:
code:
|
# ? Sep 12, 2008 05:13 |
|
Puck42 posted:I have, same thing happens. code:
uG posted:Then again maybe my idea is flawed to begin with, as ultimately I just want to get the Resources of all the nations that share a trade with x-nation. code:
code:
Mario Incandenza fucked around with this message at 17:33 on Sep 12, 2008 |
# ? Sep 12, 2008 16:51 |
|
SpeedFrog posted:Since you can't use a many-to-many relationship to perform a search, you just need to make a "left" and "right" column and join across them with something like this (untested): code:
uG fucked around with this message at 19:16 on Sep 13, 2008 |
# ? Sep 13, 2008 06:04 |
|
I don't know if this would be an ok place for this or anything, but my company is looking for web and application developers specializing in Perl. If you're interested, send me a PM and I'll give you some contact information.
|
# ? Sep 16, 2008 13:53 |
|
Randomly curious, what city/metropolitan area are you located in?
|
# ? Sep 16, 2008 14:05 |
|
Fenderbender posted:I don't know if this would be an ok place for this or anything, but my company is looking for web and application developers specializing in Perl. If you're interested, send me a PM and I'll give you some contact information. I figure 3+ years on a life system should be decent experience for what you want. Mithaldu fucked around with this message at 14:59 on Sep 16, 2008 |
# ? Sep 16, 2008 14:21 |
|
Triple Tech posted:Randomly curious, what city/metropolitan area are you located in? It's in Nashville, TN Mithaldu posted:Could you please activate the ability for other members here to email you? I don't have PM ability, but if you can accept remote workers i'd be very interested. Or, if you don't want to do that, you could give my ICQ/AIM or Yahoo ids in my profile a poke. Done. I'll also drop you an IM once I get to work.
|
# ? Sep 16, 2008 14:26 |
|
Thanks and sent.
|
# ? Sep 16, 2008 14:59 |
|
Any Perl/Tk goons around? I'm fairly new at it, and I've hit a bit of a snag. I want my application to launch a new window, be able to manipulate widgets in that window, and then return variables to the main application. I'm clearly doing something very stupid in the process, because my attempts to manipulate the properties of widgets in the child window always results in "Tk::Error: Can't call method "Contents" on an undefined value at blah blah blah". Clearly it doesn't know where to find the widget I'm trying to manipulate, which says to me that I'm not referring to it properly. This is the first time I've tried to do this exact thing, and I can't find anything in my Perl books or via Google that's helpful. I'm not primarily a programmer, though, so it's possible that I've looked right at the answer and just not understood it. Here are the relevant bits of code: code:
The error happens any time I try to manipulate $batchproject_files_list, and indicates to me that it's just out of scope. My guess is that there's some way to refer to widgets by window, but I seriously can't find it and I really have looked. The code works fine if I just put it into the main window instead. Like I say, this is the first time I've tried to do something like this - it's almost certainly some very thing.
|
# ? Sep 17, 2008 03:52 |
|
mofolotopo posted:The error happens any time I try to manipulate $batchproject_files_list, and indicates to me that it's just out of scope. It's quite possible that you have problems that have nothing to do with scope, but you also are definitely having scope problems, so let's fix those first. First off, the basics. Scoping rules are what determine which instance of a variable you're talking about when you mention that variable. The standard rule in most programming languages, including perl, is called lexical scoping: if a variable reference occurs inside a block that declares that variable, use the local instance of that variable; if it's declared in the next-inner-most enclosing block, use that instance; and so on until you're not inside any more blocks, which is called global scope. In perl, you declare a lexically-scoped variable by saying something like "my $x" or "my @y" somewhere in a block. So, when batchprojectUpdateFiles uses a variable called $batchproject_files_list, that variable must exist either locally (which it hasn't been) or globally (which works without a declaration if you don't ask perl to complain about such uses). You're clearly trying to use the same variable from toolsBatchProject, but that variable has been scoped locally to that function, so you can't get at it from batchprojectUpdateFiles. You've got a lot of options here; here's two of them. First, you could just remove the "my" from the variable in toolsBatchProject, making the variable global, so the access in batchprojectUpdateFiles will be able to find the same variable. Alternatively, you could pass the current value in as a parameter.
|
# ? Sep 17, 2008 06:30 |
|
rjmccall posted:It's quite possible that you have problems that have nothing to do with scope, but you also are definitely having scope problems, so let's fix those first. Welp, it was that drat simple. For some reason I thought that a function (B) that was called from within another function (A) would be able to see the variables that were scoped to A. Clearly not the case. Thanks a bunch! mofolotopo fucked around with this message at 06:56 on Sep 17, 2008 |
# ? Sep 17, 2008 06:50 |
|
That sort of thing is called dynamic scope. It was popular before (the much saner) lexical scope was invented. Perl supports it with the local operator.
|
# ? Sep 17, 2008 07:05 |
|
Sartak posted:That sort of thing is called dynamic scope. It was popular before (the much saner) lexical scope was invented. Perl supports it with the local operator. It was popular with interpreted languages as it simple to implement.
|
# ? Sep 17, 2008 17:37 |
|
tef posted:It was popular with interpreted languages as it simple to implement. It's actually quite nice for small, rapidly-developed programs with no real efficiency needs. Even purely lexically-scoped languages tend to have some similar mechanism, be it implicit parameters, thread-local memory, or (if all else fails) true global variables.
|
# ? Sep 18, 2008 01:30 |
|
mofolotopo posted:Welp, it was that drat simple. For some reason I thought that a function (B) that was called from within another function (A) would be able to see the variables that were scoped to A. Clearly not the case. Thanks a bunch! A subroutine definition can refer to variables that exist in the surrounding scope. code:
|
# ? Sep 18, 2008 20:05 |
|
On *nix, how can I determine which mountpoint owns a particular file? If I can't find a programmatic way, I'll have to parse `mount`, which seems ugly.
|
# ? Sep 22, 2008 14:47 |
|
satest4 posted:A subroutine definition can refer to variables that exist in the surrounding scope. That sort of thing is called a closure.
|
# ? Sep 22, 2008 18:02 |
|
Stabby McDamage posted:On *nix, how can I determine which mountpoint owns a particular file? CPAN?
|
# ? Sep 22, 2008 18:04 |
|
Pooball posted:CPAN? Thanks. I searched CPAN for "mountpoint", "filesys", etc., but I didn't find that. EDIT: Wait, it doesn't have a way to look up a mountpoint from a file. I ended up using the output of 'df', since you can say "df /any/file" and it will just report the mount that provides that file. I'd still prefer a pure Perl method, if one exists. Stabby McDamage fucked around with this message at 18:10 on Sep 22, 2008 |
# ? Sep 22, 2008 18:07 |
|
Stabby McDamage posted:I'd still prefer a pure Perl method, if one exists. Here's some quick and dirty code to walk up an absolute path until we find a directory that's part of a different filesystem. code:
|
# ? Sep 22, 2008 18:43 |
|
I am writing a perl module that needs to do some cleanup after it has received a signal, particularly sigterm. My first thought was to just install the signal handler as part of the module, but that is probably not a good idea because it can overwrite/be overwritten by a conflicting signal handler in the caller. Alternatively, I could just leave it up to the user to install the signal handler. This is probably an acceptable solution but it seems messy and possibly unnecessary; there should be an easier way to do it. This cleanup is an implementation detail and should be hidden from the user if at all possible. Any advice?
|
# ? Sep 23, 2008 05:52 |
|
Paradox posted:This cleanup is an implementation detail and should be hidden from the user if at all possible. Perhaps you want an END block. code:
Also, if you're doing OO, then the method called DESTROY will be called just before an object's memory is freed. If you really need to respond to a signal then I guess just install the signal handler.
|
# ? Sep 23, 2008 06:21 |
|
ShoulderDaemon posted:Here's some quick and dirty code to walk up an absolute path until we find a directory that's part of a different filesystem. That's a cool idea. I might use that.
|
# ? Sep 23, 2008 15:41 |
|
Sartak posted:Perhaps you want an END block. I ran a quick test, and it looks like that doesn't work for SIGTERM: code:
|
# ? Sep 23, 2008 17:23 |
|
Erasmus Darwin posted:I ran a quick test, and it looks like that doesn't work for SIGTERM: You can save the original handler coderef, then call it from your handler, thus preserving whatever the user had set up: code:
<Ctrl-C> original handler new handler
|
# ? Sep 23, 2008 19:46 |
|
Are there any popular modules that depend on signal handlers? I mean, if it's your own private ecosystem, what's the harm in just straight up assigning a handler? Like you're probably the only one who's going to do it, right? But yes awesome solution. Although is there some sort of FILO/FIFO argument to be had here? SIGINT is ENDish?
|
# ? Sep 23, 2008 19:51 |
|
I know DBI (or at least DBD::Oracle) clobbers some signal handlers, although I'm not sure what it's doing with them.
|
# ? Sep 23, 2008 19:53 |
|
Stabby McDamage posted:You can save the original handler coderef, then call it from your handler, thus preserving whatever the user had set up: But that only works if he can ensure his handler is setup after the user's handler - he's in a module, so his code will be run first, and in any case the user may want to change the handler during runtime. For a transparent solution, I'd say the module should fork a subprocess and arrange for the signals it cares about to be delivered to that process instead, then use a more transparent form of IPC like a pipe or socket to communicate that information back to the main process. Failing that, I'd just document the signal handler as part of the API, install it when you load the module, and export the function used as a handler so that if the user wants to use that signal for their own purposes, they can call the module's handler after doing whatever they wanted to do.
|
# ? Sep 23, 2008 19:53 |
|
|
# ? Apr 24, 2024 05:42 |
|
Erasmus Darwin posted:I ran a quick test, and it looks like that doesn't work for SIGTERM: Try this: code:
|
# ? Sep 23, 2008 20:31 |