Search Results

Search found 19 results on 1 pages for 'parand'.

Page 1/1 | 1 

  • django-mptt: how to successfully move nodes around

    - by Parand
    django-mptt seems determined to drive me out of my mind. I'm trying to do something relatively simple: I'm going to delete a node, and need to do something reasonable with the node's children. Namely, I'd like to move them up one level so they're children of their current parent's parent. That is, if the tree looks like: Root | Grandpa | Father | | C1 C2 I'm going to delete Father, and would like C1 and C2 to be children of Grandpa. Here's the code I'm using: class Node(models.Model): first_name = models.CharField(max_length=80, blank=True) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') def reparent_children(self, parent): print "Reparenting" for child in self.get_children(): print "Working on", child.first_name, "to parent", parent.email parent = Node.objects.get(id=parent.id) child.move_to(parent, 'last-child') child.save() So I'd call: father.reparent_children(grandpa) father.parent = None father.save() This works - almost. The children report their parents as Grandpa: c1.parent == grandpa # True Grandpa counts C1 and C2 among its children c1 in grandpa.children.all() # True However, Root disowns these kids. c1.get_root() == father # c1's root is father, instead of Root c1 in root.get_descendants() # False How do I get the children to move and their root not get corrupted?

    Read the article

  • Storing hierarchical (parent/child) data in Python/Django: MPTT alternative?

    - by Parand
    I'm looking for a good way to store and use hierarchical (parent/child) data in Django. I've been using django-mptt, but it seems entirely incompatible with my brain - I end up with non-obvious bugs in non-obvious places, mostly when moving things around in the tree: I end up with inconsistent state, where a node and its parent will disagree on their relationship. My needs are simple: Given a node: find its root find its ancestors find its descendants With a tree: easily move nodes (ie. change parent) My trees will be smallish (at most 10k nodes over 20 levels, generally much much smaller, say 10 nodes with 1 or 2 levels). I have to think there has to be an easier way to do trees in python/django. Are there other approaches that do a better job of maintaining consistency?

    Read the article

  • Python/Django: Which authorize.net library should I use?

    - by Parand
    I need authorize.net integration for subscription payments, likely using CIM. The requirements are simple - recurring monthly payments, with a few different price points. Customer credit card info will be stored a authorize.net . There are quite a few libraries and code snippets around, I'm looking for recommendations as to which work best. Satchmo seems more than I need, and it looks like it's complex. Django-Bursar seems like what I need, but it's listed as alpha. The adroll/authorize library also looks pretty good. The CIM XML APIs don't look too bad, I could connect directly with them. And there are quite a few other code snippets. What's the best choice right now, given my fairly simple requirements?

    Read the article

  • Headless, scriptable Firefox/Webkit on linux?

    - by Parand
    I'm looking to automate some web interactions, namely periodic download of files from a secure website. This basically involves entering my username/password and navigating to the appropriate URL. I tried simple scripting in Python, followed by more sophisticated scripting, only to discover this particular website is using some obnoxious javascript and flash based mechanism for login, rendering my methods useless. I then tried HTMLUnit, but that doesn't seem to want to work either. I suspect use of Flash is the issue. I don't really want to think about it any more, so I'm leaning towards scripting an actual browser to log in and grab the file I need. Requirements are: Run on linux server (ie. no X running). If I really need to have X I can make that happen, but I won't be happy. Be reliable. I want to start this thing and never think about it again. Be scriptable. Nothing too sophisticated, but I should be able to tell the browser the various steps to take and pages to visit. Are there any good toolkits for a headless, X-less scriptable browser? Have you tried something like this and if so do you have any words of wisdom?

    Read the article

  • Python Twitter library: which one?

    - by Parand
    I realize this is a bit of a lazyweb question, but I wanted to see which python library for Twitter people have had good experiences with. I've used Python Twitter Tools and like its brevity and beauty of interface, but it doesn't seem to be one of the popular ones - it's not even listed on the Twitter Libraries page. There are, however, plenty of others listed: oauth-python-twitter2 by Konpaku Kogasa. Combines python-twitter and oauth-python-twitter to create an evolved OAuth Pokemon. python-twitter by DeWitt Clinton. This library provides a pure Python interface for the Twitter API. python-twyt by Andrew Price. BSD licensed Twitter API interface library and command line client. twitty-twister by Dustin Sallings. A Twisted interface to Twitter. twython by Ryan McGrath. REST and Search library inspired by python-twitter. Tweepy by Josh Roesslein. Supports OAuth, Search API, Streaming API. My requirements are fairly simple: Be able to use OAuth Be able to follow a user Be able to send a direct message Be able to post Streaming API would be nice Twisted one aside (I'm not using twisted in this case), have you used any of the others, and if so, do you recommend them? [Update] FWIW, I ended up going with Python Twitter Tools again. The new version supported OAuth nicely, and it's a very clever API, so I stuck to it.

    Read the article

  • Python: OSX Library for fast full screen jpg/png display

    - by Parand
    Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates: Full screen image display High quality image fit-to-screen (for display) Low memory usage Fast display Reasonable learning curve (the simpler the better) Looks like there are several choices, so which is the best? Here are some I've run across: PyOpenGL PyGame PyQT wxpython I don't have any particular experience with any of these, nor any strong desire to become an expert - I'm looking for the simplest solution. What do you recommend? [Update] For those not familiar with ACDSee, here's what it does that I care about: Simple list/thubmnail display of images in a directory Sort by name/size/type Ability to view images full screen Single-key delete while viewing full screen Move to next/previous image while viewing full screen Ability to select a group of images for: move to / copy to directory delete resize ACDSee has a bunch of niceties as well, such as remembering directories you've moved images to in the past, remembering your resize settings, displaying the total size of the images you've selected, etc. I've tried most of the options I could find (including Xee) and none of them quite get there. Please keep in mind that this is a programming/library question, not a criticism of any of the existing tools.

    Read the article

  • Minimalist, Tiny Javascript Template System?

    - by Parand
    I'm looking for a minimalist template system for javascript, ala John Resig's Javascript Micro Templating. The smaller the better, and if it's jquery based even better. Recommendations? I tried John's micro-templating but ran into a few issues, wanted to see if there are more baked / better packaged solutions out there. [Update] I tried Resig's Micro Templating again and it's working well for me. Would still like to hear about other alternatives if there are any.

    Read the article

  • Possible to download entire whois database / list of registered domains?

    - by Parand
    I wanted to do some analysis on registered domain names. Looks like I can hit whois.internic.net to get information about each domain, but it also looks like there are rate limits that prevent me from doing large numbers of queries. Is there a way to periodically (say daily) grab the entire whois database? I really only care about whether a domain is registered or not, so I don't need the full whois information.

    Read the article

  • Python: split a list based on a condition?

    - by Parand
    What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of: good = [x for x in mylist if x in goodvals] bad = [x for x in mylist if x not in goodvals] is there a more elegant way to do this? Update: here's the actual use case, to better explain what I'm trying to do: # files looks like: [ ('file1.jpg', 33L, '.jpg'), ('file2.avi', 999L, '.avi'), ... ] IMAGE_TYPES = ('.jpg','.jpeg','.gif','.bmp','.png') images = [f for f in files if f[2].lower() in IMAGE_TYPES] anims = [f for f in files if f[2].lower() not in IMAGE_TYPES]

    Read the article

  • Elegant setup of Python logging in Django

    - by Parand
    I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple: Different log handlers for different events - that is, I want to be able to log to different files Easy access to loggers in my modules. The module should be able to find its logger with little effort. Should be easily applicable to command-line modules. Parts of the system are stand-alone command line or daemon processes. Logging should be easily usable with these modules. My current setup is to use a logging.conf file and setup logging in each module I log from. It doesn't feel right. Do you have a logging setup that you like? Please detail it: how do you setup the configuration (do you use logging.conf or set it up in code), where/when do you initiate the loggers, and how do you get access to them in your modules, etc.

    Read the article

  • Quickbooks integration: IPP/IDS: can these by used for actual data exchange?

    - by Parand
    Poking around options for integrating an online app with Quickbooks, I've made a lot of headway with QBWC, but it's fairly ugly. From an end user perspective the usability of QBWC is pretty low. Intuit is now pushing Intuit Partner Platform (IPP) and Intuit Data Services (IDS). I can't quite figure out what these are about: Is IPP limited to using Flex, or can it work with existing web apps? Are there APIs for actual data exchange? Is it possible to interact with desktop Quickbooks using IPP or IDS? If there is sample code, particularly in Python, some pointers would be great.

    Read the article

  • Tkinter Packing Strangeness: Buttons packed above others

    - by Parand
    I'm sure I'm doing something obvious wrong here, but I can't see it. I end up with the "Should be on top" label packed at the bottom instead of at the top. What am I doing wrong? from Tkinter import * class SelectAction(Frame): buttons = {} def callback(self): print "Callback" def createWidgets(self): logo_label = Label(text="Should be on top").pack(fill=X) for name, text, callback in ( ('setup_account', 'Account Settings', self.callback), ('do_action', 'Do Something', self.callback), ): self.buttons[name] = Button(self, text=text, command=callback).pack(fill=X) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() if __name__ == "__main__": root = Tk() app = SelectAction(master=root) app.mainloop() root.destroy()

    Read the article

  • awk or sed: Best way to grab [this text]

    - by Parand
    I'm trying to parse various info from log files, some of which is placed within square brackets. For example: Tue, 06 Nov 2007 10:04:11 INFO processor:receive: [someuserid], [somemessage] msgtype=[T] What's an elegant way to grab 'someuserid' from these lines, using sed, awk, or other unix utility?

    Read the article

  • YUI Autocomplete: itemSelectEvent getting lost with IE6 and IE7?

    - by Parand
    I'm using YUI Autocomplete (latest version loaded using loader as of today (May 14th, 2010), which looks to be 2.8.1, with the following options: ac = new YAHOO.widget.AutoComplete("mynode", "autocomp_node", ac_ds, {typeAhead: true, forceSelection: true}); ac.itemSelectEvent.subscribe( function(type, args) { alert("hey:" + args[2][1]); $('#parent_id').val(args[2][1]); }); The itemSelectEvent catches selections in AutoComplete and fills in some data on the parent. This works on FF, Chrome, Safari, and IE8. On IE6 and IE7, however, the event never seems to trigger. To replicate: In the autocomplete field, allow it to autofill for you, then hit enter. This should select the autofill and move on to the next field (that's what it does in other browsers). With IE6 and IE7 it seems to instead trigger the form submission - the itemSelectEvent never fires (or perhaps fires after the form submission?). Has anyone seen this? Any work-arounds?

    Read the article

  • Python: Attractive, clean, packagable windows GUI library

    - by Parand
    I need to create a simple windows based GUI for a desktop application that will be downloaded by end users. The application is written in python and will be packaged as an installer or executable. The functionality I need is simple - selecting from various lists, showing progress bars, etc. No animations, sprites, or other taxing/exotic things. Seems there are quite a few options for Python GUI libraries (Tk, QT, wxPython, Gtk, etc). What do you recommend that: Is easy to learn and maintain Can be cleanly packaged using py2exe or something similar Looks nice

    Read the article

  • Looking for: nosql (redis/mongodb) based event logging for Django

    - by Parand
    I'm looking for a flexible event logging platform to store both pre-defined (username, ip address) and non-pre-defined (can be generated as needed by any piece of code) events for Django. I'm currently doing some of this with log files, but it ends up requiring various analysis scripts and ends up in a DB anyway, so I'm considering throwing it immediately into a nosql store such as MongoDB or Redis. The idea is to be easily able to query, for example, which ip address the user most commonly comes from, whether the user has ever performed some action, lookup the outcome for a specific event, etc. Is there something that already does this? If not, I'm thinking of this: The "event" is a dictionary attached to the request object. Middleware fills in various pieces (username, ip, sql timing), code fills in the rest as needed. After the request is served a post-request hook drops the event into mongodb/redis, normalizing various fields (eg. incrementing the username:ip address counter) and dropping the rest in as is. Words of wisdom / pointers to code that does some/all of this would be appreciated.

    Read the article

  • Django: select_related and GenericRelation

    - by Parand
    Does select_related work for GenericRelation relations, or is there a reasonable alternative? At the moment Django's doing individual sql calls for each item in my queryset, and I'd like to avoid that using something like select_related. class Claim(models.Model): proof = generic.GenericRelation(Proof) class Proof(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') I'm selecting a bunch of Claims, and I'd like the related Proofs to be pulled in instead of queried individually.

    Read the article

  • Django: common template subsections

    - by Parand
    What's a good way to handle commonly occurring subsections of templates? For example, there is a sub-header section that's used across 4 different pages. The pages are different enough to not work well with template inheritance (ie. "extends" doesn't fit well). Is "include" the recommended method here? It feels a bit heavyweight, requiring each subsection or snippet to be in its own file. Are there any performance issues in using include or is it smart about forming template from the subsections (ie. if I make extensive use of it, do I pay any penalties)? I think what I'm looking for is something like template tags, but without the programming - a simple way to create a library of html template tags I can sprinkle in other templates.

    Read the article

  • Django: Inject errors into already validated form?

    - by Parand
    After my form.Form validates the user input values I pass them to a separate (external) process for further processing. This external process can potentially find further errors in the values. Is there a way to inject these errors into the already validated form so they can be displayed via the usual form error display methods? Or, are there better alternative approaches? One suggestions was to include the external processing in the form validation. I'm not crazy about this since the external process does a lot more than just validate.

    Read the article

1