Re: problems running subprocess inside django view

2012-01-28 Thread Brian Schott
As the same user? Are you running with manage.py runserver? Generally it is a 
bad idea to call subprocess from a web process context. A blocking call you 
don't expect might time out the client and/or hang your server.  

Check out Django-celery.  Create a tasks.py and have your view call a task.

Sent from my iPhone

On Jan 28, 2012, at 6:41 AM, Eugene Gavrish  wrote:

> You are not alone with this problem. But I haven't got any decision.
> Maybe its django-specific with Popen??
> 
> I divided my task in two part: first cron-driven disk file generation.
> Second - from django-view this file parsing.
> It satisfied my goals, but question with Popen is still opened...
> 
> 
> On 27 янв, 20:05, Mark Lancaster  wrote:
>> I'm having problems running subprocess inside a django view using:
>> 
>> result = subprocess.Popen([ , ],
>> stdout=subprocess.PIPE).communicate()[0]
>> 
>> exactly the same method works perfectly inside a regular python
>> script.
>> 
>> Should I be using a different method to initiate a script?
>> 
>> Thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Apps vs Project

2012-01-28 Thread Brian Schott
This was hard for me when I started with Django about a year ago and I'm still 
learning, but I've found that I prefer to break things down into multiple small 
apps so that the models.py, admin.py, views.py, tests.py, etc. all are fairly 
small and easy to understand within a single app.  The project settings.py can 
then just import them each as you would another external app.  

See my comments in the thread for the layout and a few tricks that I use:
https://groups.google.com/forum/#!topic/django-users/gNvhuTADOiA

Foreign keys work across app boundaries, you just need to have the apps on your 
python path and do:

from django.db import models
from crm_customer.models import Customer

class PurchaseOrder(models.Model):
   customer = models.ForeignKey(Customer)
   ...

Also, setting the app_label, you can make all the little applets appear in the 
same grouping on the admin page and essentially share a namespace for metadata 
like django-guardian permissions.  

class Meta:
app_label = 'crm'


Brian Schott
bfsch...@gmail.com



On Jan 12, 2012, at 10:31 AM, Grant Copley wrote:

> Hey guys,
> 
> I'm a 12 year ColdFusion guy learning Django and Python and had a
> quick question. If this is the wrong place to post this question, I
> apologize.
> 
> I'm interested in converting a Customer relationship management (CRM)
> system currently written in ColdFusion over to Python using Django,
> however the concept of separate apps in a single Django project is
> confusing to me. My CRM system currently manages customers, orders,
> purchase orders, etc... and all of these separate pieces are related.
> For example,
> 
> * A customer has many orders
> * A order can result in a purchase order being created
> * etc
> 
> My question is, if each piece (customers, orders, ...) ties together,
> should all of this functionality be placed in a Django project with a
> single app, or is it typical to break each piece into into a separate
> app? If you separate them into different apps (an app for customers,
> an app for orders)... then I'm confused how they tie together,
> especially on the model layer.
> 
> Thanks,
> 
> Grant
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: Unable to open database file

2012-03-02 Thread Brian Schott
Is the WSGI server running as www-data user, perhaps?  Check the permissions on 
the file with "ls -l".   Simple check would be "chmod a+rw "  to 
guarantee that it is writable by www-data.  

Brian Schott
bfsch...@gmail.com



On Feb 18, 2012, at 4:24 PM, j...@jsdey.com wrote:

> I'm another newbe and need you patient consideration.
> 
> I've worked my way through the polls tutorial.  Thinks seem to be
> working with django server.  When I use Django/Wsgi I vote from an
> external site but django is unable to open database from the line
> selected_choice.save().  The error message from debug is listed
> below.  Any guidance would be greatly appeciated. Thanks.
> 
> John
> 
> DatabaseError at /polls/1/vote/
> 
> unable to open database file
> 
> Request Method:   POST
> Request URL:  http://jsdey.com/polls/1/vote/
> Django Version:   1.3.1
> Exception Type:   DatabaseError
> Exception Value:
> 
> unable to open database file
> 
> Exception Location:   /usr/local/lib/python2.7/dist-packages/django/db/
> backends/sqlite3/base.py in execute, line 234
> Python Executable:/usr/bin/python
> Python Version:   2.7.1
> Python Path:
> 
> ['/usr/lib/python2.7',
> '/usr/lib/python2.7/plat-linux2',
> '/usr/lib/python2.7/lib-tk',
> '/usr/lib/python2.7/lib-old',
> '/usr/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages/gtk-2.0',
> '/usr/lib/pymodules/python2.7',
> '/home/robo5/Django',
> '/home/robo5/Django/mysite']
> 
> Server time:  Sat, 18 Feb 2012 15:15:47 -0600
> Traceback Switch to copy-and-paste view
> 
>/usr/local/lib/python2.7/dist-packages/django/core/handlers/
> base.py in get_response
> 
>response = callback(request,
> *callback_args, **callback_kwargs)
> 
>...
>▶ Local vars
>/home/robo5/Django/mysite/polls/views.py in vote
> 
>selected_choice.save()
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/base.py in
> save
> 
>self.save_base(using=using, force_insert=force_insert,
> force_update=force_update)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/base.py in
> save_base
> 
>rows =
> manager.using(using).filter(pk=pk_val)._update(values)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/query.py
> in _update
> 
>return query.get_compiler(self.db).execute_sql(None)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
> compiler.py in execute_sql
> 
>cursor = super(SQLUpdateCompiler,
> self).execute_sql(result_type)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
> compiler.py in execute_sql
> 
>cursor.execute(sql, params)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py
> in execute
> 
>return self.cursor.execute(sql, params)
> 
>...
>▶ Local vars
>/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/
> base.py in execute
> 
>return Database.Cursor.execute(self, query,
> params)
> 
>...
>▶ Local vars
> 
> Request information
> GET
> 
> No GET data
> POST
> Variable  Value
> csrfmiddlewaretoken
> 
> u'de79b7a128450683be3814aad7a1af65'
> 
> choice
> 
> u'1'
> 
> FILES
> 
> No FILES data
> COOKIES
> Variable  Value
> csrftoken
> 
> 'de79b7a128450683be3814aad7a1af65'
> 
> __utma
> 
> '164886436.1396980123.1309309134.1325027492.1325041095.10'
> 
> __utmz
> 
> '164886436.1309309134.1.1.utmcsr=(direct)|utmccn=(direct)|
> utmcmd=(none)'
> 
> META
> Variable  Value
> mod_wsgi.listener_port
> 
> '80'
> 
> HTTP_COOKIE
> 
> '__utma=164886436.1396980123.1309309134.1325027492.1325041095.10;
> __utmz=164886436.1309309134.1.1.utmcsr=(direct)|utmccn=(direct)|
> utmcmd=(none); csrftoken=de79b7a128450683be3814aad7a1af65'
> 
> mod_wsgi.listener_host
> 
> ''
> 
> SERVER_SOFTWARE
> 
> 'Apache/2.2.17 (Ubuntu)'
> 
> SCRIPT_NAME
> 
> u''
> 
> m

Re: Hardware requirements for Djando development (Linux vs Mac)

2012-04-20 Thread Brian Schott
Any Intel mac mini should be fine.  I do all of my development on a MacBook Pro 
laptop.  Most of the potential Linux dependencies that aren't available from 
PyPi (RabbitMQ, MYSQL, ...) can be installed using Homebrew:
http://mxcl.github.com/homebrew/

Brian Schott
bfsch...@gmail.com



On Apr 20, 2012, at 8:58 AM, Houmie wrote:

> Hi,
> 
> This might sound like a strange question.  I am switching from
> MVC .NET to Django/Linux environment. It makes most sense to go
> completely linux (Ubuntu). But there is also the option of leaving PC
> completely behind and start using a Mac for development.
> 
> As I am not familiar with Mac, is it true that a let say a Mac Mini is
> powerful enough to run Python, Eclipse/PyDev and Django like its done
> in Ubuntu without any problem?
> 
> Many Thanks,
> Houman
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: guardian: I get ImproperlyConfigured error, but I have set ANONYMOUS_USER_ID in projectName/projectName/settings.py

2012-04-22 Thread Brian Schott
This should work:

# django-guardian requires an anonymous user
ANONYMOUS_USER_ID = -1

Also, I think you need to "python manage.py syncdb" the first time you use it.

Brian Schott
bfsch...@gmail.com



On Apr 22, 2012, at 11:41 PM, su wrote:

> I set  ANONYMOUS_USER_ID  in my project setting.
> It doesn't work.
> 
> 
> Error message:
> ---
> 
> 
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 443, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 252, in fetch_command
> app_name = get_commands()[subcommand]
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 101, in get_commands
> apps = settings.INSTALLED_APPS
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", 
> line 184, in inner
> self._setup()
>   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 
> 42, in _setup
> self._wrapped = Settings(settings_module)
>   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 
> 93, in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
> line 35, in import_module
> __import__(name)
>   File "/home/su/document/django/simpleSNS/simpleSNS/settings.py", line 8, in 
> 
> from userena.models import UserenaBaseProfile
>   File "/usr/local/lib/python2.7/dist-packages/userena/models.py", line 12, 
> in 
> from userena.managers import UserenaManager, UserenaBaseProfileManager
>   File "/usr/local/lib/python2.7/dist-packages/userena/managers.py", line 11, 
> in 
> from guardian.shortcuts import assign, get_perms
>   File "/usr/local/lib/python2.7/dist-packages/guardian/shortcuts.py", line 
> 9, in 
> from guardian.core import ObjectPermissionChecker
>   File "/usr/local/lib/python2.7/dist-packages/guardian/core.py", line 7, in 
> 
> from guardian.utils import get_identity
>   File "/usr/local/lib/python2.7/dist-packages/guardian/utils.py", line 11, 
> in 
> from guardian.conf.settings import ANONYMOUS_USER_ID
>   File "/usr/local/lib/python2.7/dist-packages/guardian/conf/settings.py", 
> line 6, in 
> raise ImproperlyConfigured("In order to use django-guardian's "
> django.core.exceptions.ImproperlyConfigured: In order to use 
> django-guardian's ObjectPermissionBackend authorization backend you have to 
> configure ANONYMOUS_USER_ID at your settings module
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/BY1w2ckqa34J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


Re: Django + boto support

2012-04-26 Thread Brian Schott
It works very well.  You'll want to do the boto calls from something like 
celery tasks in the background.

Brian Schott
bfsch...@gmail.com



On Apr 26, 2012, at 1:27 PM, Nikolas Stevenson-Molnar wrote:

> The S3 part at least integrates well. It's used by the django-storages 
> project: http://code.larlet.fr/django-storages/. Other then that, I don't see 
> why the other parts wouldn't work as well. If your performing tasks that take 
> a while, you'll probably want to handle them in the background rather than as 
> part of a view.
> 
> _Nik
> 
> On 4/26/2012 10:01 AM, Eduardo B wrote:
>> 
>> Hi,
>> 
>> I am planning to develop a systems management tool for Ubuntu platform. 
>> Mitch Garnaat released a Python API that supports connecting to various 
>> Amazon Web Services. I would like to know if boto integrates very well with 
>> Django. 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/J0qKOuaxMqkJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


Re: Is there are some id obfuscate libs in django?

2012-05-27 Thread Brian Schott
Keep in mind that obfuscation isn't security, so the answer really depend on 
your goal.  Are you concerned about auto-incrementing integer IDs being 
sequential in REST urls?  If so, use named slugs or UUIDs from 
django-extensions.  UUIDs aren't obfuscated from a security perspective (they 
can be deduced), but sufficient for most purposes to make sequencing not 
obvious.  You can also use the M2Crypto library to generate a random token and 
use that to add a home-grown access key.  The snippet below isn't complete, but 
hopefully gives you an idea.

 models.py --

