title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
Django/Python - Grouping objects by common set from a many-to-many relationships | 160,298 | <p>This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.</p>
<p>In Python, it's worth mentioning that the problem is somewhat related to <a href="http://stackoverflow.com/questions/773/how-do-i-use-pythons-i... | 5 | 2008-10-01T23:59:52Z | 161,227 | <p>You have a few problems here.</p>
<p>You didn't sort your list before calling groupby, and this is required. From <a href="http://www.python.org/doc/2.5/lib/itertools-functions.html" rel="nofollow">itertools documentation</a>:</p>
<blockquote>
<p>Generally, the iterable needs to already be sorted on the same key... | 1 | 2008-10-02T07:38:59Z | [
"python",
"django",
"algorithm",
"puzzle"
] |
Django/Python - Grouping objects by common set from a many-to-many relationships | 160,298 | <p>This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.</p>
<p>In Python, it's worth mentioning that the problem is somewhat related to <a href="http://stackoverflow.com/questions/773/how-do-i-use-pythons-i... | 5 | 2008-10-01T23:59:52Z | 173,592 | <p>If performance is a concern (i.e. lots of cars on a page, or a high-traffic site), <a href="http://groups.google.com/group/django-developers/browse_thread/thread/9a672d5bbbe67562" rel="nofollow">denormalization</a> makes sense, and simplifies your problem as a side effect.</p>
<p>Be aware that denormalizing many-to... | 1 | 2008-10-06T08:41:56Z | [
"python",
"django",
"algorithm",
"puzzle"
] |
Django/Python - Grouping objects by common set from a many-to-many relationships | 160,298 | <p>This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.</p>
<p>In Python, it's worth mentioning that the problem is somewhat related to <a href="http://stackoverflow.com/questions/773/how-do-i-use-pythons-i... | 5 | 2008-10-01T23:59:52Z | 178,657 | <p>Thank you all for the helpful replies. I've been plugging away at this problem. A 'best' solution still eludes me, but I've some thoughts.</p>
<p>I should mention that the statistics of the data-set I'm working with. In 75% of the cases there will be one Mod. In 24% of the cases, two. In 1% of the cases there will ... | 0 | 2008-10-07T14:17:42Z | [
"python",
"django",
"algorithm",
"puzzle"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 160,872 | <p>Basically, you're looking for a <strong>cross-platform software/package installer</strong> (on the lines of apt-get/yum/etc.) I'm not sure something like that exists?</p>
<p>An alternative might be specifying the list of packages that need to be installed via the OS-specific package management system such as Fink o... | 0 | 2008-10-02T04:21:44Z | [
"python",
"deployment",
"build-process"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 160,965 | <p>I have continued to research this issue since I posted the question. It looks like there are some attempts to address some of the needs I outlined, e.g. <a href="http://www.minitage.org/doc/rst/about.html" rel="nofollow">Minitage</a> and <a href="http://reductivelabs.com/projects/puppet/" rel="nofollow">Puppet</a> ... | 0 | 2008-10-02T05:12:05Z | [
"python",
"deployment",
"build-process"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 177,109 | <p>You might consider creating virtual machine appliances with whatever production OS you are running, and all of the software dependencies pre-built. Code can be edited either remotely, or with a shared folder. It worked pretty well for me in a past life that had a fairly complicated development environment.</p>
| 0 | 2008-10-07T03:13:09Z | [
"python",
"deployment",
"build-process"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 180,149 | <p>Puppet doesn't (easily) support the Win32 world either. If you're looking for a deployment mechanism and not just a "dev setup" tool, you might consider looking into ControlTier (<a href="http://open.controltier.com/" rel="nofollow">http://open.controltier.com/</a>) which has a open-source cross-platform solution. <... | 0 | 2008-10-07T20:06:39Z | [
"python",
"deployment",
"build-process"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 185,505 | <p>Setuptools may be capable of more of what you're looking for than you realize -- if you need a custom version of lxml to work correctly on MacOS X, for instance, you can put a URL to an appropriate egg inside your setup.py and have setuptools download and install that inside your developers' environments as necessar... | 3 | 2008-10-09T00:41:06Z | [
"python",
"deployment",
"build-process"
] |
Are there any other good alternatives to zc.buildout and/or virtualenv for installing non-python dependencies? | 160,834 | <p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started ... | 6 | 2008-10-02T03:55:22Z | 4,060,962 | <p>I always create a <code>develop.py</code> file at the top level of the project, and have also a <code>packages</code> directory with all of the <code>.tar.gz</code> files from PyPI that I want to install, and also included an unpacked copy of <code>virtualenv</code> that is ready to run right from that file. All of... | 3 | 2010-10-30T22:31:38Z | [
"python",
"deployment",
"build-process"
] |
What is "lambda binding" in Python? | 160,859 | <p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.</p>
| 9 | 2008-10-02T04:14:01Z | 160,884 | <p>Where have you seen the phrase used?</p>
<p>"Binding" in Python generally refers to the process by which a variable name ends up pointing to a specific object, whether by assignment or parameter passing or some other means, e.g.:</p>
<pre><code>a = dict(foo="bar", zip="zap", zig="zag") # binds a to a newly-created... | 1 | 2008-10-02T04:30:36Z | [
"python",
"binding",
"lambda"
] |
What is "lambda binding" in Python? | 160,859 | <p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.</p>
| 9 | 2008-10-02T04:14:01Z | 160,898 | <p>First, a general definition:</p>
<blockquote>
<p>When a program or function statement
is executed, the current values of
formal parameters are saved (on the
stack) and within the scope of the
statement, they are bound to the
values of the actual arguments made in
the call. When the statement is
exit... | 12 | 2008-10-02T04:38:59Z | [
"python",
"binding",
"lambda"
] |
What is "lambda binding" in Python? | 160,859 | <p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.</p>
| 9 | 2008-10-02T04:14:01Z | 160,920 | <p>I've never heard that term, but one explanation could be the "default parameter" hack used to assign a value directly to a lambda's parameter. Using Swati's example:</p>
<pre><code>def foo(x):
a = lambda x=x: x
x = 7
b = lambda: x
return a,b
aa, bb = foo(4)
aa() # Prints 4
bb() # Prints 7
</cod... | 6 | 2008-10-02T04:52:54Z | [
"python",
"binding",
"lambda"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 160,895 | <p>Have you looked at <a href="http://pyparsing.wikispaces.com/" rel="nofollow">PyParsing</a>?</p>
<p>From their homepage:</p>
<p>Here is a program to parse "Hello, World!" (or any greeting of the form ", !"):</p>
<pre><code>from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!" # <... | 3 | 2008-10-02T04:37:53Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 160,896 | <p>Sounds like you really just want to parse HTML, I recommend looking at any of the wonderful packages for doing so:</p>
<ul>
<li><a href="http://crummy.com/software/BeautifulSoup" rel="nofollow">BeautifulSoup</a></li>
<li><a href="http://codespeak.net/lxml/lxmlhtml.html" rel="nofollow">lxml.html</a></li>
<li><a href... | 5 | 2008-10-02T04:38:26Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 160,922 | <p>Look at documentation for following modules on <a href="http://www.cpan.org/" rel="nofollow">CPAN</a></p>
<p><a href="http://search.cpan.org/search?query=HTML%3A%3ATreeBuilder&mode=all" rel="nofollow">HTML::TreeBuilder</a></p>
<p><a href="http://search.cpan.org/author/MSISK/HTML-TableExtract-2.10/lib/HTML/Tabl... | 8 | 2008-10-02T04:53:03Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 161,146 | <p>If you're specifically after parsing links out of web-pages, then Perl's <a href="http://search.cpan.org/perldoc?WWW::Mechanize" rel="nofollow">WWW::Mechanize</a> module will figure things out for you in a very elegant fashion. Here's a sample program that grabs the first page of Stack Overflow and parses out all t... | 7 | 2008-10-02T06:52:06Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 161,372 | <p>If your problem has anything at all to do with web scraping, I recommend looking at <a href="http://search.cpan.org/perldoc?Web::Scraper" rel="nofollow">Web::Scraper</a> , which provides easy element selection via XPath respectively CSS selectors. I have a (German) <a href="http://datenzoo.de/pub/gpw2008/web-scraper... | 2 | 2008-10-02T08:37:58Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 161,977 | <p>Also check out <a href="http://search.cpan.org/dist/pQuery/" rel="nofollow">pQuery</a> it as a really nice Perlish way of doing this kind of stuff....</p>
<pre><code>use pQuery;
pQuery( 'http://www.perl.com' )->find( 'a' )->each(
sub {
my $pQ = pQuery( $_ );
say $pQ->text, ' -> ',... | 1 | 2008-10-02T12:19:37Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 162,301 | <p>From <a href="http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators" rel="nofollow">perlop</a>:</p>
<blockquote>
<p>A useful idiom for lex -like scanners
is <code>/\G.../gc</code> . You can combine
several regexps like this to process a
string part-by-part, doing different
actions depending on ... | 1 | 2008-10-02T13:36:36Z | [
"python",
"perl",
"parsing",
"lex"
] |
Emulation of lex like functionality in Perl or Python | 160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | 4 | 2008-10-02T04:34:06Z | 172,371 | <p>Modifying Bruno's example to include error checking:</p>
<pre><code>my $input = "...";
while (1) {
if ($input =~ /\G(\w+)/gc) { print "word: '$1'\n"; next }
if ($input =~ /\G(\s+)/gc) { print "whitespace: '$1'\n"; next }
if ($input !~ /\G\z/gc) { print "tokenizing error at character " . pos($input) . ... | 0 | 2008-10-05T18:07:23Z | [
"python",
"perl",
"parsing",
"lex"
] |
Django admin site not displaying ManyToManyField relationship | 160,905 | <p>I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.</p>
<p>Here's my models.py:</p>
<pre><code>class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max... | 3 | 2008-10-02T04:43:28Z | 160,916 | <blockquote>
<p>I've tried adding the TechInline class to the inlines list, but that causes a</p>
<p>'TechInLine' not defined</p>
</blockquote>
<p>Is that a straight copy-paste? It looks like you just made a typo -- try <code>TechInline</code> instead of <code>TechInLine</code>.</p>
<p>If your syncdb didn't cr... | 2 | 2008-10-02T04:48:29Z | [
"python",
"django"
] |
Django admin site not displaying ManyToManyField relationship | 160,905 | <p>I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.</p>
<p>Here's my models.py:</p>
<pre><code>class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max... | 3 | 2008-10-02T04:43:28Z | 161,500 | <p>Assuming your app is called "projects", the default name for your techs table will be projects_tech and the projects table will be projects_project.</p>
<p>The many-to-many table should be something like projects_project_techs</p>
| 0 | 2008-10-02T09:27:51Z | [
"python",
"django"
] |
Django admin site not displaying ManyToManyField relationship | 160,905 | <p>I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.</p>
<p>Here's my models.py:</p>
<pre><code>class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max... | 3 | 2008-10-02T04:43:28Z | 162,932 | <p>@<a href="#160916" rel="nofollow">John Millikin </a>- Thanks for the sqlreset tip, that put me on the right path. The sqlreset generated code that showed me that the <code>projects_project_techs</code> was never actually created. I ended up just deleting my deb.db database and regenerating it. <code>techs</code> the... | 0 | 2008-10-02T15:17:50Z | [
"python",
"django"
] |
Library for converting a traceback to its exception? | 161,367 | <p><br />
Just a curiosity: is there an already-coded way to convert a printed traceback back to the exception that generated it? :) Or to a sys.exc_info-like structure?</p>
| 0 | 2008-10-02T08:35:39Z | 161,546 | <p>Converting a traceback to the exception object wouldn't be too hard, given common exception classes (parse the last line for the exception class and the arguments given to it at instantiation.) The traceback object (the third argument returned by sys.exc_info()) is an entirely different matter, though. The traceback... | 2 | 2008-10-02T09:48:57Z | [
"python"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 161,858 | <p><code>os.walk</code> is your friend. Look at the example in the Python manual
(<a href="https://docs.python.org/2/library/os.html#os.walk" rel="nofollow">https://docs.python.org/2/library/os.html#os.walk</a>) and try to build something from that.</p>
<p>To match "<code>**/CVS/*</code>" against a file name you get,... | 2 | 2008-10-02T11:42:20Z | [
"python",
"file",
"ant"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 161,891 | <p>Yup. Your best bet is, as has already been suggested, to work with 'os.walk'. Or, write wrappers around '<a href="http://docs.python.org/library/glob.html" rel="nofollow">glob</a>' and '<a href="http://docs.python.org/library/fnmatch.html" rel="nofollow">fnmatch</a>' modules, perhaps.</p>
| 0 | 2008-10-02T11:54:28Z | [
"python",
"file",
"ant"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 162,716 | <p><a href="http://www.python.org/doc/2.6/library/os.html#os.walk" rel="nofollow">os.walk</a> is your best bet for this. I did the example below with .svn because I had that handy, and it worked great:</p>
<pre><code>import re
for (dirpath, dirnames, filenames) in os.walk("."):
if re.search(r'\.svn$', dirpath):
... | 0 | 2008-10-02T14:47:57Z | [
"python",
"file",
"ant"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 163,212 | <p>As soon as you come across a <code>**</code>, you're going to have to recurse through the whole directory structure, so I think at that point, the easiest method is to iterate through the directory with os.walk, construct a path, and then check if it matches the pattern. You can probably convert to a regex by somet... | 3 | 2008-10-02T16:07:32Z | [
"python",
"file",
"ant"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 4,525,760 | <p>There's an implementation in the 'waf' build system source code.
<a href="http://code.google.com/p/waf/source/browse/trunk/waflib/Node.py?r=10755#471" rel="nofollow">http://code.google.com/p/waf/source/browse/trunk/waflib/Node.py?r=10755#471</a>
May be this should be wrapped up in a library of its own?</p>
| 1 | 2010-12-24T10:34:20Z | [
"python",
"file",
"ant"
] |
How would you implement ant-style patternsets in python to select groups of files? | 161,755 | <p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>
<pre><code>**/CVS/* # All files immediately under a CVS directory.
mydir/mysubdir/** # All files recursively under mysubdir
</code></pre>
<p>More examples can be seen here:</p>
<p><a href="http:... | 3 | 2008-10-02T11:00:56Z | 10,597,029 | <p>Sorry, this is quite a long time after your OP. I have just released a Python package which does exactly this - it's called Formic and it's available at the <a href="http://pypi.python.org/pypi/formic" rel="nofollow">PyPI Cheeseshop</a>. With Formic, your problem is solved with:</p>
<pre><code>import formic
fileset... | 4 | 2012-05-15T08:39:01Z | [
"python",
"file",
"ant"
] |
Interface to versioned dictionary | 162,656 | <p>I have an versioned document store which I want to access through an dict like interface.
Common usage is to access the latest revision (get, set, del), but one should be able to access specific revisions too (keys are always str/unicode or int).</p>
<pre><code>from UserDict import DictMixin
class VDict(DictMixin):... | 1 | 2008-10-02T14:38:43Z | 162,707 | <p>Yes, provide a different API for getting different versions. Either a single methodcall for doing a retrieval of a particular item of a particular revision, or a methodcall for getting a 'view' of a particular revision, which you could then access like a normal dict, depending on whether such a 'view' would see much... | 4 | 2008-10-02T14:46:31Z | [
"python"
] |
Subclassing a class with private members | 162,798 | <p>One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:</p>
<pre><code>self.__value = 1
def value():
return self.__value
</code></pre>
<p>Is there a simple way of providing access to the private members of a class that I wish to s... | 1 | 2008-10-02T14:59:18Z | 162,854 | <p>Not conveniently, without further breaking encapsulation. The double-underscore attribute is name-mangled by prepending '_ClassName' for the class it is being accessed in. So, if you have a 'ContainerThing' class that has a '__value' attribute, the attribute is actually being stored as '<code>_ContainerThing__value<... | 5 | 2008-10-02T15:06:26Z | [
"python",
"oop",
"encapsulation"
] |
Subclassing a class with private members | 162,798 | <p>One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:</p>
<pre><code>self.__value = 1
def value():
return self.__value
</code></pre>
<p>Is there a simple way of providing access to the private members of a class that I wish to s... | 1 | 2008-10-02T14:59:18Z | 163,571 | <p>Not sure of where to cite it from, but the following statement in regard to access protection is Pythonic canon: "We're all consenting adults here".</p>
<p>Just as Thomas Wouters has stated, a single leading underscore is the idiomatic way of marking an attribute as being a part of the object's internal state. Two... | 2 | 2008-10-02T17:32:12Z | [
"python",
"oop",
"encapsulation"
] |
Subclassing a class with private members | 162,798 | <p>One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:</p>
<pre><code>self.__value = 1
def value():
return self.__value
</code></pre>
<p>Is there a simple way of providing access to the private members of a class that I wish to s... | 1 | 2008-10-02T14:59:18Z | 164,691 | <p>"I know this seems to go against the general idea of private and public" Not really "against", just different from C++ and Java.</p>
<p>Private -- as implemented in C++ and Java is not a very useful concept. It helps, sometimes, to isolate implementation details. But it is way overused.</p>
<p>Python names begi... | 2 | 2008-10-02T21:28:20Z | [
"python",
"oop",
"encapsulation"
] |
Django and Python 2.6 | 162,808 | <p>I'm just starting to get into Django, and of course as of last night one of the two new Python versions went final (2.6 obviously ;)) so I'm wondering if 2.6 plus Django is ready for actual use or do the Django team need more time to finish with tweaks/cleanup? </p>
<p>All the google searches I did were inconclusi... | 5 | 2008-10-02T15:00:00Z | 163,163 | <p>The impression I get is that 2.6 should work fine with Django 1.0. As found here: <a href="http://simonwillison.net/2008/Oct/2/whatus/" rel="nofollow">http://simonwillison.net/2008/Oct/2/whatus/</a> </p>
| 7 | 2008-10-02T15:58:41Z | [
"python",
"django"
] |
Django and Python 2.6 | 162,808 | <p>I'm just starting to get into Django, and of course as of last night one of the two new Python versions went final (2.6 obviously ;)) so I'm wondering if 2.6 plus Django is ready for actual use or do the Django team need more time to finish with tweaks/cleanup? </p>
<p>All the google searches I did were inconclusi... | 5 | 2008-10-02T15:00:00Z | 249,483 | <p>Note that there is currently no python-mysql adapter for python2.6. If you need MySQL, stick with 2.5 for now.</p>
| 5 | 2008-10-30T07:23:45Z | [
"python",
"django"
] |
Django and Python 2.6 | 162,808 | <p>I'm just starting to get into Django, and of course as of last night one of the two new Python versions went final (2.6 obviously ;)) so I'm wondering if 2.6 plus Django is ready for actual use or do the Django team need more time to finish with tweaks/cleanup? </p>
<p>All the google searches I did were inconclusi... | 5 | 2008-10-02T15:00:00Z | 1,054,960 | <p>There is an unofficial build for mysqldb 1.2.2 win32 python 2.6 @ <a href="http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe" rel="nofollow">http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe</a></p>
| 2 | 2009-06-28T13:45:33Z | [
"python",
"django"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,093 | <p>Do you mean <code>urllib2.urlopen</code>? There is no function called <code>openfile</code> in the <code>urllib2</code> module.</p>
<p>Anyway, use the <code>urllib2.urlparse</code> functions:</p>
<pre><code>>>> from urllib2 import urlparse
>>> print urlparse.urlsplit('http://example.com/somefile... | 2 | 2008-10-02T15:42:59Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,094 | <p>I think that "the file name" isn't a very well defined concept when it comes to http transfers. The server might (but is not required to) provide one as "content-disposition" header, you can try to get that with <code>remotefile.headers['Content-Disposition']</code>. If this fails, you probably have to parse the URI... | 6 | 2008-10-02T15:43:10Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,095 | <p>Did you mean <a href="http://www.python.org/doc/2.5.2/lib/module-urllib2.html#l2h-3928">urllib2.urlopen</a>?</p>
<p>You could potentially lift the <em>intended</em> filename <em>if</em> the server was sending a Content-Disposition header by checking <code>remotefile.info()['Content-Disposition']</code>, but as it i... | 37 | 2008-10-02T15:43:12Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,107 | <p>I guess it depends what you mean by parsing. There is no way to get the filename without parsing the URL, i.e. the remote server doesn't give you a filename. However, you don't have to do much yourself, there's the <code>urlparse</code> module:</p>
<pre><code>In [9]: urlparse.urlparse('http://example.com/somefile.z... | 1 | 2008-10-02T15:45:47Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,108 | <pre><code>import os,urllib2
resp = urllib2.urlopen('http://www.example.com/index.html')
my_url = resp.geturl()
os.path.split(my_url)[1]
# 'index.html'
</code></pre>
<p>This is not openfile, but maybe still helps :)</p>
| 0 | 2008-10-02T15:45:48Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,111 | <p>not that I know of.</p>
<p>but you can parse it easy enough like this:</p>
<p><code><pre>
<code>url = '<a href="http://example.com/somefile.zip" rel="nofollow">http://example.com/somefile.zip</a>'
</code>print url.split('/')[-1]
</pre></code></p>
| 1 | 2008-10-02T15:46:49Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 163,202 | <p>If you only want the file name itself, assuming that there's no query variables at the end like <a href="http://example.com/somedir/somefile.zip?foo=bar">http://example.com/somedir/somefile.zip?foo=bar</a> then you can use os.path.basename for this: </p>
<pre><code>[user@host]$ python
Python 2.5.1 (r251:54869, Apr ... | 10 | 2008-10-02T16:06:16Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 15,733,928 | <p>Using <code>urlsplit</code> is the safest option:</p>
<pre><code>url = 'http://example.com/somefile.zip'
urlparse.urlsplit(url).path.split('/')[-1]
</code></pre>
| 4 | 2013-03-31T20:05:36Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 22,053,032 | <p>using requests, but you can do it easy with urllib(2)</p>
<pre><code>import requests
from urllib import unquote
from urlparse import urlparse
sample = requests.get(url)
if sample.status_code == 200:
#has_key not work here, and this help avoid problem with names
if filename == False:
if 'content-... | 0 | 2014-02-26T20:54:44Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 29,173,617 | <p>Just saw this I normally do..</p>
<pre><code>filename = url.split("?")[0].split("/")[-1]
</code></pre>
| 3 | 2015-03-20T18:38:47Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 30,160,719 | <p>The <code>os.path.basename</code> function works not only for file paths, but also for urls, so you don't have to manually parse the URL yourself. Also, it's important to note that you should use <code>result.url</code> instead of the original url in order to follow redirect responses:</p>
<pre><code>import os
impo... | 2 | 2015-05-11T06:15:24Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 32,512,647 | <p>You probably can use simple regular expression here. Something like:</p>
<pre><code>In [26]: import re
In [27]: pat = re.compile('.+[\/\?#=]([\w-]+\.[\w-]+(?:\.[\w-]+)?$)')
In [28]: test_set
['http://www.google.com/a341.tar.gz',
'http://www.google.com/a341.gz',
'http://www.google.com/asdasd/aadssd.gz',
'http:/... | 0 | 2015-09-10T22:31:37Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 36,557,581 | <p>Using <a href="https://docs.python.org/3/library/pathlib.html#pathlib.PurePosixPath" rel="nofollow">PurePosixPath</a> which is not operating systemâdependent and handles urls gracefully is the pythonic solution:</p>
<pre><code>>>> from pathlib import PurePosixPath
>>> path = PurePosixPath('http:... | 0 | 2016-04-11T19:28:35Z | [
"python",
"url",
"urllib2"
] |
urllib2 file name | 163,009 | <p>If I open a file using urllib2, like so:</p>
<pre><code>remotefile = urllib2.urlopen('http://example.com/somefile.zip')
</code></pre>
<p>Is there an easy way to get the file name other then parsing the original URL?</p>
<p>EDIT: changed openfile to urlopen... not sure how that happened.</p>
<p>EDIT2: I ended up ... | 24 | 2008-10-02T15:27:04Z | 36,917,997 | <p>You could also combine both of the two best-rated answers :
Using urllib2.urlparse.urlsplit() to get the path part of the URL, and then os.path.basename for the actual file name.</p>
<p>Full code would be :</p>
<pre><code>>>> remotefile=urllib2.urlopen(url)
>>> try:
>>> filename=remote... | 0 | 2016-04-28T14:41:39Z | [
"python",
"url",
"urllib2"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 163,556 | <p>I figured out this workaround:</p>
<pre><code>>>> p = subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
>>> p.stdin.write('one\ntwo\nthree\nfour\nfive\nsix\n')
>>> p.communicate()[0]
'four\nfive\n'
>>> p.stdin.close()
</code></pre>
<p>Is there a better ... | 21 | 2008-10-02T17:27:55Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 163,870 | <p>"Apparently a cStringIO.StringIO object doesn't quack close enough to a file duck to suit subprocess.Popen"</p>
<p>:-)</p>
<p>I'm afraid not. The pipe is a low-level OS concept, so it absolutely requires a file object that is represented by an OS-level file descriptor. Your workaround is the right one.</p>
| 12 | 2008-10-02T18:33:23Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 165,662 | <p><a href="https://docs.python.org/3/library/subprocess.html?highlight=subprocess#subprocess.Popen.communicate"><code>Popen.communicate()</code></a> documentation:</p>
<blockquote>
<p>Note that if you want to send data to
the processâs stdin, you need to
create the Popen object with
stdin=PIPE. Similarly, t... | 194 | 2008-10-03T04:11:07Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 732,822 | <pre><code>p = Popen(['grep', 'f'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
p.stdin.write('one\n')
time.sleep(0.5)
p.stdin.write('two\n')
time.sleep(0.5)
p.stdin.write('three\n')
time.sleep(0.5)
testresult = p.communicate()[0]
time.sleep(0.5)
print(testresult)
</code></pre>
| 2 | 2009-04-09T04:39:40Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 10,134,899 | <pre><code>from subprocess import Popen, PIPE
from tempfile import SpooledTemporaryFile as tempfile
f = tempfile()
f.write('one\ntwo\nthree\nfour\nfive\nsix\n')
f.seek(0)
print Popen(['/bin/grep','f'],stdout=PIPE,stdin=f).stdout.read()
f.close()
</code></pre>
| 7 | 2012-04-13T03:36:37Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 17,109,481 | <pre><code>"""
Ex: Dialog (2-way) with a Popen()
"""
p = subprocess.Popen('Your Command Here',
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=PIPE,
shell=True,
bufsize=0)
p.stdin.write('START\n')
out = p.stdout.readline()
whi... | 4 | 2013-06-14T13:20:23Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 23,740,991 | <p>Beware that <code>Popen.communicate(input=s)</code>may give you trouble if<code>s</code>is too big, because apparently the parent process will buffer it <em>before</em> forking the child subprocess, meaning it needs "twice as much" used memory at that point (at least according to the "under the hood" explanation and... | 4 | 2014-05-19T14:56:38Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 24,982,453 | <p>I am using python3 and found out that you need to encode your string before you can pass it into stdin:</p>
<pre><code>p = Popen(['grep', 'f'], stdout=PIPE, stdin=PIPE, stderr=PIPE)
out, err = p.communicate(input='one\ntwo\nthree\nfour\nfive\nsix\n'.encode())
print(out)
</code></pre>
| 12 | 2014-07-27T15:29:17Z | [
"python",
"subprocess",
"stdin"
] |
Python - How do I pass a string into subprocess.Popen (using the stdin argument)? | 163,542 | <p>If I do the following:</p>
<pre><code>import subprocess
from cStringIO import StringIO
subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0]
</code></pre>
<p>I get:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line ... | 175 | 2008-10-02T17:25:23Z | 33,482,438 | <p>I'm a bit surprised nobody suggested creating a pipe, which is in my opinion the far simplest way to pass a string to stdin of a subprocess:</p>
<pre><code>read, write = os.pipe()
os.write(write, "stdin input here")
os.close(write)
subprocess.check_call(['your-command'], stdin=read)
</code></pre>
| 9 | 2015-11-02T16:34:03Z | [
"python",
"subprocess",
"stdin"
] |
Apache sockets not closing? | 163,603 | <p>I have a web application written using CherryPy, which is run locally on <code>127.0.0.1:4321</code>. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.</p>
<p>This all works just fine for ... | 4 | 2008-10-02T17:40:38Z | 164,293 | <p>You might run the netstat command and see if you have a bunch of sockets in the TIME_WAIT state. Depending on your MaxUserPort setting you might be severly limited in the number of ports available to use. In addition the TcpTimedWaitDelay is usually set to 240 seconds so any sockets that are used cannot be reused fo... | 5 | 2008-10-02T20:02:22Z | [
"python",
"apache",
"urllib2",
"cherrypy",
"mod-proxy"
] |
Apache sockets not closing? | 163,603 | <p>I have a web application written using CherryPy, which is run locally on <code>127.0.0.1:4321</code>. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.</p>
<p>This all works just fine for ... | 4 | 2008-10-02T17:40:38Z | 164,769 | <p><code>SetEnv proxy-nokeepalive 1</code> would probably tell you right away if the problem is keepalive between Apache and CP. See the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#envsettings">mod_proxy docs</a> for more info.</p>
| 5 | 2008-10-02T21:52:03Z | [
"python",
"apache",
"urllib2",
"cherrypy",
"mod-proxy"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 163,968 | <p>According to the documentation, you can only display the <code>__unicode__</code> representation of a ForeignKey:</p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display">http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display</a></p>
<p>Seems odd that it doesn't support t... | 19 | 2008-10-02T18:53:23Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 164,631 | <p>As another option, you can do look ups like:</p>
<pre><code>class UserAdmin(admin.ModelAdmin):
list_display = (..., 'get_author')
def get_author(self, obj):
return obj.book.author
get_author.short_description = 'Author'
get_author.admin_order_field = 'book__author'
</code></pre>
| 240 | 2008-10-02T21:11:56Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 475,086 | <p>This one's already accepted, but if there are any other dummies out there (like me) that didn't immediately get it from the <a href="http://stackoverflow.com/a/164631/58668">presently accepted answer</a>, here's a bit more detail. </p>
<p>The model class referenced by the <code>ForeignKey</code> needs to have a <co... | 4 | 2009-01-23T23:40:30Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 496,453 | <p>You can show whatever you want in list display by using a callable. It would look like this:</p>
<pre>
def book_author(object):
return object.book.author
class PersonAdmin(admin.ModelAdmin):
list_display = [book_author,]</pre>
| 9 | 2009-01-30T17:41:43Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 679,791 | <p>AlexRobbins' answer worked for me, except that the first two lines need to be in the model (perhaps this was assumed?), and should reference self:</p>
<pre><code>def book_author(self):
return self.book.author
</code></pre>
<p>Then the admin part works nicely.</p>
| 0 | 2009-03-25T00:27:08Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 3,351,431 | <p>Like the rest, I went with callables too. But they have one downside: by default, you can't order on them. Fortunately, there is a solution for that:</p>
<pre><code>def author(self):
return self.book.author
author.admin_order_field = 'book__author'
</code></pre>
| 51 | 2010-07-28T09:13:55Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 14,677,451 | <p>I just posted a snippet that makes admin.ModelAdmin support '__' syntax:</p>
<p><a href="http://djangosnippets.org/snippets/2887/">http://djangosnippets.org/snippets/2887/</a></p>
<p>So you can do:</p>
<pre><code>class PersonAdmin(RelatedFieldAdmin):
list_display = ['book__author',]
</code></pre>
<p>This is ... | 9 | 2013-02-03T21:21:58Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 21,456,615 | <p>if you try it in Inline, you wont succeed unless:</p>
<p>in your inline:</p>
<pre><code>class AddInline(admin.TabularInline):
readonly_fields = ['localname',]
model = MyModel
fields = ('localname',)
</code></pre>
<p>in your model (MyModel):</p>
<pre><code>class MyModel(models.Model):
localization... | 2 | 2014-01-30T12:30:33Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 23,747,842 | <p>Despite all the great answers above and due to me being new to Django, I was still stuck. Here's my explanation from a very newbie perspective.</p>
<p><strong>models.py</strong></p>
<pre><code>class Author(models.Model):
name = models.CharField(max_length=255)
class Book(models.Model):
author = models.Fo... | 52 | 2014-05-19T21:55:14Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 28,190,954 | <p>Please note that adding the <code>get_author</code> function would slow the list_display in the admin, because showing each person would make a SQL query.</p>
<p>To avoid this, you need to modify <code>get_queryset</code> method in PersonAdmin, for example:</p>
<pre><code>def get_queryset(self, request):
retur... | 7 | 2015-01-28T11:20:40Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 34,735,225 | <p>If you have a lot of relation attribute fields to use in <code>list_display</code> and do not want create a function (and it's attributes) for each one, a dirt but simple solution would be override the <code>ModelAdmin</code> instace <code>__getattr__</code> method, creating the callables on the fly:</p>
<pre class... | 1 | 2016-01-12T03:42:30Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 37,497,913 | <p>There is a very easy to use package available in PyPI that handles exactly that: <a href="https://pypi.python.org/pypi/django-related-admin" rel="nofollow">django-related-admin</a>. You can also <a href="https://github.com/PetrDlouhy/django-related-admin" rel="nofollow">see the code in GitHub</a>.</p>
<p>Using this... | 3 | 2016-05-28T10:30:55Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? | 163,823 | <p>I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).</p>
<p>With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doin... | 150 | 2008-10-02T18:26:19Z | 39,642,294 | <p>I prefer this:</p>
<pre><code>class CoolAdmin(admin.ModelAdmin):
list_display = ('pk', 'submodel__field')
@staticmethod
def submodel__field(obj):
return obj.submodel.field
</code></pre>
| 0 | 2016-09-22T14:48:41Z | [
"python",
"django",
"django-admin",
"modeladmin"
] |
WPF Alternative for python | 163,881 | <p>Is there any alternative for WPF (windows presentation foundation) in python? </p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF">http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF</a> </p>
| 4 | 2008-10-02T18:35:16Z | 163,892 | <p>You might want to look at <a href="http://www.pygtk.org/" rel="nofollow">pygtk</a> and <a href="http://glade.gnome.org/" rel="nofollow">glade</a>. <a href="http://www.learningpython.com/2006/05/07/creating-a-gui-using-pygtk-and-glade/" rel="nofollow">Here</a> is a tutorial.</p>
<p>There is a long <a href="http://wi... | 3 | 2008-10-02T18:38:46Z | [
"python",
"user-interface"
] |
WPF Alternative for python | 163,881 | <p>Is there any alternative for WPF (windows presentation foundation) in python? </p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF">http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF</a> </p>
| 4 | 2008-10-02T18:35:16Z | 163,905 | <p>Here is a list of <a href="http://wiki.python.org/moin/GuiProgramming">Python GUI Toolkits</a>.</p>
<p>Also, you can <a href="http://stevegilham.blogspot.com/2007/07/hello-wpf-in-ironpython.html">use IronPython to work with WPF directly</a>. </p>
| 6 | 2008-10-02T18:41:08Z | [
"python",
"user-interface"
] |
WPF Alternative for python | 163,881 | <p>Is there any alternative for WPF (windows presentation foundation) in python? </p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF">http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF</a> </p>
| 4 | 2008-10-02T18:35:16Z | 163,911 | <p>Try <a href="http://www.ibm.com/developerworks/linux/library/l-qt/" rel="nofollow">PyQt</a> which binds python to QT graphics library. There are some other links at the end of that article:</p>
<ul>
<li>Anygui</li>
<li>PyGTK</li>
<li>FXPy</li>
<li>wxPython</li>
<li>win32ui </li>
</ul>
| 1 | 2008-10-02T18:42:38Z | [
"python",
"user-interface"
] |
WPF Alternative for python | 163,881 | <p>Is there any alternative for WPF (windows presentation foundation) in python? </p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF">http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF</a> </p>
| 4 | 2008-10-02T18:35:16Z | 163,935 | <p>If you are on Windows and you want to use WPF (as opposed to an alternative), you can use it with <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython" rel="nofollow">IronPython</a> - a .NET version of python.</p>
<p>Here's a quick example: <a href="http://stevegilham.blogspot.com/2007/07/hello-wp... | 1 | 2008-10-02T18:47:36Z | [
"python",
"user-interface"
] |
How do I deploy a Python desktop application? | 164,137 | <p>I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.</p>
<p>I have no knowledge of deploying "real-life" Python applications, though I have used <a href="http:... | 28 | 2008-10-02T19:31:51Z | 164,272 | <p>Wow, there are a lot of questions in there:</p>
<ul>
<li><p>It is possible to run the bytecode (.pyc) file directly from the Python interpreter, but I haven't seen any bytecode obfuscation tools available.</p></li>
<li><p>I'm not aware of any "all in one" deployment solution, but:</p>
<ul>
<li><p>For Windows you c... | 2 | 2008-10-02T19:56:36Z | [
"python",
"deployment"
] |
How do I deploy a Python desktop application? | 164,137 | <p>I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.</p>
<p>I have no knowledge of deploying "real-life" Python applications, though I have used <a href="http:... | 28 | 2008-10-02T19:31:51Z | 164,291 | <p>You can distribute the compiled Python bytecode (.pyc files) instead of the source. You can't prevent decompilation in Python (or any other language, really). You could use an obfuscator like <a href="http://www.lysator.liu.se/~astrand/projects/pyobfuscate/" rel="nofollow">pyobfuscate</a> to make it more annoying fo... | 12 | 2008-10-02T20:02:01Z | [
"python",
"deployment"
] |
How do I deploy a Python desktop application? | 164,137 | <p>I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.</p>
<p>I have no knowledge of deploying "real-life" Python applications, though I have used <a href="http:... | 28 | 2008-10-02T19:31:51Z | 166,332 | <p>Maybe IronPython can provide something for you? I bet those .exe/.dll-files can be pretty locked down. Not sure how such features work on mono, thus no idea how this works on Linux/OS X...</p>
| 1 | 2008-10-03T10:57:05Z | [
"python",
"deployment"
] |
How do I deploy a Python desktop application? | 164,137 | <p>I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.</p>
<p>I have no knowledge of deploying "real-life" Python applications, though I have used <a href="http:... | 28 | 2008-10-02T19:31:51Z | 464,932 | <p>I have been using py2exe with good success on Windows. The code needs to be modified a bit so that the code analysis picks up all modules needed, but apart from that, it works.</p>
<p>As for Linux, there are several important distribution formats:</p>
<ul>
<li>DEB (Debian, Ubuntu and other derivatives)</li>
<li>RP... | 0 | 2009-01-21T11:37:20Z | [
"python",
"deployment"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 164,507 | <p>Rather than changing the template directories dynamically you could modify the request and add a value that lets your view know if the user is on an iphone or not. Then wrap render_to_response (or whatever you are using for creating HttpResponse objects) to grab the iphone version of the template instead of the stan... | 18 | 2008-10-02T20:44:38Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 164,616 | <p>How about redirecting user to i.xxx.com after parsing his UA in some middleware? I highly doubt that mobile users care how url look like, still they can access your site using main url.</p>
| 1 | 2008-10-02T21:08:31Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 189,367 | <p>You should take a look at the <a href="http://code.google.com/p/django-mobileadmin/" rel="nofollow">django-mobileadmin</a> source code, which solved exactly this problem.</p>
| 2 | 2008-10-09T22:00:13Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 207,954 | <p>Other way would be creating your own template loader that loads templates specific to user agent. This is pretty generic technique and can be use to dynamically determine what template has to be loaded depending on other factors too, like requested language (good companion to existing Django i18n machinery).</p>
<p... | 2 | 2008-10-16T09:41:23Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 216,377 | <p>I'm developing djangobile, a django mobile extension: <a href="http://code.google.com/p/djangobile/" rel="nofollow">http://code.google.com/p/djangobile/</a></p>
| 3 | 2008-10-19T12:46:33Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 299,780 | <p>There is a nice article which explains how to render the same data by different templates
<a href="http://www.postneo.com/2006/07/26/acknowledging-the-mobile-web-with-django" rel="nofollow">http://www.postneo.com/2006/07/26/acknowledging-the-mobile-web-with-django</a></p>
<p>You still need to automatically redirect... | 2 | 2008-11-18T19:06:33Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 433,216 | <p>This article might be useful: <a href="http://mobiforge.com/developing/story/build-a-mobile-and-desktop-friendly-application-django-15-minutes-or-less" rel="nofollow">Build a Mobile and Desktop-Friendly Application in Django in 15 Minutes</a></p>
| 4 | 2009-01-11T17:04:52Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 3,487,254 | <p>Detect the user agent in middleware, switch the url bindings, profit!</p>
<p>How? Django request objects have a .urlconf attribute, which can be set by middleware.</p>
<p>From django docs:</p>
<blockquote>
<p>Django determines the root URLconf
module to use. Ordinarily, this is the
value of the ROOT_URLCON... | 9 | 2010-08-15T11:57:53Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 4,152,279 | <p>best possible scenario: use minidetector to add the extra info to the request, then use django's built in request context to pass it to your templates like so</p>
<pre><code>from django.shortcuts import render_to_response
from django.template import RequestContext
def my_view_on_mobile_and_desktop(request)
...... | 1 | 2010-11-11T07:43:09Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Change Django Templates Based on User-Agent | 164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middlewa... | 38 | 2008-10-02T20:30:09Z | 14,510,830 | <p>A simple solution is to create a wrapper around <code>django.shortcuts.render</code>. I put mine in a <code>utils</code> library in the root of my application. The wrapper works by automatically rendering templates in either a "mobile" or "desktop" folder.</p>
<p>In <code>utils.shortcuts</code>:</p>
<blockquote>
<... | 0 | 2013-01-24T21:09:45Z | [
"python",
"django",
"django-templates",
"mobile-website",
"django-middleware"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 164,681 | <p>I've actually done this a long time ago, but it wasn't petty. What we did is use the <a href="http://sawfish.wikia.com/wiki/Main_Page" rel="nofollow">Sawfish window manager</a> and wrote a hook to recognize the flashplayer window, then strip all the decorations and snap it full screen.</p>
<p>This may be possible ... | 1 | 2008-10-02T21:26:19Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 165,089 | <p>You can use a dedicated application which sends the keystroke to the window manager, which should then pass it to flash, if the window starts as being the active window on the screen. This is quite error prone, though, due to delays between starting flash and when the window will show up.</p>
<p>For example, your s... | 7 | 2008-10-02T23:44:15Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 277,865 | <pre><code>nspluginplayer --fullscreen src=path/to/flashfile.swf
</code></pre>
<p>which is from the http://gwenole.beauchesne.info//en/projects/nspluginwrapper</p>
| 1 | 2008-11-10T13:40:49Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 2,276,508 | <p>I've done this using openbox using a similar mechanism to the one that bmdhacks mentions. The thing that I did note from this was that the standalone flash player performed considerably worse fullscreen than the same player in a maximised undecorated window. (that, annoyingly is not properly fullscreen because of... | 0 | 2010-02-16T21:31:19Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 3,994,891 | <p>You have to use Acton script 3 cmd:</p>
<pre><code>stage.displayState = StageDisplayState.FULL_SCREEN;
</code></pre>
<p>See Adobe Action script 3 programming.</p>
<p>But be careful : in full screen, you will lose display performances!</p>
<p>I've got this problem ... more under Linux!!!</p>
| 0 | 2010-10-22T07:57:47Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
Programmatically launching standalone Adobe flashplayer on Linux/X11 | 164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full ... | 7 | 2008-10-02T20:36:02Z | 10,877,411 | <blockquote>
<p>Another option would be to write a pygtk application that embedded the standalone flash player inside a gtk.Socket and then resized itself. After a bit of thought, this might be your best bet.</p>
</blockquote>
<p>This is exactly what I did. In addition to that, my player scales flash content via Xco... | 1 | 2012-06-04T06:56:19Z | [
"python",
"linux",
"adobe",
"x11",
"flash-player"
] |
How would I package and sell a Django app? | 164,901 | <p>Currently I am hosting a Django app I developed myself for my clients, but I am now starting to look at selling it to people for them to host themselves.</p>
<p>My question is this: How can I package up and sell a Django app, while protecting its code from pirating or theft? Distributing a bunch of .py files doesn'... | 30 | 2008-10-02T22:27:56Z | 164,920 | <p>The way I'd go about it is this:</p>
<ol>
<li>Encrypt all of the code</li>
<li>Write an installer that contacts the server with the machine's hostname and license file and gets the decryption key, then decrypts the code and compiles it to python bytecode</li>
<li>Add (in the installer) a module that checks the mach... | 11 | 2008-10-02T22:40:24Z | [
"python",
"django",
"distribution",
"piracy-prevention"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.