Search Results

Search found 9 results on 1 pages for 'alexh'.

Page 1/1 | 1 

  • How do I get django comments to join on auth_user

    - by AlexH
    I'm using the django comments framework, and when I list the comments I want to include some of the information stored in auth_user. However, I find I need an extra query for each comment to get the user info. I tried using select_related() when I pull the comments, but this doesn't help. Is there a reason that it's not joining the auth_user table, and is there any way to force it to?

    Read the article

  • Use python decorators on class methods and subclass methods

    - by AlexH
    Goal: Make it possible to decorate class methods. When a class method gets decorated, it gets stored in a dictionary so that other class methods can reference it by a string name. Motivation: I want to implement the equivalent of ASP.Net's WebMethods. I am building this on top of google app engine, but that does not affect the point of difficulty that I am having. How it Would look if it worked: class UsefulClass(WebmethodBaseClass): def someMethod(self, blah): print(blah) @webmethod def webby(self, blah): print(blah) # the implementation of this class could be completely different, it does not matter # the only important thing is having access to the web methods defined in sub classes class WebmethodBaseClass(): def post(self, methodName): webmethods[methodName]("kapow") ... a = UsefulClass() a.post("someMethod") # should error a.post("webby") # prints "kapow" There could be other ways to go about this. I am very open to suggestions

    Read the article

  • python decorator to modify variable in current scope

    - by AlexH
    Goal: Make a decorator which can modify the scope that it is used in. If it worked: class Blah(): # or perhaps class Blah(ParentClassWhichMakesThisPossible) def one(self): pass @decorated def two(self): pass Blah.decorated ["two"] Why? I essentially want to write classes which can maintain specific dictionaries of methods, so that I can retrieve lists of available methods of different types on a per class basis. errr..... I want to do this: class RuleClass(ParentClass): @rule def blah(self): pass @rule def kapow(self): pass def shazam(self): class OtherRuleClass(ParentClass): @rule def foo(self): pass def bar(self): pass RuleClass.rules.keys() ["blah", "kapow"] OtherRuleClass.rules.keys() ["foo"]

    Read the article

  • Flex: Using NumericStepper as an itemEditor in a DataGrid

    - by AlexH
    I am trying to make one field in a datagrid editable with a numeric stepper. My current attempts look like they are working, but the dataProvider is not actually being changed. Based on what I have read in a billion different places, the syntax should be < mx:DataGridColumn dataField="a" itemRenderer="mx.controls.NumericStepper" rendererIsEditor="true" editorDataField="value" / > I have tried several variations on this theme, and nothing seems to work. What am I missing?

    Read the article

  • Associate "Code/Properties/Stuff" with Fields in C# without reflection. I am too indoctrinated by J

    - by AlexH
    I am building a library to automatically create forms for Objects in the project that I am working on. The codebase is in C#, and essentially we have a HUGE number of different objects to store information about different things. If I send these objects to the client side as JSON, it is easy enough to programatically inspect them to generate a form for all of the properties. The problem is that I want to be able to create a simple way of enforcing permissions and doing validation on the client side. It needs to be done on a field by field level. In javascript I would do this by creating a parallel object structure, which had some sort of { permissions : "someLevel", validator : someFunction } object at the nodes. With empty nodes implying free permissions and universal validation. This would let me simply iterate over the new object and the permissions object, run the check, and deal with the result. Because I am overfamilar with the hammer that is javascript, this is really the only way that I can see to deal with this problem. My first implementation thus uses reflection to let me treat objects as dictionaries, that can be programatically iterated over, and then I just have dictionaries of dictionaries of PermissionRule objects which can be compared with. Very javascripty. Very awkward. Is there some better way that I can do this? Essentially a way to associate a data set with each property, and then iterate over those properties. Or else am I Doing It Wrong?

    Read the article

  • python decorator to add function to list in current scope

    - by AlexH
    Goal: Make a decorator which can modify the scope that it is used in. If it worked: class Blah(): # or perhaps class Blah(ParentClassWhichMakesThisPossible) def one(self): pass @decorated def two(self): pass Blah.decorated ["two"] Why? I essentially want to write classes which can maintain specific dictionaries of methods, so that I can retrieve lists of available methods of different types on a per class basis. errr..... I want to do this: class RuleClass(ParentClass): @rule def blah(self): pass @rule def kapow(self): pass def shazam(self): class OtherRuleClass(ParentClass): @rule def foo(self): pass def bar(self): pass RuleClass.rules.keys() ["blah", "kapow"] OtherRuleClass.rules.keys() ["foo"]

    Read the article

  • Download a file with Adobe AIR

    - by AlexH
    How do I download a file from the internet in a Flex based AIR application. I tried using a file with url set to the address, but I got a file does not exist error when I tried to save it. And it is really hard to google for help on this issue.

    Read the article

  • Is it possible, in a django template, to check if an object is contained in a list

    - by AlexH
    I'm very new to django, about a week into it. I'm making a site where users enter stuff, then other users can vote on whether they like the stuff or not. I know it's not so novel, but it's a good project to learn a bunch of tools. I have a many-to-many table for storing who likes or dislikes what. Before I render the page, I pull out all the likes and dislikes for the current user, along with the stuff I'm going to show on the page. When I render the page, I go through the list of stuff I'm going to show and print them out one at a time. I want to show the user which stuff they liked, and which they didn't. So in my django template, I have an object called entry. I also have two lists of objects called likes and dislikes. Is there any way to determine if entry is a member of either list, inside my django template. I think what I'm looking for is a filter where I can say something like {% if entry|in:likes %} or {% if likes|contains:entry %} I know I could add a method to my model and check for each entry individually, but that seems like it would be database intensive. Is there a better way to think about this problem?

    Read the article

1