import M2Crypto
from django_extensions.db import fields as extensions

class Foo(models.Model):

uuid = extensions.UUIDField(
editable=False,
help_text="Automatically generated globally unique ID.")

token = models.CharField(
help_text="Automatically generated authorization token",
max_length=255,
editable=False, default=None, blank=True, null=True)

def save(self, *args, **kwargs):
""" set the authorization token on first save """
if not self.id:
self.token = base64.urlsafe_b64encode(
M2Crypto.m2.rand_bytes(16))
super(Foo, self).save(*args, **kwargs)

-- views.py --

from django.views.generic import DetailView

class FooTokenView(DetailView):

def get_object(self):
object = get_object_or_404(Foo,
   uuid=self.kwargs['uuid'],
       token=self.kwargs['token'])
return object

---


Brian Schott
bfsch...@gmail.com



On May 27, 2012, at 11:14 AM, Marcin Tustin wrote:

> Why would you want this? Arbitrary integers are already completely opaque.
> 
> On Sun, May 27, 2012 at 4:12 PM, forrest yang  wrote:
> Just try to convert the increasing numeric id in the database to some other 
> obfuscated id. 
> The lib need to support long type integer range conversion and convert in two 
> directions.
> Is there are some id obfuscate libs in django or widely used in django 
> community?
> 
> Any one knows that?
> 
> Thanks
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/0lkBciSL24MJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> Marcin Tustin
> Tel: 07773 787 105
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


Re: Looking for common practice suggestion.

2012-07-03 Thread Brian Schott
An intermediate approach would be to generate an initial_data.json/yaml file 
and place it in your project's fixtures directory.  This at least should be 
database independent.
https://docs.djangoproject.com/en/dev/howto/initial-data/

Brian Schott
bfsch...@gmail.com



On Jul 3, 2012, at 1:33 PM, Robert Steckroth wrote:

> Hey Gang, I am writing a framework to install django projects to the cloud. 
> Currently I have the user specifying
> the site domain and site name in a config file for the django.sites framework 
> and providing the site_id in settings.py.
> Personally, I change the django.sites entries by issuing mysql commands to 
> the database.
> Can any of you provide the most common/best way that the django.sites object 
> is created?
> Is it usually provided in the settings.py file? Or is a database change your 
> current method?
> The docs don't seem to get into how this object get created. Also, is this 
> object created with the syncdb command?
> Much thanks to any help.
> 
> -- 
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: complicated permissions

2012-09-10 Thread Brian Schott
If you are looking for a pre-canned solution, look at django-guardian.  It 
implements object-level permission for users and groups.  You just create 
arbitrary permissions in the meta class of your models and can test them in 
your templates and/or views.  It has admin view support, template tags, and 
recently mixin wrappers for class-based views.  

https://github.com/lukaszb/django-guardian

Brian


Brian Schott
bfsch...@gmail.com



On Sep 9, 2012, at 10:55 PM, jondykeman  wrote:

> Hi Everyone, 
> 
> I was hoping to get some input on how other people deal with complicated 
> permission situations. I have banged my head against these concepts I think I 
> need some fresh eyes. 
> 
> - User accounts can create and manage their own content.
> - Users that are part of the same company can view the content created by 
> Users at the company; however, they can only edit if given permission.
> - Users from different companies can share their content as either read or 
> read/write with Users at other companies.
> 
> Things I have thought about are:
> 
> - Of course using object level permissions
> - Maybe using many-to-many to assign all of the different layers groupings a 
> record would fall under.
> - How to allow sharing of content outside the company - should they be able 
> to send an invite based on e-mail to share the content? as a lookup of 
> everyone in the system wouldn't be appropriate.
> - How to control the read vs. write views
> 
> Any kind of help would be greatly appreciated. I have struggled to wrap my 
> head around the "right" way for a long time.
> 
> JD
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/uVfk-78yaFEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



sekizai and django-registration tests failing

2011-09-27 Thread Brian Schott
 
'mptt', 

 
'menus',

 
'south',

 
'publisher',

 
'sekizai',  

 
'cms.plugins.file', 

 
'cms.plugins.googlemap',

 
'cms.plugins.picture',  

 
'cms.plugins.link', 

 
'cms.plugins.flash',

 
'cms.plugins.snippet',  

 
'cms.plugins.inherit',  

 
'cms.plugins.text', 

 
'cmsplugin_advancednews',   

 
# useful 3rd party apps 

 
'compressor',   

 
'easy_thumbnails',  

 
'filer',

 
# your own apps 
        
 
'nimbis_cloud', 

 
)   

 



Brian Schott
bfsch...@gmail.com





smime.p7s
Description: S/MIME cryptographic signature


Re: Ajax replacement in django

2011-10-12 Thread Brian Schott
This is a bit old-school, but you could do this by using meta-refresh on a 
frame.  I think that should still work in most browsers.  
http://en.wikipedia.org/wiki/Meta_refresh

Basically, you can place an iframe inside your base.html template that includes 
an  link to your dynamic content.   
http://www.w3schools.com/tags/tag_iframe.asp

Create a iframe_base.html template file that has the meta refresh tag included 
in  section and just the iframe parts should refresh.  

Not sure if this is what you want, and not sure this is a good idea, but it 
doesn't require javascript.

Brian Schott
bfsch...@gmail.com



On Oct 12, 2011, at 11:06 AM, Phang Mulianto wrote:

> but for the web html standart you need ajax.
> 
> maybe you can use some javascript framework like prototype+scripatoulus or 
> jquery to simply work with ajax and browser compatibility issue.
> 
> On Oct 12, 2011 10:55 PM, "Donald Stufft"  wrote:
> I don't think there's any reason to insult anyone, let's be civil.
> On Wednesday, October 12, 2011 at 10:50 AM, Chandrakant Kumar wrote:
> 
>> 
>> You are another 'garbage' product of our country's shitty education system.
>> 
>> On 10/12/2011 08:09 PM, lankesh87 wrote:
>>> Actually my project guide is asking me to search for ajax replacement
>>> in django. So that way we dont have to use ajax.
>>> 
>>> I mean if we could only refrsh particular part in our web page without
>>> refreshing the whole page "using django".
>>> 
>>> Thanx in advance and pardone me for my foolish questions as i am new
>>> to django and web but i do have some basic knowledge on
>>> how html functions.
>>> 
>>> On Oct 12, 7:24 pm, Javier Guerra Giraldez wrote:
>>>> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 wrote:
>>>>> I am developing a web application where i need ajax like features.
>>>>> But I don't want to use ajax, so my question is- "is there any way to
>>>>> perform ajax like functions in django?"
>>>> that kind of specifications (ajax-like but no ajax) sound very weird
>>>> to me. I find only two explanations:
>>>> 
>>>> A) you don't know how HTTP works
>>>> 
>>>> or
>>>> 
>>>> B) when you say 'ajax' you're in fact talking about a specific library
>>>> that you don't want to use and not the generic javascript-driven
>>>> requests.
>>>> 
>>>> if A, then please do learn about HTTP first. then you'll not only
>>>> realize what you really need, but will also be in position to make
>>>> your applications like you want.
>>>> 
>>>> if B, then please tell us what is it that you don't want.
>>>> 
>>>> --
>>>> Javier
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


Re: Which Linux distro to use on EC2?

2011-11-14 Thread Brian Schott
Ubuntu has great cloud-init support for dealing with cloud startup scripts.  
Works on most clouds:  openstack, ec2, eucalyptus...

Sent from my iPhone

On Nov 13, 2011, at 8:52 PM, ydjango  wrote:

> I was concerned that Ubuntu being a desktop OS might have some
> limitations which CENTOS or Debian being Server OS might not have.
> Based on answers so far, looks like all the distributions are quite
> close and my concern about ubuntu is unfounded. If it is all matter
> taste then I will go with Ubuntu.
> 
> thanks everyone.
> 
> 
> On Nov 13, 5:01 pm, Kurtis Mullins  wrote:
>> I don't have a recommendation on a specific distribution -- that's really a
>> matter of personal taste and experience. However, try to go with a
>> free-tier instance until you really need to upgrade. There are only certain
>> images that can be used with that free-tier. It's a pretty good deal! I've
>> used both Amazon's CentOS based Distribution and Ubuntu on it -- I prefer
>> Ubuntu, coming from a Debian backend. CentOS has quite a bit of a server
>> community as well, though.
>> 
>> On Sun, Nov 13, 2011 at 7:22 PM, Joey Espinosa 
>> wrote:
>> 
>>> No, Gentoo is not a variant of Debian.
>> 
>>> I also don't think there are variants that are for "hardcore" users more
>>> than others. If you're "hardcore", then you should be able to do things
>>> like write your own kernel modules and perform low-level disk operations no
>>> matter the distro.
>> 
>>> I personally love Ubuntu on EC2. The ami/ec2 tools are in the repository
>>> by default, and are updated regularly. If you use the official AMIs from
>>> Canonical, then you'll get a setup that is optimized for EC2 without you
>>> having to do anything extra (for instance, "byobu" runs automatically when
>>> you connect via SSH).
>> 
>>> In the end, it all really depends on you. As Casey mentioned, you are
>>> probably better off with what you're already familiar with. After all, what
>>> good is the "best" OS if you're more familiar with the "good enough" OS?
>>> You'll be more productive with what you are comfortable managing. I'm
>>> familiar with many distros (certified in Red Hat & Solaris, and long time
>>> Gentoo user), but I go with Ubuntu on EC2 every time.
>> 
>>> Hope this helped.
>> 
>>> --
>>> Joey "JoeLinux" Espinosa
>>> Software Developer
>>> http://about.me/joelinux
>>> On Nov 13, 2011 7:10 PM, "Casey Greene"  wrote:
>> 
 I would suggest that you use whatever your sysadmin (or if no sysadmin,
 developer (or if it's just you, you)) are most familiar with.  I assume the
 packages that you are using (at least the ones you've listed) will be in
 the package management systems for any of the distros that you have listed.
>> 
 I'm also pretty sure that gentoo is not a variant of debian.
>> 
 Casey
>> 
 On 11/13/2011 03:58 PM, Charles Cossé wrote:
>> 
> The main difference with Ubuntu is that it's a binary distribution
> (pre-compiled binaries for a standardized platform).  I use Gentoo,
> personally, which is a variant of Debian with "portage" rather than
> "apt".   LAMP server stuff is readily available on all distros of Linux.
>  If you're hardcore then use Gentoo.  If you're medium-core then use
> Debian.  If you're softcore then use Ubuntu.  If you like RedHat style
> more than Debian, then go CentOS.  Whichever you choose, you'll
> immediately need to familiarize yourself with it's package manager and
> how things are done on that platform.  good luck :-)
>> 
> On Sun, Nov 13, 2011 at 12:56 PM, ydjango  > wrote:
>> 
>I am setting up nginex, apache, python django, mysql based application
>on EC2. I expect high web traffic and high mysql query usage. Mysql
>and web server will on seperate servers.
>> 
>Which linux distro should I use for heavy production use - Ubuntu,
>Centos or Debian?
>> 
>Does it matter?
>> 
>I see most instructions on web is using Ubuntu and it seems it is
>considered easiest to set up. But I read somewhere that Ubuntu is not
>for server use. What is the downside if I chose ubuntu?
>> 
>--
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To post to this group, send email to django-users@googlegroups.com
>> .
>To unsubscribe from this group, send email to
>
> django-users+unsubscribe@**googlegroups.com
>
>  **>.
>For more options, visit this group at
>
> http://groups.google.com/**group/django-users?hl=en
> .
>> 
> --
> AsymptopiaSoftware|Software@**theLimit
> http://www.asymptopia.org
>> 
> --
> You received this message because you are subscribed to the Google

Re: Need to process uploaded files into database entries(takes hours), how do I return a progress bar?

2011-11-27 Thread Brian Schott
You really should look at django-celery and RabbitMQ.  The upload submit can 
initiate a task that is defined in tasks.py.  There are separate worker 
processes that pick up the task from the message queue and do the actual work.  
These workers don't even have to be on the same machine with rabbitMQ so you 
get instant scalability.   Then your AJAX job status view can poll a job status 
table that is updated by the task and you don't have to worry about threads.
https://github.com/ask/django-celery

Brian Schott
bfsch...@gmail.com



On Nov 27, 2011, at 8:54 PM, Nathan McCorkle wrote:

> I'm using Django 1.3 and am processing 3 files into genes, proteins,
> and genomes for a tool I built... this processing usually takes
> between 5 minutes to a few hours, depending on the genome size.
> 
> After uploading the files (10-100 MB), the upload view begins
> processing the files, without returning for a long time (causing my
> browser to ask me if I want to kill the plupload script).
> 
> For the user of this app, they don't know if their upload failed or is
> processing, etc... so I'd think forking the processing function (or
> making it a new thread) is what needs to happen, then the view can
> return to the user, and the upload page can start doing AJAX requests
> to check to processing progress.
> 
> I feel like I want to do this:
> http://www.artfulcode.net/articles/threading-django/
> but am scared of crashing because I've heard Django isn't threadsafe
> with transactions. (and my processing function is making DB
> transactions)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need to process uploaded files into database entries(takes hours), how do I return a progress bar?

2011-11-27 Thread Brian Schott
What are your settings?  Using carrot?  Kombu?  RabbitMQ?  

Does your task try to return a value?  

Sent from my iPhone

On Nov 27, 2011, at 11:22 PM, Nathan McCorkle  wrote:

> P.S. the printGene function works... printing the messages on the
> celeryd console terminal... the processXLS1 function doesn't even
> print anything at all
> 
> On Sun, Nov 27, 2011 at 11:21 PM, Nathan McCorkle  wrote:
>> Yeah I've seen the djcelery solution before... I've tried implementing
>> it, but I'm getting an error on the celeryd console:
>> TypeError: processXLS1() got an unexpected keyword argument 'task_is_eager'
>> 
>> when I try running processXLS1.delay(dataObjectID=someInteger) from a
>> function in views.py
>> 
>> here's what's in my tasks.py:
>> "
>> from celery.decorators import task
>> from enzymeFilter.models import *
>> from django.db import transaction
>> 
>> @task
>> def printGene(y):
>>print "ppp"
>>fil=open('/var/www/media/testFile','w')
>>fil.write('coming from background')
>>fil.close()
>> 
>>print Gene.objects.get(id=y+1)
>>return True
>> 
>> @task
>> @transaction.commit_manually
>> def processXLS1(datasetObjectID):
>>print "processing XLS as task"
>>datasetObject = Dataset.objects.get(id=datasetObjectID)
>>try:
>>... more processing code
>> "
>> 
>> thanks
>> -Nathan
>> 
>> On Sun, Nov 27, 2011 at 9:52 PM, Brian Schott  wrote:
>>> You really should look at django-celery and RabbitMQ.  The upload submit 
>>> can initiate a task that is defined in tasks.py.  There are separate worker 
>>> processes that pick up the task from the message queue and do the actual 
>>> work.  These workers don't even have to be on the same machine with 
>>> rabbitMQ so you get instant scalability.   Then your AJAX job status view 
>>> can poll a job status table that is updated by the task and you don't have 
>>> to worry about threads.
>>> https://github.com/ask/django-celery
>>> 
>>> Brian Schott
>>> bfsch...@gmail.com
>>> 
>>> 
>>> 
>>> On Nov 27, 2011, at 8:54 PM, Nathan McCorkle wrote:
>>> 
>>>> I'm using Django 1.3 and am processing 3 files into genes, proteins,
>>>> and genomes for a tool I built... this processing usually takes
>>>> between 5 minutes to a few hours, depending on the genome size.
>>>> 
>>>> After uploading the files (10-100 MB), the upload view begins
>>>> processing the files, without returning for a long time (causing my
>>>> browser to ask me if I want to kill the plupload script).
>>>> 
>>>> For the user of this app, they don't know if their upload failed or is
>>>> processing, etc... so I'd think forking the processing function (or
>>>> making it a new thread) is what needs to happen, then the view can
>>>> return to the user, and the upload page can start doing AJAX requests
>>>> to check to processing progress.
>>>> 
>>>> I feel like I want to do this:
>>>> http://www.artfulcode.net/articles/threading-django/
>>>> but am scared of crashing because I've heard Django isn't threadsafe
>>>> with transactions. (and my processing function is making DB
>>>> transactions)
>>>> 
>>>> --
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "Django users" group.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> To unsubscribe from this group, send email to 
>>>> django-users+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at 
>>>> http://groups.google.com/group/django-users?hl=en.
>>>> 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>> 
>>> 
>> 
>> 
>> 
>> --
>> Nathan McCorkle
>> Rochester Institute of Technology
>> College of Science, Biotechnology/Bioinformatics
>> 
> 
> 
> 
> -- 
> Nathan McCorkle
> Rochester Institute of Technology
> College of Science, Biotechnology/Bioinformatics
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Simple task dispatching (How heavy is celery + RabbitMQ)

2011-11-28 Thread Brian Schott
There are plenty of tutorials about memory management with RabbitMQ.  There are 
mechanisms for setting the high watermark for memory to throttle producers.   
You could look at the database backend for django-kombu.  It might have a 
smaller footprint.  django-ztask looks interesting, but you don't seem to get 
reliable message delivery, but maybe I misread the site.  

Brian Schott
bfsch...@gmail.com



On Nov 28, 2011, at 8:34 PM, Gelonida N wrote:

> On 11/28/2011 12:14 PM, Gelonida N wrote:
>> Hi,
>> 
>> I'd like to use a light weight dispatching system for a web server.
>> 
>> Basically some django post requests might require processing, which
>> should be done in the back ground due to its run times.
>> 
>> The results would be added to the django data base.
>> 
>> The browser could verify via AJAX requests whether the task is finished.
>> 
>> 
>> The server would be running on a rather weak virtual machine with rather
>> low memory (nginx / uwsgi / django )
>> 
>> ( For testing  I run the server on windows with one of the following
>> setups (depending on what I'd like to test)
>> - django runserver
>> - twisted - django
>> - cygwin/nginx - fastcgi - django
>> 
>> Most people seem to recommend celery with RabbitMQ.
>> If I understood well, rabbit MQ requires Erlang to be installed and I
>> found some posts indicating that RabbitMQ requires quite some memory
>> 
>> So I wondered whether celery / RabbitMq wouldn't be a little on the
>> heavy side and eat away a little too much from my meory.
>> 
>> 
>> Is there any good light weight dispatching alternative to celery or
>> would this be one of these  'roll your own dispatcher' tasks?
>> 
>> 
> Thanks a lot for all your answers.
> 
> 
> To summarize quickly
> RabbitMQ doe snot seem to be as greedy as I expected (probably around
> 19MB for my expected load)
> 
> Django-ztask is a small brokerless solution
> 
> Celery supports multiple brokers with difference performance. the dd
> broker would not require an additional process (apart from celery)
> 
> 
> uwsgi has a spooler which might be what I'm looking for I just would
> like to execute some tasks, which are too slow to be treated directly
> within an HTTP request  sequentially one after the other.
> 
> However if I used uwsgi I had to look for an alternative implementation
> and a small wrapper such, that the system would still be working on a
> windows host without uwsgi. (performance on windows is not crucial, but
> it should work)
> 
> Now I just need some time to test some of these options on  windows PC
> and on my tiny virtual linux host.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Newbie question on re-defining an XML schema in my Django data model...

2011-11-29 Thread Brian Schott
Marc,

There is a couple of ways to do this on top of the Django ORM.  You probably 
want to use a many-to-many relationship with an extra index field.
https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships


class SingularWorkFlow(models.Model):
name  = models.CharField(default=None, null=True)

def __unicode__(self):
return self.name

class CompositeWorkFlow(models.Model):
name  = models.CharField(default=None, null=True)
workflows = models.ManyToManyField(SingularWorkFlow, 
through='WorkFlowOrderedList')

def __unicode__(self):
return self.name

class WorkFlowOrderedList(models.Model):
composite = models.ForeignKey(CompositeWorkFlow)
singular = models.ForeignKey(SingularWorkFlow)
index = models.IntegerField(default=None, null=True)

class Meta:
ordering = ['index',]



Brian Schott
bfsch...@gmail.com



On Nov 29, 2011, at 10:44 AM, Marc Edwards wrote:

> I need some help in resetting my thinking on creating my Django data
> model.
> 
> I have previously created an XML schema definition for my data model,
> but am now trying to re-create this XML data model in a Django data
> model.
> 
> In my XML schema, I had defined "collections" of XML complex types
> that essentially were lists that I could XQuery.  I used the ID &
> IDREF tags to cross-reference my elements between lists of elements.
> As XML is a tree structure, my schema defined a top down tree
> hierarchy.  Now I want to redefine this in a Django data model.
> 
> In my primary scenario, I had a list of "singular" workflows that
> constituted a "parent" element "catalog" of workflows, i.e. a workflow
> catalog. Multiple "singular" workflows can be combined into an ORDERED
> collection of workflows called a "reference" or "composite" workflow.
> There are many composite/reference workflow instances with varied
> ordered combinations of singular workflows.
> 
> In my XML hierarchy, I used the IDREF tags to reference the "singular"
> workflows from within the "reference" workflow element instance.
> 
> In my Django object model, I can define a class for a "singular"
> workflow...easy enough, and I can query the Django database model to
> select the "singular" workflows.
> 
> But, what is the correct method of now creating the "composite"
> workflow that will reference the singular workflows?
> 
> My pseudo-code for the composite workflow class looks like this...
> 
> class SingularWorkFlow(models.Model):
>   pass
> 
> class CompositeWorkflow(models.Model):
>   OrderedListOfSingularWorkflows =
> list(models.ForeignKey(SingularWorkFlow)
> 
> I don't think this will work, but would kindly ask for some guidance.
> 
> Regards, Marc
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: slow function

2011-12-05 Thread Brian Schott
That's usually a bad sign when other programmers start naming saints when 
reviewing your code :-).   I have similar code explosion issues in a models.py 
file in a site I'm building.  

What's the best dangothonic way to break up models.py or views.py for that 
matter.  
1. Create a models.py or views.py at the top level that does a bunch of 
imports?  Explicitly or progrmmatically by looping over files?
2. Expose the hierarchy to the caller.  Ex: from my_app.models.my_model import 
MyModel
3. Break up the whole app into smaller apps?  

Still trying to figure out a good way to determine what should be a separate 
app.  If you have a relathionships like Publishers -> Books, and Authors -> 
Books should you try to break out Books, Authors, and Publishers as separate 
apps?  

Brian Schott
bfsch...@gmail.com



On Dec 5, 2011, at 5:18 AM, Håkon Erichsen wrote:

> - Holy mother of god, that's a huge view file! I would advice to slice it 
> into logically separated files, and put this in a directory called "views", 
> everything doesn't have to be in views.py!
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Novice question...generation of model instances within a "for" loop...

2011-12-08 Thread Brian Schott
I think if you set:
new_cmd_str.id = None 
That will force a new PK.  Not sure why the CmdString constructor isn't 
clearing this..

Brian Schott
bfsch...@gmail.com



On Dec 8, 2011, at 11:47 AM, Marc Edwards wrote:

> I'm looping through some JSON code and generating new model instances
> that I am saving to my SQLiteDB.
> 
> I have 3 nested "for" loops, like this:
> 
>for app_catalog in JSON_Object['TSS_WorkFlow_Catalog']:
>for eda_app in app_catalog['EDA_App']:
>new_eda_app =
> EDA_App(isv=eda_app['isv'],product_name=eda_app['product_name'],product_category=eda_app['product_category'])
>new_eda_app.save()
>for cmd_str_pair in eda_app['CmdStrings']['name']:
>new_cmd_str = CmdString(name=cmd_str_pair['Text'],
> cmd=cmd_str_pair['Value'], eda_app=new_eda_app)
>new_cmd_str.save()
> 
> My JSON file has 3 EDA_Apps, each EDA_App has 3, 4, and 4 CmdStrings,
> respectively.
> 
> When I loop through the second nested "for" for the CmdStrings,
> the .save() is writing to the same model instance, and at the end of
> the first nested "for" loop, I have 3 CmdString instances in my DB,
> NOT 3+4+4=11 CmdString instances.
> 
> Since my DB has 3 EDA_Apps in the DB, I think that the code to
> instance a new model instance to save to the DB seems to be fine. It
> is the second nested "for" loop that is acting fishy.  I don't know if
> I am doing something wrong relative to the DB, because when I step
> through the 2nd nested "for" loop, I can clearly see the "new_cmd_str"
> taking on the next values from the JSON file.  This must be related to
> how I am using the DB.
> 
> When I try using .save(force_insert=True) on the 2nd nested "for" loop
> save, I receive a Django DEBUG page message that the "PRIMARY KEY must
> be unique".
> 
> Any thoughts or observations on my code style?
> 
> Kind regards, Marc
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django E-Commerce Framework

2011-12-08 Thread Brian Schott
I've been playing with django-shop.  It looks lightweight, class extensible, 
and lightweight, but haven't worked with it enough to recommend yet.  That's 
still in my scrum backlog...

Brian Schott
bfsch...@gmail.com



On Dec 8, 2011, at 11:58 AM, Nan wrote:

>> I'm guessing that the OP wanted to develop a "standard" e-commerce
>> site for a single company, in which case I agree with Stuart and Andre
>> that the way to go is a well-tested e-commerce framework.
>> 
>> I had to roll my own because I was doing something very different
>> ...
>> But had a
>> well-tested framework for that kind of thing been available, I would
>> have grabbed it.
> 
> Seconded.  Satchmo is great if you're trying to create a bog-standard
> e-commerce site.  Our requirements turned out to be far outside of
> what Satchmo supports, and even using Custom Products, getting Satchmo
> to do even half of what we needed was extremely time consuming and
> awkward (the documentation skims the surface of implementation and
> customization and wasn't much help for a lot of what we needed to
> do).
> 
> Worse, the Custom Product system resulted in as many as 1200 queries
> (I kid you not) for a simple page displaying a dozen products with
> "add to cart" buttons -- which couldn't be properly cached due to CSRF
> protection.  With some careful query caching added to both our
> extensions and Satchmo's core, we brought this down to around 80
> queries... when the cache is current.
> 
> But now we want to add some features that can't be done without
> significantly forking Satchmo itself, so we're probably going to roll
> our own.
> 
>> The good thing is that the Django community has build lots of high-quality
>> modules that cover just about every corner of this space, so any specific
>> needs can almost certainly be addresses here. "What can I use for
>> e-commerce" is a very open-ended question, though.
> 
> Not to hijack the OP's thread, but if you have any suggestions for
> basic shopping cart functionality, payment processing (Paypal Pro?),
> or coupons / BOGO (that's buy-one-get-one), I for one would love to
> hear them.
> 
> 
> On Dec 7, 10:19 am, bobhaugen  wrote:
>> I'm guessing that the OP wanted to develop a "standard" e-commerce
>> site for a single company, in which case I agree with Stuart and Andre
>> that the way to go is a well-tested e-commerce framework.
>> 
>> I had to roll my own because I was doing something very different: B2B
>> e-commerce with an efficient order form (order from a grid combining
>> many products, not one-product-per-page adding to a shopping cart one
>> at a time) and order line items from many producers where the payment
>> from the customer needs to get allocated to each producer.  But had a
>> well-tested framework for that kind of thing been available, I would
>> have grabbed it.
>> 
>> As it is, I did use django-paypal with some customizations, which is
>> its own kind of pain in the butt.  (Not django-paypal, the
>> customizations, because now I am stuck with the version of django-
>> paypal that I customized...)  Eventually I'll take another look at
>> payment apps and some of the newer e-commerce frameworks that are more
>> modular.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Split File Storage

2011-12-27 Thread Brian Schott
Sounds like you already have a django-centric solution in mind, but what you 
want might be found in a distributed filesystem solution like Gluster 
(http://www.gluster.org/) or a distributed object store like Swift 
(http://swift.openstack.org/) accessed via django-storages.  Or put them on 
CloudFiles or S3?  Replication is good because the MTBF plummets as you add 
bits.

Brian Schott
bfsch...@gmail.com



On Dec 27, 2011, at 9:02 PM, Cameron wrote:

> Greetings all-
> 
> I have a django site which is referencing about 1TB of static files at the 
> moment and growing fast. I am running out of affordable upgrade options and 
> need to scale the file storage out to multiple machines once it hits 3TB. I 
> have a pretty good idea about what needs to be done for this but I wanted to 
> ask here first incase someone has a snippet / custom storage already written 
> that does something similar?
> 
> I have seen django-dust and django-resto however these are both replicated 
> storage for load balancing / HA. I actually want to be able to split the 
> storage of the files between servers and control when certain servers are 
> full and can no longer write to etc.
> 
> Any advice would be much appreciated. Cheers.
> -
> Cameron
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/J-sDi9ah1NMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Directory layout for a large Django application (not project)

2012-01-09 Thread Brian Schott
My advice is If you find yourself breaking models, views, utils, etc. into 
separate files within an app, you should really consider breaking your app into 
multiple apps.  I hit this myself in or own project and found myself dealing 
with the auto registration functionality for admin.py, tasks.py, and a bunch of 
other too-large files.  I bit the bullet and broke things out and my 
import/discovery headaches disappeared.  My individual py files got small and 

+--major_app
 +--docs
 +--templates
  +-- (img, js, css, base.html)
 +--projects
  +--dev
  +--test
  +--deploy
 +--apps
  +--sub_app1(create with startapp command)
   +--models.py
   +--tasks.py
   +--templates
   +--tests.py
   +--urls.py
   +--views.py
   +--...
  +--sub_app2
   +-- .

I put this in the top of my settings.py files down in projects/dev or 
projects/test, or projects/deploy so that the apps just get discovered.

# the base directory is up two levels from the project
PROJDIR = os.path.abspath(os.path.dirname(__file__)) + '/'
PROJNAME = PROJDIR.split('/')[-2]
BASEDIR = os.path.abspath(os.path.join(PROJDIR, '..', '..')) + '/'
APPSDIR = os.path.abspath(os.path.join(BASEDIR, 'apps')) + '/'

# add apps and projects directory to path
sys.path.insert(0, PROJDIR)
sys.path.insert(0, APPSDIR)

Brian

Brian Schott
bfsch...@gmail.com

On Jan 7, 2012, at 2:24 PM, IgorS wrote:

> Below is my current structure. I am new to Django and probably missing
> something... Restructuring an application somewhere in the middle of
> the development cycle is more expensive than just having the "right"
> layout from the start. Especially if this is possible. I consider a
> small overhead at the start being better than a great rework in the
> middle (yes, i am aware of the minimal viable product concept :-)
> 
> app
>   +--models
>   ---abstract_base.py
>   ---core.py
>   ---...
>   +--probe
>   +--static
>   ---css
>   ---js
>   ---images
>   +--templates
>   ---base.html
>   ---...
>   +--tests
>   ---test_users.py
>   ---...
>   +--utils
>   +--views
>   ---__init__.py
>   ---app_settings.py
>   ---context_processors.py
>   ---middleware.py
>   ---urls.py
> 
> Thank you,
> -igor



smime.p7s
Description: S/MIME cryptographic signature


Re: Directory layout for a large Django application (not project)

2012-01-10 Thread Brian Schott
I see I broke off mid thought, my individual py files got small and I didn't 
have to do any of my own sub-file discovery logic to do something like 
"models/foo_models.py", "models/bar_models.py"...  There is nothing preventing 
tight foreign-key relationships across apps.  In reality, all of the tables are 
in the same database.  

I also use:

class Meta:
app_label = 'major_app'

in the model class of each sub_app, so that all of the admin pages are grouped 
together.  

Brian

Brian Schott
bfsch...@gmail.com



On Jan 10, 2012, at 1:46 AM, Derek wrote:

> Brian
> 
> That is useful "generic" advice and a topic I am very interested in -
> how to break up an "enterprise" type of application into smaller apps
> (to enable distribution of sub-sections to different types of
> audiences) while at the same time maintaining tight coherency among
> closely-related data sets.  In this case there is a typically a "core"
> data set and then many other more peripheral ones that all need to
> connect to the core.  I have not yet seen any example of such a design
> process - or even a set of principles - which describe *how* to
> achieve such a design.
> 
> Derek
> 
> On 9 January 2012 18:18, Brian Schott  wrote:
>> My advice is If you find yourself breaking models, views, utils, etc. into 
>> separate files within an app, you should really consider breaking your app 
>> into multiple apps.  I hit this myself in or own project and found myself 
>> dealing with the auto registration functionality for admin.py, tasks.py, and 
>> a bunch of other too-large files.  I bit the bullet and broke things out and 
>> my import/discovery headaches disappeared.  My individual py files got small 
>> and
>> 
>> +--major_app
>> +--docs
>> +--templates
>>  +-- (img, js, css, base.html)
>> +--projects
>>  +--dev
>>  +--test
>>  +--deploy
>> +--apps
>>  +--sub_app1(create with startapp command)
>>   +--models.py
>>   +--tasks.py
>>   +--templates
>>   +--tests.py
>>   +--urls.py
>>   +--views.py
>>   +--...
>>  +--sub_app2
>>   +-- .
>> 
>> I put this in the top of my settings.py files down in projects/dev or 
>> projects/test, or projects/deploy so that the apps just get discovered.
>> 
>> # the base directory is up two levels from the project
>> PROJDIR = os.path.abspath(os.path.dirname(__file__)) + '/'
>> PROJNAME = PROJDIR.split('/')[-2]
>> BASEDIR = os.path.abspath(os.path.join(PROJDIR, '..', '..')) + '/'
>> APPSDIR = os.path.abspath(os.path.join(BASEDIR, 'apps')) + '/'
>> 
>> # add apps and projects directory to path
>> sys.path.insert(0, PROJDIR)
>> sys.path.insert(0, APPSDIR)
>> 
>> Brian
>> 
>> Brian Schott
>> bfsch...@gmail.com
>> 
>> On Jan 7, 2012, at 2:24 PM, IgorS wrote:
>> 
>>> Below is my current structure. I am new to Django and probably missing
>>> something... Restructuring an application somewhere in the middle of
>>> the development cycle is more expensive than just having the "right"
>>> layout from the start. Especially if this is possible. I consider a
>>> small overhead at the start being better than a great rework in the
>>> middle (yes, i am aware of the minimal viable product concept :-)
>>> 
>>> app
>>>   +--models
>>>   ---abstract_base.py
>>>   ---core.py
>>>   ---...
>>>   +--probe
>>>   +--static
>>>   ---css
>>>   ---js
>>>   ---images
>>>   +--templates
>>>   ---base.html
>>>   ---...
>>>   +--tests
>>>   ---test_users.py
>>>   ---...
>>>   +--utils
>>>   +--views
>>>   ---__init__.py
>>>   ---app_settings.py
>>>   ---context_processors.py
>>>   ---middleware.py
>>>   ---urls.py
>>> 
>>> Thank you,
>>> -igor
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: Directory layout for a large Django application (not project)

2012-01-10 Thread Brian Schott
Interesting!   So, that means you can serve blog.example.com and 
shop.example.com from the same server?  I haven't tried any of the multi-site 
support in django, so not sure how this compares.  Makes my head hurt to think 
what this does to SSL.   I've never been able to figure out SSL and virtual 
hosting on Apache.

Brian Schott
bfsch...@gmail.com



On Jan 10, 2012, at 6:01 AM, Cal Leeming [Simplicity Media Ltd] wrote:

> I've hit this same problem myself many times.
> 
> Ultimately there is never any one answer - you can split out functionality 
> into individual modules, but there has to be a good use case for it, 
> otherwise the overhead has a negative impact.
> 
> You also have to take into consideration the re-usability of what you are 
> splitting out, and if something is split out, then it has to be treated as a 
> standardized module which is kept backwards compatible for everything.
> 
> It's not just a case of having a standardized directory layout, the entire 
> use case of the project will determine the layout - you can follow 'sane 
> principles' such as naming convention etc, but the actual splitting of 
> functionality is really up to the developer (and isn't really something that 
> can be taught - it's more of an experience thing).
> 
> Personally, I found that using 'MultiHostMiddleware' has been an absolute 
> life saver for splitting out sites within a single project - check it out: 
> http://code.djangoproject.com/wiki/MultiHostMiddleware (I just went and 
> tidied it up a bit).
> 
> Just my two cents worth!
> 
> Cal
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.



smime.p7s
Description: S/MIME cryptographic signature


file manager options for user home directory

2012-01-18 Thread Brian Schott
Looking for some expert advice.  I need to provide an upload and file browse 
capability for a user's home directory.  It doesn't have to be a full blown 
file explorer necessarily, just a basic upload, download, rename, delete.  
What's the best way to deal with the userid issues on Linux?   The files live 
in a user's home directory, so the files are owned by the user, not www-data, 
and it's probably not an option to set the default group to www-data.  Users 
can remote desktop and/or ssh to their account, so no predicting what 
user/group creation will happen behind the scenes.

I've thought about different options, but they all have tradeoffs:
1. dav enabled nginx process for each user with a javascript dav file explorer?
2. django-storages with sftp?
3. something else?

Brian

Brian Schott
bfsch...@gmail.com





smime.p7s
Description: S/MIME cryptographic signature


Re: file manager options for user home directory

2012-01-19 Thread Brian Schott
That might work for a public folder in a user's home directory, but I was 
looking for a mechanism that doesn't involve gutting all security or relying on 
users to correctly set permissions our groups.  I could tolerate adding a key 
to a user .ssh/authorized_keys file that gives www-data user 
command="sftp-internal" access if django-storages sftp backend allows multiple 
accounts (or even as root if properly root jailed to /home).  Just feel I'm 
going the long way around the barn and am missing an obvious way to for 
web-based file management for user's files...

On Jan 19, 2012, at 12:56 AM, Mike Dewhirst wrote:

> On 19/01/2012 2:10pm, Brian Schott wrote:
>> Looking for some expert advice.  I need to provide an upload and file
>> browse capability for a user's home directory.  It doesn't have to be
>> a full blown file explorer necessarily, just a basic upload,
>> download, rename, delete.  What's the best way to deal with the
>> userid issues on Linux?   The files live in a user's home directory,
>> so the files are owned by the user, not www-data, and it's probably
>> not an option to set the default group to www-data.  Users can remote
>> desktop and/or ssh to their account, so no predicting what user/group
>> creation will happen behind the scenes.
> 
> If the user makes the particular files world-readable/writable it doesn't 
> matter what the uid/gid happens to be. Everything should just work for nginx.
> 
> 
>> 
>> I've thought about different options, but they all have tradeoffs: 1.
>> dav enabled nginx process for each user with a javascript dav file
>> explorer? 2. django-storages with sftp? 3. something else?
>> 
>> Brian
>> 
>> Brian Schott bfsch...@gmail.com
>> 
>> 
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: Execution time of a long process results in an Internal Server Error 500

2013-01-10 Thread Brian Schott
+1
http://pypi.python.org/pypi/django-celery
is a good solution for this kind of background task.  It opens up a lot 
possibilities like django-celery-email for background email sending, etc.  Keep 
your web contexts as short as possible.

For the AJAX server-side integration, check out:
http://www.dajaxproject.com


Brian Schott
bfsch...@gmail.com



On Jan 10, 2013, at 9:12 AM, Tom Evans  wrote:

> On Thu, Jan 10, 2013 at 1:21 PM, Mauro Sánchez  wrote:
>> Hello, I have a process that takes about 2 or 3 minutes to execute. The
>> problem is that sometimes (not always) it results in an Internal Server
>> Error 500 because of the time it takes.
>> Is there a way to configure Apache or mod_wsgi to prevent this? Let's say,
>> that even if the process takes 10 or 15 minutes it just keeps running until
>> it finish?
>> Thanks a lot for the help.
>> Cheers,
>> Mauro.
>> 
> 
> Providing a URL that consumes an entire web worker for >1 minute is a
> good way to open yourself up for a DOS attack - even 10 seconds is too
> long really. Put lengthy operations in to a queue - like django-celery
> -  so that you can manage how much of your resources that task
> consumes, and poll for completion with AJAX.
> 
> Cheers
> 
> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Automating deployments

2013-02-01 Thread Brian Schott
We are using ansible.
http://ansible.cc/

Other popular choices are puppet and chef.  The real benefit. Is that these
tools let you version control your configurations.

Sent from my iPhone

On Feb 1, 2013, at 7:46 PM, Carlos Aguilar  wrote:

Bash scripts really???

If you are a Python developer you can use fabric to deployed and pip for
dependencies.

Best Regards

El viernes, 1 de febrero de 2013, Marc Aymerich escribió:

> Hi,
> I'm thinking about the best way to provide automatic deployment for
> the Django project I'm working on. Its a pretty big one and has lots
> of dependencies, lots of SO packages, Celeryd and other daemons, SO
> tweaks... and also several people will need to have installed it on
> their servers (they are sysadmins, not Django developers), Therefore I
> want to automate as much as possible the installation and updating
> processes, to minimize their pain and also because of having
> homogeneity.
>
> As I've been a sysadmin myself for many years I've already written
> some bash scripts that automates all the deployment. But in order to
> make it more 'natural' I'm planning to integrate those scripts within
> the Django project as management commands.
>
> To illustrate my ultimate goal this is how I imagine the workflow:
>
> sudo pip install django-my_project
> my_project-admin.sh clone project_name path
>
> sudo python manage.py installrequirements
> sudo python manage.py setuppostgres
> python manage.py syncdb
> python manage.py migrate
> python manage.py createsuperuser
>
> sudo python manage.py setupapache
> python manage.py collectstatic
> sudo python manage.py setupceleryd
> sudo python manage.py createtincserver
> python manage.py updatetincd
> sudo python manage.py setupfirmware
> python manage.py loaddata firmwareconfig
>
> sudo python manage.py restartservices
>
>
> Any thought on this? How do you automate your deployments? I heard
> about fabric lots of times but never used it. Will fabric be helpful
> in my case? Does it has any advantage for writing my own scripts? Or
> maybe there are already some existing tools for automating deployment
> of most common services like Apache, celeryd ..,?
>
> Many thanks!
> br
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com .
> To post to this group, send email to 
> django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
Carlos Aguilar
Consultor Hardware y Software
DWD&Solutions
http://www.dwdandsolutions.com
http://www.houseofsysadmin.com
Cel: +50378735118
USA: (301) 337-8541

 --
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Confusion about Static Files

2013-03-29 Thread Brian Schott
David,

This took me a while to figure out also when I first started.  Running with 
debug on and runserver works great, then you try to use it in production and 
things break.  The big picture idea is that static files are intended to be 
hosted by something in front of Django, be that Apache or Ngnix or whatever.  
All of the django.contrib.static module does is define a) how/where the 
manage.py collectstatic command finds static files, STATICFILES_FINDERS, 
STATICFILES_DIRS, b) where it will save them on the local filesystem 
STATIC_ROOT, and c) what URL prefix will get used in templates STATIC_URL.

With settings.DEBUG  = True, you can add static files to your url pattern with 
the code below so that your server will work with manage.py runserver, but as 
soon as you go production and turn off DEBUG, this will stop working by design.
---
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()
---

You really want not to serve files through Django.  Just do a collectstatic 
before runserver, and point your web server /static/ location at that 
directory. Here is a link to the nginx.conf file used by Mezzanine (a Django 
CMS app).
https://github.com/nimbis/mezzanine-project/blob/master/deploy/
Notice that location /static/ is served directly and everything else for the 
most part is a redirect to the Django server running on another port.  You can 
find Apache examples all over the place.  


Brian Schott
bfsch...@gmail.com



On Mar 29, 2013, at 3:36 PM, David Pitchford  
wrote:

> I am experienced with Python but new to Django and web development in 
> general. I am struggling to understand its static files system from the 
> documentation. It seems like I have to set multiple settings variables and 
> create multiple folders in order to get the server to accomplish the simple 
> task of "finding" these files. After toying with it for a few hours I haven't 
> been able to get the static files system to work and and have resorted to the 
> following system which is probably a very bad idea:
> 
> In views.py:
> 
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> import datetime
> import os.path
> import settings
> 
> statictypes = {".css": "text/css",
>".js": "text/javascript"}
> 
> def servestatic(request, filename):
> fullfilename = os.path.join(settings.STATIC_ROOT, filename)
> ext = os.path.splitext(filename)[1]
> return HttpResponse(open(fullfilename).read(), 
> content_type=statictypes[ext])
> 
> And in urls.py:
> 
> from django.conf.urls import patterns, include, url
> import mysite.views as views
> 
> staticextensions = [ext[1:] for ext in views.statictypes.keys()]
> staticextstring = '|'.join(staticextensions)
> 
> urlpatterns = patterns('',
> ...
> (r"([^/]+\.(?:%s))$" % staticextstring, views.servestatic)
> )
> 
> This actually works (and I could optimize it by caching the static file 
> contents in memory rather than continually rereading them), but of course 
> it's circumventing Django's built-in system for managing static files. My 
> project architecture looks like this:
> 
> mysite
> |
> |--manage.py
> |--mysite
>|
>|__init__.py
>|settings.py
>|urls.py
>|views.py
>|wgsi.py
>|--static
>|  |
>|  |--jquery.js
>|  |--TestFormat.css
>|
>|--templates
>   |
>   |--TestTemplate.html
> 
> At the beginning, the documentation page mentions, "For small projects, this 
> isn’t a big deal, because you can just keep the static files somewhere your 
> web server can find it." This sounds like the simple solution I'm looking 
> for; what does it mean and how do I do it? I'm also frequently confused by 
> how when I created the project it created two nested folders with the same 
> name. Which is considered to be the "project root"?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Deploying: Desktop to server

2013-04-09 Thread Brian Schott
Tim,

Others are welcome to disagree, but try to avoid the trap of using JSON 
fixtures to migrate the database.   You can get yourself in trouble pretty 
quickly with foreign key collisions if you are not careful.  Use pg_dump or 
mysqldump instead to backup/move database content.  A good strategy is to do 
content updates on the production site and test/develop against database 
snapshots locally.

Also, when you change the models,  it is worth learning how to use South to do 
schema migration.  
http://south.readthedocs.org/en/latest/tutorial/part1.html 

Brian Schott
bfsch...@gmail.com



On Apr 9, 2013, at 4:37 AM, Tom Evans  wrote:

> On Tue, Apr 9, 2013 at 1:09 AM, Tim Johnson  wrote:
>> FYI - I'm new to django, but have been doing web programming since
>> '96 and python since '03.
>> 
>> I intend to put together a test site on my desktop and push it to a
>> remote server. I will be the only user making changes to this site.
>> 
>> Thus I presume that it is OK to push the database as well.
> 
> Any time you push the database you will wipe any changes that are made
> on the site itself. This includes things like sessions, users, etc. If
> you don't use these things, then sure, push your DB to the site. If
> your site makes any changes to your DB at all, it's probably not safe
> to push it.
> 
> Cheers
> 
> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
Is a many-to-many what you really want?  How common are the choices and suppose 
someone goes in an edits one of the choices and suddenly it doesn't match up 
right with a different linked question.  It might make sense to use a reverse 
foreign key one-to-many relationship and provide a mechanism to duplicate a 
question, including its member choices.  That way you could add some statistics 
on each choice unique to a question.

Several possible paths depending on how you want to go.

1.  You could just use a reverse foreign key and have a one-to-many 
relationship.

class Choice(models.Model):
question = models.ForeignKey('Question', related_name='choices')
choice = models.CharField(max_length=255)
index = models.IntegerField(default=0)  # in case you want order_by 
filtering
count = models.IntegerField(default=0) # in case you want to count 
number of times this is selected right or wrong
is_correct = models.BooleanField(default=False) # boolean flag replaces 
"answer"

class Question(models.Model):
  question = models.CharField(max_length=64)
  module = 
 
def times_correct(self):
return 
self.choices.objects.filter(is_correct=True).aggregate(Sum('count'))

def times_total(self):
return self.choices.objects.aggregate(Sum('count'))


Then in the admin, you create a table inline admin and just add unique entries.


2. Encode the thing as a JSON list and store in a JSONField
https://github.com/derek-schaefer/django-json-field

3. There are several flavors of ListField out there:
http://djangosnippets.org/snippets/1491/



Brian Schott
bfsch...@gmail.com



On Apr 10, 2013, at 1:38 PM, Cody Scott  wrote:

> I am trying to store questions in a database.
> I don't to set a fixed number of options for the question, some questions 
> could have 4 or 2 or 5.
> 
> Currently I am using a ManyToManyField to a table that just contains a 
> CharField.
> This works but creating an option requires making another Choice object and 
> selecting that, also when you want to select a Choice that has already been 
> created you have to use that little box in the admin and it doesn't scale 
> when you have hundreds of options.
> 
> Even if I wanted to have 4 options every time what is the recommended way 
> without having four CharFields?
> 
> class Choice(models.Model):
> choice = models.CharField(max_length=255)
> def __unicode__(self):
> return self.choice
>  
> #multiple choice question
> class Question(models.Model):
> question = models.CharField(max_length=64)
> answer = models.CharField(max_length=255)
> choices = models.ManyToManyField(Choice, related_name='questions', 
> verbose_name='options')
> module = models.ForeignKey('Module', related_name='questions')
>  
> times_correct = models.IntegerField(editable=False, default=0)
> times_total = models.IntegerField(editable=False, default=0)
>  
> def _get_average(self):
> "Returns the average in percent"
> if self.times_total != 0:
> return (self.times_correct / float(self.times_total))*100
> return 0.0
> average = property(_get_average)
>  
> def __unicode__(self):
> return self.question
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
You can create and edit choices right in the Question admin view.  You can even 
control how many blank slots to show by default.  Go look at ChoiceInline admin 
here in the tutorial:
https://docs.djangoproject.com/en/dev/intro/tutorial02/

The next step would be to create an admin action on Question to duplicate the 
question and its choices.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/

That way, your workflow is duplicate a question, edit on a single page, hit 
save.

Brian Schott
bfsch...@gmail.com



On Apr 10, 2013, at 3:02 PM, Cody Scott  wrote:

> I like the is_correct and the count attributes!
> 
> The problem with that it is hard to make a quiz in the admin section. You 
> create a quiz and a question but then you have to go to the choice section 
> and create choices for the question. And even if you have the same choice in 
> two questions you need to create the choice multiple times.
> 
> It would be nice to have text fields and be able to say add a 5th choice, and 
> just enter text. It seems easier than changing forms and selecting an option 
> from a large list, or even in your case creating each choice for a quiz.
> 
> Is there a way to have the admin link from Question to Choice in this 
> configuration?
> 
> On Wednesday, 10 April 2013 14:43:54 UTC-4, BFSchott wrote:
> Is a many-to-many what you really want?  How common are the choices and 
> suppose someone goes in an edits one of the choices and suddenly it doesn't 
> match up right with a different linked question.  It might make sense to use 
> a reverse foreign key one-to-many relationship and provide a mechanism to 
> duplicate a question, including its member choices.  That way you could add 
> some statistics on each choice unique to a question.
> 
> Several possible paths depending on how you want to go.
> 
> 1.  You could just use a reverse foreign key and have a one-to-many 
> relationship.
> 
> class Choice(models.Model):
>   question = models.ForeignKey('Question', related_name='choices')
>   choice = models.CharField(max_length=255)
>   index = models.IntegerField(default=0)  # in case you want order_by 
> filtering
>   count = models.IntegerField(default=0) # in case you want to count 
> number of times this is selected right or wrong
>   is_correct = models.BooleanField(default=False) # boolean flag replaces 
> "answer"
> 
> class Question(models.Model):
>   question = models.CharField(max_length=64)
>   module = 
>  
>   def times_correct(self):
>   return 
> self.choices.objects.filter(is_correct=True).aggregate(Sum('count'))
> 
>   def times_total(self):
>   return self.choices.objects.aggregate(Sum('count'))
> 
> 
> Then in the admin, you create a table inline admin and just add unique 
> entries.
> 
> 
> 2. Encode the thing as a JSON list and store in a JSONField
> https://github.com/derek-schaefer/django-json-field
> 
> 3. There are several flavors of ListField out there:
> http://djangosnippets.org/snippets/1491/
> 
> 
> 
> Brian Schott
> bfsc...@gmail.com
> 
> 
> 
> On Apr 10, 2013, at 1:38 PM, Cody Scott  wrote:
> 
>> I am trying to store questions in a database.
>> I don't to set a fixed number of options for the question, some questions 
>> could have 4 or 2 or 5.
>> 
>> Currently I am using a ManyToManyField to a table that just contains a 
>> CharField.
>> This works but creating an option requires making another Choice object and 
>> selecting that, also when you want to select a Choice that has already been 
>> created you have to use that little box in the admin and it doesn't scale 
>> when you have hundreds of options.
>> 
>> Even if I wanted to have 4 options every time what is the recommended way 
>> without having four CharFields?
>> 
>> class Choice(models.Model):
>> choice = models.CharField(max_length=255)
>> def __unicode__(self):
>> return self.choice
>>  
>> #multiple choice question
>> class Question(models.Model):
>> question = models.CharField(max_length=64)
>> answer = models.CharField(max_length=255)
>> choices = models.ManyToManyField(Choice, related_name='questions', 
>> verbose_name='options')
>> module = models.ForeignKey('Module', related_name='questions')
>>  
>> times_correct = models.IntegerField(editable=False, default=0)
>> times_total = models.IntegerField(editable=False, default=0)
>>  
>> def _get_average(self):
>> "Returns the average in perc

Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
Cody,

This is a REALLY large list, so I recommend at this level of detailed question 
to StackOverflow.  It is a great resource and lots of Django developers like to 
show off and write your code for you sometimes :-).

Short answers:
There are ways to do custom inline forms:
http://stackoverflow.com/questions/1559690/custom-form-in-inline-form
and  filtering the queryset many-to-many choices:
http://stackoverflow.com/questions/291945/how-do-i-filter-foreignkey-choices-in-a-django-modelform

Also, you can just add a module foreign key reference to Choice as well and set 
a unique_together constraint on choice + module.  There are tradeoffs in all of 
these approaches.

Brian

Brian Schott
bfsch...@gmail.com



On Apr 10, 2013, at 4:30 PM, Cody Scott  wrote:

> I also want to have the same question in multiple quizzes. But the count for 
> each option should be dependent on the Quiz. I can do the same thing to Quiz 
> in the admin and add Questions Inline but then to add Choices to the 
> Questions I need to go to the question panel and there will be a lot of 
> duplicate questions and it will hard to tell which question is for which quiz.
> 
> I'm not even adding the Choices to the admin because there will be so many 
> duplicates, but I can't not add Question to the admin because I still need to 
> set choices.
> 
> Is there a way to Inline 2 steps? So that I can set Choices for a Question 
> when I am making a Quiz?
> 
> On Wednesday, 10 April 2013 13:38:14 UTC-4, Cody Scott wrote:
> I am trying to store questions in a database.
> I don't to set a fixed number of options for the question, some questions 
> could have 4 or 2 or 5.
> 
> Currently I am using a ManyToManyField to a table that just contains a 
> CharField.
> This works but creating an option requires making another Choice object and 
> selecting that, also when you want to select a Choice that has already been 
> created you have to use that little box in the admin and it doesn't scale 
> when you have hundreds of options.
> 
> Even if I wanted to have 4 options every time what is the recommended way 
> without having four CharFields?
> 
> class Choice(models.Model):
> choice = models.CharField(max_length=255)
> def __unicode__(self):
> return self.choice
>  
> #multiple choice question
> class Question(models.Model):
> question = models.CharField(max_length=64)
> answer = models.CharField(max_length=255)
> choices = models.ManyToManyField(Choice, related_name='questions', 
> verbose_name='options')
> module = models.ForeignKey('Module', related_name='questions')
>  
> times_correct = models.IntegerField(editable=False, default=0)
> times_total = models.IntegerField(editable=False, default=0)
>  
> def _get_average(self):
> "Returns the average in percent"
> if self.times_total != 0:
> return (self.times_correct / float(self.times_total))*100
> return 0.0
> average = property(_get_average)
>  
> def __unicode__(self):
> return self.question
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: a bit confused about projects/apps

2013-07-17 Thread Brian Schott
Unless you really want to build it all from scratch, you might want to look at 
a CMS framework such as Mezzanine (http://mezzanine.jupo.org), DjangoCMS 
(https://www.django-cms.org), FeinCMS.

Think of a project as a Django web server configuration.  In the end, manage.py 
and settings.py are just Python, so you can build hierarchy if you want and use 
introspection to import file/directory settings hierarchy.

However, it sounds like you have a collection of very interrelated apps, so it 
probably makes sense to keep it in a single project for your site.  We have a 
base site and several rebranded copies, so we have multiple project directories 
in our code tree, but each server is just one project.  Don't forget, there are 
global things like user authentication you don't want to have a user have to 
login separately to go to blog.example.com from www.example.com. 

Brian


On Jul 17, 2013, at 8:30 AM, Alex Hall  wrote:

> Hi all,
> I currently have a boring, small, plain website to give the essential 
> information about my business. I hope to add a projects section, to host 
> programming projects I have done, a section for hosting 
> articles/tutorials/recordings, and, eventually, an ecommerce system so i can 
> charge for some of it. In the future, I also hope to have a remote 
> instruction system using some sort of VOIP (I am a technology instructor), 
> which will also be paid.
> 
> So, what might my setup look like? Would my entire site be one project, with 
> apps for programming projects, writings/recordings, and ecommerce? Should I 
> use different projects? If I create a project and then later decide I want to 
> move it up a level, to the main website directory, can I do that, or are 
> there too many import statements I'd have to change? I know an app is 
> portable and pluggable, but is a project? Are you only ever supposed to have 
> a single project for a website? What about subdomains - should one project 
> run everything, or should each subdomain have its own project, even if you 
> have to copy apps? Sorry for all the questions, I just want to be sure I do 
> it right before I actually begin developing anything. Thanks.
> 
> 
> Have a great day,
> Alex (msg sent from Mac Mini)
> mehg...@gmail.com
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: dear someone,

2013-07-22 Thread Brian Schott
NAME (path to a database file) should include the filename, not just a 
directory.  Try './mysite/mysite.db' for NAME.

Brian

On Jul 22, 2013, at 1:44 PM, Stian Sjøli  wrote:

> I am trying to start up with django using the tutorial on the website. I get 
> the following error "OperationalError: unable to open database file. I have 
> change the mood for all my files so that everybody (user, group and others 
> have all right to all the files in the folder). My settings.py file I have 
> modified to say(so that I can use the builtin sqlite3 with python;
> 
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 
> 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': './mysite/',  # Or path to database file 
> if using sqlite3.
> # The following settings are not used with sqlite3:
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': '',  # Empty for localhost through domain 
> sockets or '127.0.0.1' for localhost through TCP.
> 'PORT': '',  # Set to empty string for default.
> }
> }
> 
> from another tutorial I wonder if it could be that django does not know of 
> where my python is, and vica versa...
> 
> i am greatful for any help or suggestions.
> 
> 
> stian
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: is it possible to use REST API with HTML within Django?

2013-08-15 Thread Brian Schott
You need to provide a lot more information before anyone can help.  

Sound like you have at least a view handling GET or POST returning JSON?
https://docs.djangoproject.com/en/1.5/topics/class-based-views/mixins/#jsonresponsemixin-example
http://django-rest-framework.org

If you are talking about calling AJAX from inside the browser, I recommend you 
check out:
http://www.dajaxproject.com

There are other tools, but it makes life easier.

Brian Schott
bfsch...@gmail.com



On Aug 15, 2013, at 12:27 PM, evh  wrote:

> Hi,
> 
> I am having trouble getting REST to work within Django.  Has anyone succeeded 
> in doing this?  How do I embed REST API calls within the HTML that runs my 
> webpage?  I am trying to send "commands" to a device that is connected to my 
> webpage and can do this outside of Django manually in a PowerShell window, 
> but just within my HTML code.
> 
> Thanks for any help or advice,
> Ed
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Django Periodic tasks

2013-08-16 Thread Brian Schott
Also, load the page with a busy animated gif and use something like dajaxice to 
fetch and replace the computed value.  Several examples and libraries out ther.

—
Sent from Mailbox for iPad

On Fri, Aug 16, 2013 at 11:22 PM, Some Developer
 wrote:

> On 17/08/13 03:43, Christophe Pettus wrote:
>>
>> On Aug 16, 2013, at 7:36 PM, Some Developer wrote:
>>
>>> Alternately I could get rid of the hourly period task and just work it out 
>>> when a customer visits a certain page but that is likely to lead to long 
>>> load times and heavy database use.
>>>
>>> Any suggestions on what you would do in this situation?
>>
>> Calculate the value on demand, and cache it with an expiration time, most 
>> likely.
>>
>> --
>> -- Christophe Pettus
>> x...@thebuild.com
>>
> Good plan. Thanks.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 tutorial, part 1

2013-10-12 Thread Brian Schott
Polls not pools?

—
Sent from Mailbox for iPhone

On Sat, Oct 12, 2013 at 12:58 PM, Enrico Battiston
 wrote:

> Hi, i'm a first time user and i'm experiencing an error in the first part 
> of the django 1.5 tutorial.
> At the "Activating models" paragraph when i execute the command line "*python 
> manage.py sql polls*" it return me: "ImportError: No module named pools".
> Here the section INSTALLED_APPS of setting.py:
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> # 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> 'pools',
> )
> Here the content of models.py:
> from django.db import models
> # Create your models here.
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
> Here what i've in return if i execute "*python manage.py shell --traceback*
> ":
> Traceback (most recent call last):
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 222, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 250, in execute
> translation.activate('en-us')
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/utils/translation/__init__.py",
>  
> line 90, in activate
> return _trans.activate(language)
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 183, in activate
> _active.value = translation(language)
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 172, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  
> line 154, in _fetch
> app = import_module(appname)
>   File 
> "/Users/enricobattiston/Library/Containers/com.bitnami.django/Data/app/apps/django/lib/python2.7/site-packages/django/utils/importlib.py",
>  
> line 35, in import_module
> __import__(name)
> ImportError: No module named pools
> Here  what i've in return for the command line "*django-admin.py version*": 
> "1.5"
> And for the "*python --version*": "Python 2.7.3"
> What to do?
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/35db6d08-f0b1-477a-9f68-1fd32c264878%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1381603157716.4a343d67%40Nodemailer.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Streaming images with HttpResponse?

2013-11-18 Thread Brian Schott
What are you trying to do?  Typical approach would be to use Javascript to pull 
the images.  Take a look at dajaxice.  


—
Sent from Mailbox for iPhone

On Mon, Nov 18, 2013 at 1:57 PM, Alex Karargyris 
wrote:

> So thanks to Simon I was able to make this work. Here is the code for those 
> who might be interested:
> yield ""
> yield ''
> yield "\n"
> rval, frame = settings.CAP.read()
> gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
> cv2.imwrite('media/image.jpeg', gray, [int(cv2.IMWRITE_JPEG_QUALITY), 90
> ])
> x={"src": "..%s/image.jpeg" % (settings.MEDIA_URL), "alt": "Video Frame"
> }
> yield '' % x
> yield "\n"
> However as it doesn't stream the images but instead it saves and the html 
> is refreshed every 0.01 secs. This does not seem to be an elegant solution 
> because a) there is latency and b) the browser keeps reloading constantly. 
> Some of you suggested websockets. Is there some good example for Django + 
> Websockets for streaming images to the browser?
> Thanks a lot!
> -Alex
> On Friday, November 15, 2013 11:15:21 AM UTC-5, Alex Karargyris wrote:
>>
>> I have this simple app that I opens webcam and processes the frames using 
>> OpenCV. In my views.py I have the following code:
>>
>> def processImage():
>> 
>> while True:
>> 
>> rval, frame = settings.CAP.read()  //Read frames from webcam
>> gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) //Make 
>> frame grayscale
>> pil_img = Image.fromarray(gray)  
>> 
>> response = HttpResponse(mimetype="image/png")
>> pil_img.save(response, "PNG")
>> 
>> return response
>>
>> Although there is a while loop the function runs only once because it is 
>> broken by "return response". How could I change the code to make it run 
>> constantly?
>>
>>
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/60f5ed0b-2179-4c63-9d9b-159ff8381049%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1384825037826.412bfaaf%40Nodemailer.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to share apps between projects?

2015-03-21 Thread Brian Schott
You can add an ssh git path
http://stackoverflow.com/questions/4830856/is-it-possible-to-use-pip-to-install-a-package-from-a-private-github-repository

Sent from my iPhone

> On Mar 21, 2015, at 8:50 AM, ThomasTheDjangoFan 
>  wrote:
> 
> Hi guys,
> 
> I developed some apps that I want share between 2 of my own projects.
> 
> What is the best practise for this?
> I could just copy them over, but what if there needs to be a bug-fix?
> 
> Is there something like a 'private pip install'?
> 
> Kind regards
> Thomas
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/b95b7671-44f8-4942-9de5-daf0a5951e1d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64AA0417-6D2F-42C8-919C-F605DEA8B1F0%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to fabric

2014-11-17 Thread Brian Schott
Ansible is a good choice.

Sent from my iPhone

> On Nov 17, 2014, at 11:07 AM, Cal Leeming [iops.io]  wrote:
> 
> There isn't really such a thing as a "deployment plugin", there are many 
> aspects to deployment workflow that should be considered.
> 
> It really depends on how you are intending on deploying your application, if 
> you are dockerizing it then your CI system should be building the images and 
> pushing to a repository of your choice (docker hub, S3 etc). If you are 
> snapshotting on the hosting provider, then you can use packer.io and a bunch 
> of shell scripts. Pushing code to a single server via SSH isn't really a 
> scalable way to do deployment, and if this is what you are doing then you 
> might as well run a tmux/screen session on the server instead.
> 
> Sadly other than Amazon Beanstalk and Heroku, both of which are horrifically 
> expensive, there isn't much in the way of choices. You can look at dokku and 
> deis, both of which are not considered stable for production but use the same 
> build pack idea as Heroku.
> 
> If you want to go super ghetto, you should use a shell script which SSHs into 
> your "single use" box, issue a "docker pull" then restart the running 
> container. All of these things require a lot of plumbing work.
> 
> Another approach would be to install python 2.6 in a venv (assuming you have 
> the relevant system libs) and run Fabric with that instead... In fact putting 
> fabric in its own venv is probably better because having fabric inside your 
> application space anyway would be considered cross contamination (e.g. 
> deployment tooling mixed in with application code). This may feel weird at 
> first, but once you get into the concept of separating plumbing from 
> application code, it feels more normal. If you do this, use virtualenvwrapper 
> to save headaches.
> 
> If you're a JS guy, there's also a bunch of SSH tooling for node too, but I 
> can't give any personal recommendation on those.
> 
> Cal
> 
> 
> 
>> On Mon, Nov 17, 2014 at 11:28 AM, Andreas Kuhne  
>> wrote:
>> Hi all,
>> 
>> We are just about ready to release our newly rewritten website. It is based 
>> on Django 1.6 and Python 3. 
>> 
>> We have worked through all of the problems with using python 3 (migrated 
>> some plugins ourselves, other plugins were updated during the course of the 
>> project). The only problem we have left is a good deployment plugin, so that 
>> we easily can deploy new versions of our site.
>> 
>> We previously used fabric, but that doesn't work with python 3. So I was 
>> wondering if anyone has any python 3 compatible fabric alternative that they 
>> are using?
>> 
>> Regards,
>> 
>> Andréas
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CALXYUb%3DTpr7RfejfXs2H5vryg6vGp45_bbE%2Bp8tm%3D8CgQN2hzw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAHKQagGz1tNLfdF09%3DcFBJaAWfBWFNbWCP%3DTANonGVkZSbvGfg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4679766C-BFEC-4A96-A1D2-BDBD316053EE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and SSL

2014-12-10 Thread Brian Schott
Hopefully you aren’t using Django runserver command for actually running 
Django.  This is really a configuration question relating to your WSGI 
application server.  Gunicorn is popular and supports SSL.  

http://gunicorn-docs.readthedocs.org/en/latest/settings.html#ssl 
<http://gunicorn-docs.readthedocs.org/en/latest/settings.html#ssl>

Brian Schott
bfsch...@gmail.com



> On Dec 10, 2014, at 11:55 AM, pythonista  wrote:
> 
> I am getting a request from the security infrastructure and I could use some 
> advice/recommendation.
> 
> This is a 3 tier application.
> 
> Apache/Django/Sql Server
> 
> Apache is https and there is a proxy server between.
> 
> The security team is saying that the communication from Django should also be 
> ssl encrypted in case the proxy server goes down.
> 
> 1. Can Django be made hardened via ssl?
> 2. Doesn't Apache and the Proxy server provide sufficient security so that 
> ssl / django is not required?
> 
> 3. If the Proxy server goes down I can test some header responses to 
> determine if the call is from a secure call and from the expected server
>  If such security is required is that not sufficient?
> 
> Thanks in advance.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com 
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users 
> <http://groups.google.com/group/django-users>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/611a928d-b3bf-4672-b850-591d62b7d350%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/611a928d-b3bf-4672-b850-591d62b7d350%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7AFEAE16-1C7D-4ABF-864D-BB20A4A9C509%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django collectstatic

2013-12-12 Thread Brian Schott
The best way to get help is to paste the errors into a gist 
(https://gist.github.com) or similar service and post the link.  Redact 
anything that looks like a key or password :-).

Brian Schott
bfsch...@gmail.com



On Dec 12, 2013, at 6:24 AM, kodali srinath chowdary 
 wrote:

> while dealing with collectstatic 
> i once performed it with some setting in it and it was copied into the admin 
> file
> later i changed the setting and path name then i tried  django-admin 
> collectstatic  command
> 
> its now showing errors
> 
> what colud be the problem
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/89cdd62c-409e-4f6c-8027-a22ddec49698%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



smime.p7s
Description: S/MIME cryptographic signature


Re: Polymorphic Inheritance

2014-05-13 Thread Brian Schott
A good package for what you describe is:
https://github.com/chrisglass/django_polymorphic
http://django-polymorphic.readthedocs.org/en/latest/performance.html
At best this is performing one query per table.  This is better than the 
hand-built solutions which often perform multiple queries per row.

There is a good book called "Two Scoops of Django", which recommends avoiding 
premature database optimization. Unless you've identified this is the long pole 
in your tent, you are probably better off focusing on other optimizations such 
as installing memcached.

Brian Schott
bfsch...@gmail.com



On May 13, 2014, at 2:52 PM, guettli  wrote:

> I search for a way to get polymorphic inheritance like in "Single table 
> inheritance" [1]
> 
> I have found this comparison site:
> 
>https://www.djangopackages.com/grids/g/model-inheritance/
> 
> Before I try each, I want to ask here, if someone answer some questions:
> 
> I have three classes: Parent, ChildA, ChildB.
> 
> The result of Parent.objects.filter() should return Child instances and 
> should query only one db table.
> Unfortunately one one app has filed the column "amount of queries" in the 
> comparison grid.
> What about the other apps?
> 
> Next question:
> 
> If the class Parent is in the parentapp application, and I want to subclass 
> this model in a different
> application (childapp). The table which belongs to parentapp needs to be 
> changed: new columns
> need to be added. Does south handle the migrations like in the build in 
> (django core) inheritance solutions?
> 
> Why not the build in inheritance solutions? My point of view: multi table 
> inheritance is slow and with abstract base classes
> you can't query the base class. Both solutions are not polymorphic.
> 
> 
> [1] http://en.wikipedia.org/wiki/Single_Table_Inheritance
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e1f72be5-e4ec-4e92-a6ca-30507a9bab28%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Django authentication by email

2014-05-15 Thread Brian Schott
Django-allauthhttps://github.com/pennersr/django-allauth
—
Sent from Mailbox

On Thu, May 15, 2014 at 7:58 AM, Frankline  wrote:

> Hi all,
> I am thinking of developing a web application where users will have to
> login by their email address instead of using their usernames.
> Now I know I can do this by writing my own auth backend, but I'm just
> curious how the rest of you handle this. Do you normally use third party
> packages to handle this instead of writing a custom backend? If so, what
> packages would you recommend that are actively maintained?
> Any disadvantages to writing my own custom backend?
> Thanks.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAEAUGdUV44ZjMQCxiaVk_Ok9H5SbLP3jfc_rv-vEUsHrtZWmgw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1400158119069.1bb75fac%40Nodemailer.
For more options, visit https://groups.google.com/d/optout.


Re: LoginRequiredMixin ignored

2016-06-15 Thread Brian Schott
Try swapping class order.

Sent from my iPhone

> On Jun 15, 2016, at 6:55 PM, Lee Hinde  wrote:
> 
> Using Django 1.9.7.
> I have the following class:
> class AddView(LoginRequiredMixin, CreateView):
> template_name = "entry.html"
> model = Property
> form_class = AddPropertyForm
> success_url = "/buy/"
> login_url = '/account/login/'
> 
> def dispatch(self, request, *args, **kwargs):
> print request.user
> print request.user.is_authenticated()
> return super(AddView, self).post(request, *args, **kwargs)
> 
> def form_valid(self, form):
> ls_property = form.save(commit=False)
> ls_property.user = get_user(self.request)
> ls_property.latitude = form.cleaned_data['latitude']
> ls_property.longitude = form.cleaned_data['longitude']
> submit =  form.cleaned_data['submit']
> ls_property.visible = (submit != 'draft')
> ls_property.save()
> return super(AddView, self).form_valid(form)
> 
> The LoginRequiredMixin is ignored, i.e, I can get to the page without being 
> logged in.
> request.user reports: AnonymousUser
> request.user.is_authenticated() reports: False
> If I wrap the url:
> url(r'^sell', user_passes_test(user_is_active)(AddView.as_view()), 
> name="add"),
> the page is protected, so I have a work around.
> This seems basic and I don't find other reports of LoginRequiredMixin not 
> working, so I assume it's me.
> What am I missing?
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CA%2BePoMzApQGdzZ9AW47CjF3yhT0Smnc1AZw%2BOQ8uTcH1G3%3Dasg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C45F29DE-EF15-4890-B73D-A7B20627CE5D%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python on the web

2016-03-07 Thread Brian Schott
Dude.  Try django gigs.com or freelance.com 

Sent from my iPhone

> On Mar 7, 2016, at 11:11 AM, Bob Gailer  wrote:
> 
> 
> On Mar 7, 2016 10:51 AM, "Gregg Turner"  wrote:
> >
> > Hey,
> >
> > Need a simple python script put into a website. It uses the requests module.
> >
> > $20? Any takers? 
> 
> Strictly speaking this isn't the place to buy services. Also we would need a 
> lot more information. Can you guess what that information would be?
> >
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/d178af7a-2b90-496e-9a0d-7605cfdaa013%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAP1rxO4chd1wGNbJQy4HEJ1pXopXbvmXuxg_9%3DhtNZDsH1xv5g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5A0D7A58-1B11-4E33-95B3-EF4DE2E9E42F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.