Re: Strange error in django

2015-04-22 Thread John DeRosa
Oh, sorry.

Well, you’re using joblib. The joblib.load() call loads something and return a 
Python object into the symbol clf.

It would seem you need to look at the object that joblib.load is 
reconstituting. This code snippet doesn’t give enough information to diagnose 
this, but if I were you, I’d probably try this:

1. What file does "joblib.load(os.path.join(CLASSIFIERS_PATH, filter_name, 
classifier_name))” read, and what object does it return?

2. Can you interactively run this code in the Python interpreter? Does it run 
OK, or does it throw an exception?

3. If it works on your development machine, try running it interactively on 
your production machine. Ssh into your production server and run the code.

4. What does dir(clf) return? Does the clf object have the methods you expect 
it to have?


If you can get it to throw an exception when you run it from the interactive 
prompt, you can single-step it.

John


> On Apr 22, 2015, at 4:10 PM, Cristian Javier Martinez 
> <martinezcristianjav...@gmail.com> wrote:
> 
> Thanks for your reply John DeRosa but the question is about what is causing 
> the exception because I'm not using threads at all and the error says 
> "'Thread' object has no attribute '_children'". I'm catching the error and 
> printing it out before the return as you can see in the log.
> 
> El miércoles, 22 de abril de 2015, 19:13:55 (UTC-3), John DeRosa escribió:
> If you get an exception, the “except” clause will drop down into the “return” 
> statement, and classification_serializer will be referenced before it’s 
> assigned to. (Because it never was assigned to.)
> 
> John
> 
>> On Apr 22, 2015, at 2:36 PM, Cristian Javier Martinez 
>> <martinezcri...@gmail.com > wrote:
>> 
>> Hi! I'm using the django rest framework and successfully deployed an 
>> application in a production environment but I'm having an strange error 
>> related to threads when I call a method that performs a simple 
>> classification task (using a scikit learn classifier) and I have no idea 
>> what is causing the error. This is the method in views.py
>> 
>> @api_view(['GET', 'POST'])
>> def classify_item(request):
>> """
>> Classify item, or list classifications.
>> """
>> if request.method == 'GET':
>> items = Item.objects.all()
>> serializer = ItemSerializer(items, many=True)
>> return Response(serializer.data)
>> 
>> elif request.method == 'POST':
>> serializer = ItemSerializer(data=request.data['item'])
>> if serializer.is <http://serializer.is/>_valid():
>> try:
>> item = serializer.data
>> filter_name = request.data['filter']
>> 
>> 
>> # fix encoding
>> item_dict =  {}
>> for key in item:
>> value = item[key]
>> if isinstance(value, unicode):
>> value = value.encode('utf-8')
>> item_dict[key] = value
>> 
>> classifier_name = 
>> CLASSIFIER_NAME_BY_FILTER[filter_name]
>> 
>> logger.debug("retrieving the persisted 
>> classifier and classifing the item")
>> clf = 
>> joblib.load(os.path.join(CLASSIFIERS_PATH, filter_name, classifier_name))
>> 
>> logger.debug("predicting probabilities")
>> data = pd.DataFrame([item_dict])
>> 
>> logger.debug("scoring item")
>> score = clf.predict(data)[0][1]
>> 
>> logger.debug("score: {}".format(score))
>> 
>> 
>> # create and save classification
>> classification = 
>> Classification(classifier_name=classifier_name,score=score,item_id=item['_id'])
>> classification_serializer = 
>> ClassificationSerializer(classification)
>> #classification_serializer.save()
>> except Exception as e:
>> logger.error("Ocurrio un error al intentar 
>> parsear el item: {}".form

Re: Strange error in django

2015-04-22 Thread John DeRosa
If you get an exception, the “except” clause will drop down into the “return” 
statement, and classification_serializer will be referenced before it’s 
assigned to. (Because it never was assigned to.)

John

> On Apr 22, 2015, at 2:36 PM, Cristian Javier Martinez 
>  wrote:
> 
> Hi! I'm using the django rest framework and successfully deployed an 
> application in a production environment but I'm having an strange error 
> related to threads when I call a method that performs a simple classification 
> task (using a scikit learn classifier) and I have no idea what is causing the 
> error. This is the method in views.py
> 
> @api_view(['GET', 'POST'])
> def classify_item(request):
> """
> Classify item, or list classifications.
> """
> if request.method == 'GET':
> items = Item.objects.all()
> serializer = ItemSerializer(items, many=True)
> return Response(serializer.data)
> 
> elif request.method == 'POST':
> serializer = ItemSerializer(data=request.data['item'])
> if serializer.is_valid():
> try:
> item = serializer.data
> filter_name = request.data['filter']
> 
> 
> # fix encoding
> item_dict =  {}
> for key in item:
> value = item[key]
> if isinstance(value, unicode):
> value = value.encode('utf-8')
> item_dict[key] = value
> 
> classifier_name = 
> CLASSIFIER_NAME_BY_FILTER[filter_name]
> 
> logger.debug("retrieving the persisted 
> classifier and classifing the item")
> clf = 
> joblib.load(os.path.join(CLASSIFIERS_PATH, filter_name, classifier_name))
> 
> logger.debug("predicting probabilities")
> data = pd.DataFrame([item_dict])
> 
> logger.debug("scoring item")
> score = clf.predict(data)[0][1]
> 
> logger.debug("score: {}".format(score))
> 
> 
> # create and save classification
> classification = 
> Classification(classifier_name=classifier_name,score=score,item_id=item['_id'])
> classification_serializer = 
> ClassificationSerializer(classification)
> #classification_serializer.save()
> except Exception as e:
> logger.error("Ocurrio un error al intentar 
> parsear el item: {}".format(e))
> return Response(classification_serializer.data, 
> status=status.HTTP_201_CREATED)
> 
> return Response(serializer.errors, 
> status=status.HTTP_400_BAD_REQUEST)
> 
> And the output is:
> 
> [22/Apr/2015 21:14:56] DEBUG [classifiers.views:63] retrieve the classifier 
> for the given sited_id and classify item
> [22/Apr/2015 21:15:14] DEBUG [classifiers.views:66] predicting probabilities
> [22/Apr/2015 21:15:14] DEBUG [classifiers.views:69] scoring item
> [22/Apr/2015 21:15:14] ERROR [classifiers.views:80] Ocurrio un error al 
> intentar parsear el item: 'Thread' object has no attribute '_children'
> [22/Apr/2015 21:15:14] ERROR [django.request:256] Internal Server Error: 
> /items/
> Traceback (most recent call last):
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/django/core/handlers/base.py",
>  line 132, in get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/newrelic-2.50.0.39/newrelic/hooks/framework_django.py",
>  line 499, in wrapper
> return wrapped(*args, **kwargs)
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/django/views/decorators/csrf.py",
>  line 58, in wrapped_view
> return view_func(*args, **kwargs)
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/django/views/generic/base.py",
>  line 71, in view
> return self.dispatch(request, *args, **kwargs)
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/newrelic-2.50.0.39/newrelic/hooks/component_djangorestframework.py",
>  line 27, in _nr_wrapper_APIView_dispatch_
> return wrapped(*args, **kwargs)
>   File 
> "/home/keepcon/meli_filters_env/local/lib/python2.7/site-packages/rest_framework/views.py",
>  line 452, in dispatch
> response = self.handle_exception(exc)
>   File 
> 

Re: Django Celery throwing runtime warnings for naive times

2014-04-28 Thread John DeRosa
I suggest you file a ticket in the celery project 
(https://github.com/celery/celery/issues), or ask for help on the #celery IRC 
channel. (See 
http://celery.readthedocs.org/en/latest/getting-started/resources.html for 
"help" resources...) They'd be more profitable avenues for you, given the code 
path that's in the stack dump.

John

On Apr 28, 2014, at 3:33 AM, heidi  wrote:

> 
> 
> I run an online game with Django 1.6 and Celery 3.1.11. Kombu is 3.0.15.
> 
> Recently I had problems with Celery and DST, so I decided to run the whole 
> site on UTC and save myself the bother of worrying about timezones.
> 
> The relevant parts of my settings.py:
> 
> TIME_ZONE = 'UTC'
> USE_TZ = True
> 
> CELERY_ENABLE_UTC = True
> CELERY_TIMEZONE = 'UTC'
> 
> Now, whenever I send any delayed task, I see a bunch of RuntimeWarnings that 
> complain about naive datetimes. I went into my settings.py and turned this 
> into an exception, and this is the traceback that resulted:
> 
> [2014-04-18 15:03:49,748: INFO/MainProcess] Received task: 
> sometask[sometaskid] eta:[2014-04-19 00:33:32.410032+00:00]
> [2014-04-18 15:03:50,130: ERROR/MainProcess] Error in timer: 
> RuntimeWarning(u'DateTimeField TaskState.eta received a naive datetime 
> (2014-04-18 17:50:19.547046) while time zone support is active.',)
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 
> 171, in apply_entry
> entry()
>   File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 
> 64, in __call__
> return self.fun(*self.args, **self.kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/kombu/async/timer.py", line 
> 132, in _reschedules
> return fun(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", 
> line 73, in capture
> self.state.freeze_while(self.shutter, clear_after=self.clear_after)
>   File "/usr/local/lib/python2.7/dist-packages/celery/events/state.py", line 
> 421, in freeze_while
> return fun(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/celery/events/snapshot.py", 
> line 70, in shutter
> self.on_shutter(self.state)
>   File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 
> 145, in on_shutter
> _handle_tasks()
>   File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 
> 139, in _handle_tasks
> self.handle_task(task)
>   File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 
> 105, in handle_task
> task_id=uuid, defaults=defaults)
>   File "/usr/local/lib/python2.7/dist-packages/djcelery/snapshot.py", line 
> 128, in update_task
> obj.save()
>   File "/usr/local/lib/python2.7/dist-packages/djcelery/models.py", line 358, 
> in save
> super(TaskState, self).save(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 545, in save
> force_update=force_update, update_fields=update_fields)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 573, in save_base
> updated = self._save_table(raw, cls, force_insert, force_update, using, 
> update_fields)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 635, in _save_table
> forced_update)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 679, in _do_update
> return filtered._update(values) > 0
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
> line 507, in _update
> return query.get_compiler(self.db).execute_sql(None)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
> line 975, in execute_sql
> cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
> line 771, in execute_sql
> sql, params = self.as_sql()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
> line 940, in as_sql
> val = field.get_db_prep_save(val, connection=self.connection)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
> line 353, in get_db_prep_save
> prepared=False)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
> line 914, in get_db_prep_value
> value = self.get_prep_value(value)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", 
> line 906, in get_prep_value
> RuntimeWarning)
> RuntimeWarning: DateTimeField TaskState.eta received a naive datetime 
> (2014-04-18 17:50:19.547046) while time zone support is active.
> 
> 
> As you can see, none of the traceback is due to my code, so I do not know how 
> to proceed. I could merely leave the warnings in (if I recall correctly, 
> Celery defaults time offsets to the CELERY_TIMEZONE in settings.py, and this 
> is what I want anyway) but my OCD is screaming out at me to get this fixed. 
> Plus, I 

Re: Django

2014-04-19 Thread John DeRosa

On Apr 19, 2014, at 8:02 AM, Mark Phillips  wrote:

> "Two Scoops of Django" is also very good.
> 
> 

+1 for TSoD. Super book!

-- 
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/B5D083F9-F9D1-4C02-9517-C8AB1A569B7F%40ipstreet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread John DeRosa
Not sure what is going on without seeing the code. But something is None when 
it should be a string, as the exception is telling you.

It's often easiest to try out problem code interactively in Python, and zero in 
on the problem.

John


On Mar 26, 2014, at 3:53 PM, Anthony <lifesillus...@gmail.com> wrote:

> Thanks John,
> 
> I've yet to test it but I read a few people stating to use lambdas 
> variables/properties. Is it definitely the case that it will only evaluate 
> once?
> 
> Either way I've embarked on the mission to make methods return as properties 
> and have found @property decorator to fit my needs, the issue was I was 
> calling Object.property not ObjectI().property, However I want to apply this 
> functionality to all my methods and am using:
> 
> __getattribute__
> 
> def __getattribute__(self, item):
> super(DateCalc, self).__getattribute__(item)
> 
> But I've run into the problem that my __init__ properties don't seem to be 
> initialised eg I get
> self._date_actual = datetime.strptime("{Y}-{m}-{d}".format(Y=year, m=month, 
> d=day), self._format_global).date() TypeError: must be string, not None
> 
> Anyone have an idea about what's going on?
> 
> 
> On Thu, Mar 27, 2014 at 5:07 AM, John DeRosa <jo...@ipstreet.com> wrote:
> For the default value to work as you expect, do this:
> 
> def view(request, year=None):
> if year is None:
> year = today.year()
> 
> 
> Kwarg defaults are evaluated when the module is interpreted for the first 
> time.
> 
> John
> 
> 
> On Mar 26, 2014, at 1:57 PM, Anthony Hawkes <lifesillus...@gmail.com> wrote:
> 
>> Hi Guys,
>> 
>> I'm running into a problem with django(I guess this would also affect Python 
>> in general) where if I create a view eg
>> def view(year=today.year())
>> The year is never re-evaluated until the server is reloaded/restarted
>> 
>> I'm trying to figure out how to make a callable method accessible as a 
>> property if this is even possible to try and rectify this(not sure if this 
>> is even the correct approach). I've had a look at some magic methods but 
>> can't figure it out.
>> 
>> Basically I want to make eg
>> 
>> def year(something):
>> return 'blah'
>> 
>> Accessible using object.year as well as object.year()
>> 
>> Any pointers/ideas etc?
>> 
>> -- 
>> 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/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/gcx1oTBAZlA/unsubscribe.
> To unsubscribe from this group and all its topics, 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/FE30EAD3-E463-4379-B11C-970D86703AC3%40ipstreet.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> -- 
> Anthony Hawkes
> E-Mail: lifesillus...@gmail.com
> Ph: 0400 372 260
> 
> -- 
> 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/CABqJoT1rSB4YeHQHiZH_4KNqMuub1THHyuzAvOCjas_Drz94sg%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/7BECE858-26BB-402C-A5DA-5A613F14FE1F%40ipstreet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making functions callable

2014-03-26 Thread John DeRosa
For the default value to work as you expect, do this:

def view(request, year=None):
if year is None:
year = today.year()


Kwarg defaults are evaluated when the module is interpreted for the first time.

John


On Mar 26, 2014, at 1:57 PM, Anthony Hawkes  wrote:

> Hi Guys,
> 
> I'm running into a problem with django(I guess this would also affect Python 
> in general) where if I create a view eg
> def view(year=today.year())
> The year is never re-evaluated until the server is reloaded/restarted
> 
> I'm trying to figure out how to make a callable method accessible as a 
> property if this is even possible to try and rectify this(not sure if this is 
> even the correct approach). I've had a look at some magic methods but can't 
> figure it out.
> 
> Basically I want to make eg
> 
> def year(something):
> return 'blah'
> 
> Accessible using object.year as well as object.year()
> 
> Any pointers/ideas etc?
> 
> -- 
> 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/e7adace8-ffc9-4f77-b970-e73bed5ae8e1%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/FE30EAD3-E463-4379-B11C-970D86703AC3%40ipstreet.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres and backup/restore

2014-02-06 Thread John DeRosa
pg_dump is all you need, if your db is small enough. It generates a consistent 
backup.

pg_dump, zip, stash it in a cloud container named "backup" is what we do.

John

On Feb 6, 2014, at 3:07 PM, Lachlan Musicman  wrote:

> Hola,
> 
> What are people's recommendations for postgres db backup solutions?
> 
> I've just installed django-dbbackup and will give it a try, but
> thought I'd ask what others were using.
> 
> cheers
> L.
> 
> 
> 
> 
> 
> -- 
> From this perspective it is natural that anarchism be marked by
> spontaneity, differentiation, and experimentation that it be marked by
> an expressed affinity with chaos, if chaos is understood to be what
> lies outside or beyond the dominant game or system. Because of the
> resistance to definition and categorisation, the anarchist principle
> has been variously interpreted as, rather than an articulated
> position, "a moral attitude, an emotional climate, or even a mood".
> This mood hangs in dramatic tension between utopian hope or dystopian
> nihilism...
> -
> http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos
> 
> -- 
> 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/CAGBeqiMREb74W8jX-5wTFL4Btg7C4NYC6fipL%2B%3DXB91nqD7xKg%40mail.gmail.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/507345A1-916B-4DC8-8233-6073CB64F184%40ipstreet.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Presentation ideas?

2014-01-17 Thread John DeRosa
I’m glad Russ answered too. I was thinking only about tutorials, but neglected 
to explain that. Not that it was hard to figure out, I supposed.

On Jan 16, 2014, at 8:56 PM, Keith Edmiston  wrote:

> John/Russ,
> 
> Thanks a ton for these suggestions. Great thoughts!
> 
> Keith
> 

-- 
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/E18E4296-C681-46F6-8B06-515D901A091F%40ipstreet.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Presentation ideas?

2014-01-16 Thread John DeRosa
You can survey technologies you don’t use in your daily work.
You can explore alternative technologies for your current job.
You can learn new details about technologies you know, in intermediate or 
advanced tutorials.
You can learn in-depth, because you’re in a session for 3 hours, vs. 45 minutes.
You can more easily network, because tutorials are less frenetic than the 
full-conference madhouse.


John

On Jan 16, 2014, at 2:25 PM, Keith Edmiston  wrote:

> I'm scheduled to give a talk/presentation to my colleagues on why attending 
> tutorials and sprints at a conference is a great idea (I attended 
> DjangoConUS2013). 
> 
> Any ideas/thoughts much appreciated. 
> 
> ---
> 
> Conference Tutorials and Sprints…what are they all about?
> 
> "Often we attend technical conferences, but wonder what the tutorials 
> beforehand and sprints afterwards really offer. This session will provide 
> some insight to that dark world of give and take."
> 
> 
> -- 
> Keith Edmiston
> (512)970-7222
> 
> -- 
> 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/CAP_gv7LC_owxKuigT_hbVd5mjruCm7AUKMqBHq6y1P0uP%2BdaKw%40mail.gmail.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/73858338-D0B1-4736-84B0-6416D2ACBCED%40ipstreet.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fabric for dependency management, testing strategy

2013-11-11 Thread John DeRosa
Agree with Avraham. Some other considerations:

I use Linux package managers (e.g., apt-get on Debian) for non-critical 
technology. This usually (but not always) means all non-Python technology, plus 
Python technology that we don’t push to its limits.

But, OTOH, at least in Ubuntu, it can sometimes be a hassle to locate the 
Ubuntu package containing the Python package I want to install. OTTH, it *is* 
quite nice to let apt-get to take care of all the dependencies, and install the 
big technologies (e.g., postgres). 

When using pip, make sure you lock your versions in your dependency file. 
(e.g., celery==3.0.1) BUT don’t blindly trust it. I’ve had instances where I 
asked for version x and pip installed a different version and my life turned 
into hell for half a day. I partly blame pip (if I ask for version 3.0.1, then 
I want 3.0.1 dammit, and if you can’t install 3.0.1 then you should throw an 
exception!) and partly blame lazy package maintainers who assert that, e.g., 
3.0.4 is a drop in replacement for 3.0.1 when in fact it is not.

Our systems are smallish (~ 25 nodes or so) and I find managing them with 
fabric is satisfactory. I have fabric tasks for updating nodes, provisioning 
new nodes, etc., and it works for me. But I have been thinking about adding 
Ansible to the mix. YMMV.

John


On Nov 11, 2013, at 6:47 AM, Avraham Serour  wrote:

> for dependency management you should use pip, first step is to go through the 
> docs for fabric (and pip)
> also you should google for best practices
> 
> 
> On Mon, Nov 11, 2013 at 4:40 PM, Kannan  wrote:
> Hi Guys, 
> I am new to Fabric. Please send me  your thoughts of using Fabric for 
> dependency management and also about the testing strategy. 
> 
> 
> Additionally, Please send me tutorials or links or something that can start 
> with.
> 
> 
> 
> 
> With regards, 
> Kannan
> 
> 
> -- 
> 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/CAL4xV_B_vxCBop5AgEjcyCzj6RiPHVW3cV0PxfgDEuRHzM3ifQ%40mail.gmail.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/CAFWa6tLB9FOhVrVvr7ydAkojmPTp8s_20%2BFO1N22cTnLXJcW_A%40mail.gmail.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/CD172942-461A-4B7E-AD84-52AF60A4AB70%40ipstreet.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django-celery connects to localhost but not by ip

2013-09-20 Thread John DeRosa
Nope… Good luck!

On Sep 19, 2013, at 9:23 PM, Chad Vernon <chadver...@gmail.com> wrote:

> Thanks, I found the issue after checking the logs.
> 
> I saw in the log that it listed the AMQP connection that it accepts:
> 
> =INFO REPORT 19-Sep-2013::20:52:57 ===
> accepting AMQP connection <0.403.0> (127.0.0.1:59930 -> 127.0.0.1:5672)
> 
> So if that is stating the obvious, I assumed it was blocking all other ips.  
> So I found this page 
> http://superuser.com/questions/464311/open-port-5672-tcp-for-access-to-rabbitmq-on-mac
> and removed NODE_IP_ADDRESS from rabbitmq-env.conf and that seems to work.  
> But I guess my first assumption was incorrect about what the log displayed 
> because when I run the command again, the log just says my machine connected 
> and displays the port range of that ip address.
> 
> However, one issue that still is strange is that the ASyncResult returned 
> from the task always seems to return False from the .ready() method even 
> though it seems to have completed the task.  Any ideas on that?
> 
> 
> On Thursday, September 19, 2013 7:36:41 PM UTC-7, John DeRosa (work) wrote:
> First things to check:
> 
> Check the firewall on the RabbitMQ server. Can you access that server?
> 
> Did you set up the vhost and account on the RabbitMQ server?
> 
> Look in the RabbitMQ logs. Did the request make it to RabbitMQ?
> 
> John
> 
> On Sep 19, 2013, at 7:34 PM, Chad Vernon <chadv...@gmail.com> wrote:
> 
>> I am using djcelery and rabbitmq.  Everything runs fine when the BROKER_HOST 
>> is localhost but when I change it to the ip of the machine it no longer 
>> runs.  
>> 
>> Basically I am trying to be able to run python commands on a separate 
>> machine to be picked up by the RabbitMQ server on a different machine.  But 
>> to test first I am doing it all on the same machine.  But as I said it 
>> doesn't seem to work when I change from localhost to the machine ip. I just 
>> get socket.error: [Errno 61] Connection refused.
>> 
>> Any ideas?
>> 
>> Thanks,
>> Chad 
>> 
>> -- 
>> 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...@googlegroups.com.
>> To post to this group, send email to django...@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.

-- 
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-celery connects to localhost but not by ip

2013-09-19 Thread John DeRosa
First things to check:

Check the firewall on the RabbitMQ server. Can you access that server?

Did you set up the vhost and account on the RabbitMQ server?

Look in the RabbitMQ logs. Did the request make it to RabbitMQ?

John

On Sep 19, 2013, at 7:34 PM, Chad Vernon  wrote:

> I am using djcelery and rabbitmq.  Everything runs fine when the BROKER_HOST 
> is localhost but when I change it to the ip of the machine it no longer runs. 
>  
> 
> Basically I am trying to be able to run python commands on a separate machine 
> to be picked up by the RabbitMQ server on a different machine.  But to test 
> first I am doing it all on the same machine.  But as I said it doesn't seem 
> to work when I change from localhost to the machine ip. I just get 
> socket.error: [Errno 61] Connection refused.
> 
> Any ideas?
> 
> Thanks,
> Chad 
> 
> -- 
> 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: m2m_changed signal not caught

2013-09-17 Thread John DeRosa
>From memory, I _think_ this catches the signal from the Department model, not 
>the News model. To catch it when you edit the relationship from a *News* model 
>form, you need to hook it up ("sender=News.department.through"). 

On Sep 17, 2013, at 3:59 AM, Roberto López López  wrote:

> 
> Hi,
> 
> I need to use the m2m_changed signal to assign permissions over an object. 
> But somehow, I cannot make it work.
> 
> To summarise, my models.py is as follows:
> 
> from cmsplugin_news.models import News
> from django.contrib.auth.models import Group
> from django.db import models
> from guardian.shortcuts import assign_perm, remove_perm
> 
> 
> class Department(models.Model):
> news = models.ManyToManyField(
> News, blank=True, related_name='departments'
> )
> write_group = models.ForeignKey(Group, blank=True)
> 
> 
> @receiver(m2m_changed, sender=Department.news.through)
> def _m2m_changed_news_departments(sender, instance, action, reverse, model, 
> pk_set, **kwargs):
> if action == "pre_add":
> for pk in pk_set:
> d = Department.objects.get(pk__exact=pk)
> assign_perm('cmsplugin_news.change_news', d.write_group, instance)
> assign_perm('cmsplugin_news.delete_news', d.write_group, instance)
> elif action == "pre_remove":
> for pk in pk_set:
> d = Department.objects.get(pk__exact=pk)
> remove_perm('cmsplugin_news.change_news', d.write_group, instance)
> remove_perm('cmsplugin_news.delete_news', d.write_group, instance)
> 
> The point is that the signal is never caught. I am editing the m2m relation 
> from the admin interface (as an inline in cmsplugin_news). When I 
> add/delete a department from the formset, the signal is never caught by my 
> method.
> 
> Any help here? Thank you very much.
> 
> Roberto
> 
> 
> 
> -- 
> 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: User Permissions

2013-07-30 Thread John DeRosa
Take a look at django-guardian. (http://pythonhosted.org/django-guardian/)

John

On Jul 30, 2013, at 12:39 PM, Carlos Leite  wrote:

> Django do not have a "per-row" permission system in the box.
> You will have to create that by yourself.
> 
> You may start adding something like "owner" to your content type.
> this field will be somthing like
> 
>  owner = models.ForeignKey(User)
> 
> then, based on "request.user" in your views (for instance),
> you may filter objects using .objects.filter(owner=requet.user)
> 
> hope that helps.
> 
> 
> 
> On Tue, Jul 30, 2013 at 12:39 PM,   wrote:
>> Hi All,
>> 
>> I have a very simple django site.
>> The site allows the administrator to create a model which contains 5 text
>> items and then stores that to the sqlite database.
>> I have also created a user login page from a tutorial on youtube.
>> I want to be able to control which model the logged in user has access to.
>> For instance I want user "John" to be able to see logged model entries 1-5
>> and not 6-7.
>> Is this simple? How should I go about setting permissions?
>> 
>> Any help is appreciated. If you would like specific code please ask.
>> 
>> 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.
>> 
>> 
> 
> 
> 
> -- 
> 
> Cadu Leite
> twitter: @cadu_leite
> http://people.python.org.br/
> 
> -- 
> 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: autogenerating SECRET_KEY every time the server runs

2013-06-20 Thread John DeRosa
When we run the development server locally, we often start with an 
already-existing database. We don't re-initialize the db unless we have to, 
because there's been a schema change or a change in the value stored in a 
table's field.

So we'd need SECRET_KEY to not change most of the time!

John

On Jun 20, 2013, at 8:29 AM, Michael Cetrulo  wrote:

> considering that the SECRET_KEY is automatically generated every time a new 
> project is created [1], wouldn't make more sense to have this logic on 
> settings.py and generate a new value when loading the app instead of saving 
> it as an actual hardcoded value there? eg:
> 
> #settings.py
> from django.utils.crypto import get_random_string
> chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
> SECRET_KEY = get_random_string(50, chars)
> 
> is there any problems I'm not considering here? thanks.
> 
> [1] 
> https://github.com/django/django/blob/master/django/core/management/commands/startproject.py
> 
> -- 
> 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: Understanding Django transactions

2013-05-21 Thread John DeRosa
Regardless of whatever comments and corrections may come, I thank you for 
summarizing what you think the changes will be! I didn't know about these 
impending changes.

John

On May 21, 2013, at 4:23 AM, Michael  wrote:

> 
> I've been reading up on how transactions work in Django 1.5 and how they will 
> work in 1.6. I think I have a grasp of things, but I wanted to reach out on 
> here to just check that my understanding of things is correct, and ask a 
> question or two.
> 
> Django 1.5:
> 
> The database-level auto-commit is turned OFF.
> SQL standards dictate that every query opens a transaction if one does not 
> already exist. This happens regardless of the database's auto-commit setting.
> After each Django ORM operation (read or write), Django commits this open 
> transaction. This emulates the database-level auto-commit.
> Transaction decorators cannot be nested. When one is opened, any previous 
> transaction will be committed.
> When executing raw SQL (with a database cursor), Django marks the current 
> transaction as dirty but does not issue a commit. If data changes were made 
> then they need manually committing. Why do the docs say that you only need to 
> commit the change if data was changed? If the transaction is marked as dirty 
> regardless of a read or a write, would it not always need committing or 
> rolling back to ensure the transaction is properly closed by the end of the 
> connection?
> Setting TRANSACTIONS_MANAGED to True stops Django from sending any commits 
> after ORM operations. The database-level auto-commit is still disabled. With 
> this setting, using any Django ORM read or write operation (all wrapped in 
> `transaction.commit_on_success`) fails with TransactionManagementError('This 
> code isn't under transaction management'). Is this expected?
> Django 1.6:
> 
> The database-level auto-commit is turned ON.
> Every database operation via the ORM will be committed using the database's 
> auto-commit, including any custom SQL executed with the database cursor.
> The `atomic` decorator / context manager either starts a new transaction, or 
> creates a new savepoint if it's nested within an existing transaction. They 
> are committed as long as no exception is raised.
> If ATOMIC_REQUESTS is specified in the database config, all views are wrapped 
> in `atomic`, unless it's wrapped in `non_atomic_requests`.
> If you set AUTOCOMMIT to False in a database configuration, this will disable 
> the database-level auto-commit. All DB reads and writes will need manually 
> wrapping in transactions. The docs say that with this disabled, Django won't 
> perform any commits. Does this mean that the `atomic` decorator won't work 
> properly and you have to use the underlying database library to handle 
> transactions? In 1.6 it would appear that Django never performs a commit 
> outside of `atomic`, so I'm confused by this comment!
> I'd really appreciate any information if some of what I understand to be true 
> is not accurate.
> 
> Many 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?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: [SPAM] Implementing User login expiration

2013-04-08 Thread John DeRosa
On Apr 5, 2013, at 5:33 PM, Nikolas Stevenson-Molnar  
wrote:

> How about creating request middleware to sign out deactivated users?
> Something like:
> 
> if request.user.profile.expired:
>logout(request)
> 
> If you're concerned about the extra database hit per request, then maybe
> cache the expiration?
> 
> expire_date = cache.get("%d_expire" % request.user.id)
> if not expire_date:
>expire_date = request.user.profile.expire_date
>cache.set(...)
> if expire date < now()
>logout(request)
> 
> _Nik

Great idea! Thank you!

John

-- 
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.




Implementing User login expiration

2013-04-05 Thread John DeRosa
I have a Profile table that's 1:1 with the User table. Each Profile row has 
an account_expiration field.

I want to invalidate users when their accounts expire. By "invalidate", I 
mean: They can't log in, and they can't use the system any more.

The closer I look, the more complicated it seems.

Adding an expiration date check to our authentication backend is the easy 
part. The hard part is what to do about users who are currently logged in? 
They have Session objects in the database, and the session cache. (We 
use django.contrib.sessions.backends.cached_db.) I could make a periodic 
task that deletes the session objects of expired accounts, but it would 
also have to find the expired objects in the cache. This starts to feel 
unwieldy and fragile.

I could crank down SESSION_COOKIE_AGE to one hour, but that would be ugly.

I'm wondering if I'm over-thinking this. Has anyone implemented account 
expiration in a way that deals with users already logged in?

Thanks!

John

-- 
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: background task without celery

2012-12-10 Thread John DeRosa
On Dec 10, 2012, at 9:44 AM, leonardo  wrote:

> Hi,
> 
> I'm deploying a project to validation purpose in Heroku and not worth paying 
> for a worker to execute background task.
> Is there a way to execute background task without celery + rabbitmq ?
> 

I investigated alternatives to Celery, and came up with a handful of worthy 
alternatives. See my blog posts at 
http://seeknuance.com/2012/08/09/my-requirements-for-replacing-celery/ and 
http://seeknuance.com/2012/08/14/alternatives-to-using-celery/, they might help 
your search.

John

-- 
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: How many developers have moved to class-based views?

2012-11-12 Thread John DeRosa
On Nov 11, 2012, at 9:57 AM, Kevin  wrote:

> Hello!
> 
>   I am curious of how many existing Django developers have moved over to 
> class-based views or are still using the function-based ones.  I tend to use 
> a mix depending on what I am trying to do.  I try to stick with 

I use only function-based views. I've yet to read a compelling argument for 
switching.

-- 
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: Help me choose OS for django server

2012-10-30 Thread John DeRosa
+2 for fail2ban.

I love reviewing fail2ban's email, and seeing the script kiddies continuing to 
try to login to root. Which is login-disabled on all our servers. Keep trying, 
kids...

John

On Oct 30, 2012, at 4:38 PM, Fred Stluka  wrote:

> +1 for fail2ban
> 
> It's surprising that a 3-year attack eventually succeeded if you
> had fail2ban installed, which should have blocked the attack after
> just a couple tries.  Or had you not yet learned about fail2ban?
> I got hacked once too, before I learned about fail2ban.  Never 
> since.
> 
> --Fred 


-- 
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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread John DeRosa
Nope, I didn't find a solution. I moved on to another issue and never got back 
to this. We just learned to work around this, I'm semi-ashamed to say.

John

On Oct 23, 2012, at 2:29 PM, Alphydan <alphy...@gmail.com> wrote:

> I have the same problem (on ubuntu, python 2.7, django 1.4, 
> django-picklefield 0.2.1) ... does anybody have any insight?
> John, did you find a solution?
> 
> Thank you. 
> 
> On Thursday, 8 April 2010 19:30:20 UTC+1, John DeRosa wrote:
> Hello Djangonauts,
> 
> I'm doing something wrong, but I just can't see it!
> 
> My problem is that a custom model field isn't being displayed in the Admin 
> interface.
> 
> I'm running OS X 10.6.3, Python 2.6, and Django 1.1.1. I installed 
> django-picklefield 0.1.5 from PyPi, and I'm trying to use it in a database 
> model. I defined a couple of custom PickledObjectField fields. They show up 
> in the Admin model docs as being of type "Text", but they *don't* show up in 
> the Admin when I add or change a row.
> 
> Here's what I'm doing. What am I doing wrong?
> 
> John
> 
> --
> 
> In models.py:
> 
> from picklefield.fields import PickledObjectField
> 
> class LayoutTemplate(models.Model):
> [snip]
> attachment_points = PickledObjectField(help_text="A list of 
> TemplateAttachmentPoints")
> placed_objects = PickledObjectField(blank=True,
> help_text="A list of objects placed 
> on this template")
> # These LayoutObjects are allowed on this template.
> allowed_objects = PickledObjectField(help_text="A list of allowed 
> objects.")
> 
> def __unicode__(self):
> return u"%s" % self.name
> 
> 
> In admin.py:
> 
> from hosted.models import LayoutTemplate
> from django.contrib import admin
> admin.site.register(LayoutTemplate)
> 
> 
> 
> 
> -- 
> 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/-/QHA-yQ1spEIJ.
> 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: Background Programs in Django

2012-09-26 Thread John DeRosa
There are a number of technologies out there for background asynchronous tasks 
in Python. They differ on attributes such as how the tasks are managed and 
administered; the run queues' sophistication (how many, how they're divvied up, 
whether they can be pinned to servers, etc.), whether the tasks can be 
distributed to multiple servers; etc.

The best-known is probably Celery (http://celeryproject.org). Many features. 
There are other tools, which are simpler and may be better suited for your 
task. Here's a shameless plug, I'm considering switching from Celery, so I made 
a list of the alternatives I was considering. My experiences and criteria are 
not yours, but, this blog post might be a good place from which to start your 
research: http://seeknuance.com/2012/08/14/alternatives-to-using-celery/.

John

On Sep 26, 2012, at 5:07 AM, surya  wrote:

> I have to use RSS/ Atom feeds of blogs in my Django app. So, I thought to use 
> Google Feed API. All the API provides is a BIG list of feeds..
> 
> If I need a post (say no 25), I need to GET the whole feeds and search every 
> time which is redundant. So, I am thinking to run a background program which 
> periodically performs GET and updates the feeds as a JSON file. Now, I can at 
> least do some work efficiently!
> 
> If anyone got a better idea, please do tell me.
> 
> Can anyone tell me how to do that? It should be in sync with requests I 
> perform on the JSON file in 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/-/KOAA_d2eaFgJ.
> 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: how to use HTTPS with django

2012-07-06 Thread John DeRosa
On Jul 6, 2012, at 4:24 AM, Melvyn Sopacua wrote:

> On 6-7-2012 8:08, heni yemun wrote:
> 
>> I want to know how to use HTTPS to securely login and signup a user with 
>> django.
> 
> Django doesn't care about HTTPS. You'd handle this in the webserver by
> redirecting to the secure virtual host for the login url. How to
> implement that is webserver specific.

One of the many ways to handle this is to terminate SSL/TLS in the load 
balancer, and have the balancer send all requests as HTTP to the web servers 
running Django (and httpd or whathaveyou) behind it.

John

-- 
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: Macs are great for Django development!

2012-04-20 Thread John DeRosa
On Apr 20, 2012, at 8:39 AM, creecode wrote:

> Hello Houman,
> 
> On Friday, April 20, 2012 5:58:34 AM UTC-7, Houmie wrote:
>  
> 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?
> 
> Macs are great for Django development!  You may have to do a bit more work to 
> get some libraries installed as sometimes they aren't specifically tuned for 
> Macs.  Any modern Mac should be just fine for development.  Heck even ancient 
> Macs (PPC based) can be used albeit slower and somewhat harder to configure, 
> not the OS but again some of the libraries you might install.

+1. Our dev environment is all MacBook Pro laptops. The oldest one is a 
2010-vintage machine. They're a great dev environment.

John

-- 
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: reverse() with keyword argument driving me batty

2012-01-12 Thread John DeRosa
On Jan 12, 2012, at 10:18 AM, Andy McKay wrote:

> On Thu, Jan 12, 2012 at 9:50 AM, John DeRosa <jo...@ipstreet.com> wrote:
>>   url(r'^results/text/(?P)/$', 'textresults', 
>> name='exporttextresults')
> 
> One guess, you haven't specified what the (?P in your regex accepts.
> For example:
> (?P\w+)
> 

Gah! I am an imbecile! Now I know why Mozilla never hired me!

Thanks!!!

John

-- 
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.



reverse() with keyword argument driving me batty

2012-01-12 Thread John DeRosa
Hi all,

I'm running Django 1.3, and I can't get a simple reverse() with keywords to 
work.

My urlconf has this:

   url(r'^results/text/(?P)/$', 'textresults', 
name='exporttextresults')

My code does this:

   exporturl = reverse("exporttextresults", kwargs={"jobkey": returned_key})

And I get this error:

   *** NoReverseMatch: Reverse for 'exporttextresults' with arguments '()' 
and keyword arguments '{'jobkey': 
'40756766e8de9e0994536cf11773267d469c3a4ed77da53e89b8bc1de6c9'}' not found.


What's the right calling sequence for a reverse to an URL with a keyword 
argument?

Thanks,

John

-- 
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: auto_now, auto_now add -- good or bad?

2011-07-15 Thread John DeRosa
On Jul 15, 2011, at 9:22 AM, Shawn Milochik wrote:

> Considering these facts, I'm wondering what the consensus is in the community:
> 
>A. They're still there because they're too annoying to deprecate
> or just not important enough to spend time on.
> 
>B. They're useful shortcuts and their use is preferable to manual
> replacements.
> 
> 
> [1] 
> http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/
> [2] https://code.djangoproject.com/ticket/1056
> 

I use them. So, B. I'm not crazy about their names, however.

-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-23 Thread John DeRosa
Me

On Jun 23, 2011, at 7:49, Chris Calitz  wrote:

> Sounds really cool. I'm definitely in. 
> 
> On 22 Jun 2011, at 14:16, "Cal Leeming [Simplicity Media Ltd]" 
>  wrote:
> 
>> Hi all,
>> 
>> Some of you may have noticed, in the last few months I've done quite a few 
>> posts/snippets about handling large data sets in Django. At the end of this 
>> month (after what seems like a lifetime of trial and error), we're finally 
>> going to be releasing a new site which holds around 40mil+ rows of data, 
>> grows by about 300-500k rows each day, handles 5GB of uploads per day, and 
>> can handle around 1024 requests per second on stress test on a moderately 
>> spec'd server.
>> 
>> As the entire thing is written in Django (and a bunch of other open source 
>> products), I'd really like to give something back to the community. (stack 
>> incls Celery/RabbitMQ/Sphinx SE/PYQuery/Percona 
>> MySQL/NGINX/supervisord/debian etc)
>> 
>> Therefore, I'd like to see if there would be any interest in webcast in 
>> which I would explain how we handle such large amounts of data, the trial 
>> and error processes we went through, some really neat tricks we've done to 
>> avoid bottlenecks, our own approach to smart content filtering, and some of 
>> the valuable lessons we have learned. The webcast would be completely free 
>> of charge, last a couple of hours (with a short break) and anyone can 
>> attend. I'd also offer up a Q session at the end.
>> 
>> If you're interested, please reply on-list so others can see.
>> 
>> Thanks
>> 
>> 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.
> -- 
> 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.



Displaying a custom field (PickledObjectField) in the admin

2010-04-08 Thread John DeRosa
Hello Djangonauts,

I'm doing something wrong, but I just can't see it!

My problem is that a custom model field isn't being displayed in the Admin 
interface.

I'm running OS X 10.6.3, Python 2.6, and Django 1.1.1. I installed 
django-picklefield 0.1.5 from PyPi, and I'm trying to use it in a database 
model. I defined a couple of custom PickledObjectField fields. They show up in 
the Admin model docs as being of type "Text", but they *don't* show up in the 
Admin when I add or change a row.

Here's what I'm doing. What am I doing wrong?

John

--

In models.py:

from picklefield.fields import PickledObjectField

class LayoutTemplate(models.Model):
[snip]
attachment_points = PickledObjectField(help_text="A list of 
TemplateAttachmentPoints")
placed_objects = PickledObjectField(blank=True,
help_text="A list of objects placed on 
this template")
# These LayoutObjects are allowed on this template.
allowed_objects = PickledObjectField(help_text="A list of allowed objects.")

def __unicode__(self):
return u"%s" % self.name


In admin.py:

from hosted.models import LayoutTemplate
from django.contrib import admin
admin.site.register(LayoutTemplate)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Flat file application for binary data?

2010-02-06 Thread John DeRosa

On Feb 5, 2010, at 1:27 PM, Peter Herndon wrote:

> FileFields and ImageFields are by default stored on disk, with just a pointer 
> stored in the db.  For more examples, take a look at David Larlet's 
> django-storages (http://code.welldev.org/django-storages/wiki/Home) and 
> Justin Driscoll's ImageKit 
> (http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home), both of which 
> should give you at least a starting point.  With ImageKit, for example, you 
> create a "spec" for your image fields, and part of the spec is a means of 
> determining the filesystem storage location (including a method you can 
> define if you need to).
> 

Looking at the django-storages code gave me some useful ideas. Thanks, Peter.

John

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Flat file application for binary data?

2010-02-06 Thread John DeRosa
On Feb 5, 2010, at 12:36 PM, Mike Ramirez wrote:

> It's built in.  
> 
> http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
> 
> http://docs.djangoproject.com/en/dev/ref/files/storage/
> 
> Between those two docs, you should be able to do everything you want.  AFAIK, 
> no file uploads are stored directly in the database, though there is a model 
> behind it, it stores the path,.
> 

I know about those, and they don't do what I'm looking for. At least, not as I 
understand them.

I'm looking at the next architectural level up. For example, creating an md5 or 
sha1 hash directory under a file root, where file uploads can be organized in 
/mm/dd folders. And providing the linkage from the user account in the SQL 
db, to their binary file directory.

I was hoping someone else had packaged this kind of support for 
binary-objects-stored-in-files in a nice and purty application. :-)

I'll chew on this more. Maybe a custom storage system backend is the way to go. 
(http://tinyurl.com/yjh7st4) 

John

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Flat file application for binary data?

2010-02-05 Thread John DeRosa
I'm building a site that will include using lots of image files, audio clips, 
and video clips. Including users uploading these things and then later 
referencing them.

I don't want to store this binary data in the database, but instead want to 
store them in disk files.

I've looked for a Django app that manages flat files, and can't find one. By 
"manage," I mean functions like organizing the directory into a year/mo/date 
(for example) structure, returning filenames for new data to be recorded into a 
database table, and returning the binary data given a link. This stuff isn't 
rocket science, but I'd rather not code it from scratch.

Anybody know of an suitable application for this?

Thank you in advance,

John

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ForeignKey related bug

2008-01-29 Thread John DeRosa

Chirayu Patel wrote:
> Hi,
> 
> While building a blog type application, I seem to have stumbled upon a
> bug. In a nut shell all object attributes have become read only when I 
> fetch the object from a query set which is fetched using the xxx_set() 
> API.
> 
> Please see the pdb trace for details. I have added comments to depict
> the erroneous logs. (pdb was started from within a unit test). I do 
> get similar behavior when using the shell.
> 
> Any suggestions for debugging this one?

This may not be all of your problem, but pdb had a bug (at least Python 
2.4, maybe it's gone in 2.5) wherein setting a variable at a breakpoint 
worked if and only if you didn't reexamine it after setting it.  E.g., 
this worked:

(Pdb) foobar = "dfdf"
(Pdb) c

But this did not:

(Pdb) foobar = "dfdf"
(Pdb) foobar
'old value'
(Pdb) c


There used to be a post on someone's blog about this, but darned if I 
can find it now.

John

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django under 2.5

2007-08-29 Thread John DeRosa

ditto

Kevin Menard wrote:
> On 8/28/07, Alvaro Mouriño <[EMAIL PROTECTED]> wrote:
>> Hi list,
>>
>> I have been running django under python 2.4 but now I'm considering
>> switching to 2.5. Are there any known compatibility issues? Or is it
>> just straightforward?
> 
> I've been running under 2.5 without any problems.  The same codebase
> works under 2.4 as well.
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is cloning Facebook in Django feasible?

2007-07-27 Thread John DeRosa

Ick!  Why would you want to?  Isn't one facebook in the world enough? :-)

[EMAIL PROTECTED] wrote:
> Is it possible to develop a Facebook functional clone in Django? What
> parts of it are provided out of the box? Any third-party contributions?
> 
> 
> > 
> 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: KeyError when using blocktrans

2007-06-20 Thread John DeRosa

Malcolm Tredinnick wrote:
> This is by design. It is much easier for translators if they only have
> to move small fragments of "replaced text" around, since it has to be
> done without error. So, if a translator needs to put {{itemAuthor}} in
> another position in the line, it's fairly easy to do. However, if they
> need to move a much longer fragment -- say, {{ item.author|urlizetrunc|
> escape }} -- there's now a huge block of text that they have to copy or
> retype precisely, despite it having no intrinsic meaning for the
> translation.
> 
> So, in blocktrans tags, only simple variable references are permitted
> and any aliases should be put as tag arguments. I'm not sure why this
> worked before 0.96 -- my recollection is that it has always worked as it
> does now. In any case, the current behaviour is intended.
> 
> Regards,
> Malcolm
> 

Thanks for the explanation!

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: KeyError when using blocktrans

2007-06-19 Thread John DeRosa

[EMAIL PROTECTED] wrote:
> With the latest version of Django from SVN, it appears you can no
> longer use sub-attributes of a template variable within a blocktrans
> tag.  For instance, the following will give you a KeyError:
> 
> {% blocktrans %}by {{ item.author }} at{% endblocktrans %}
> 
> However, the following works just fine:
> 
> {% blocktrans with item.author as itemAuthor %}by {{ itemAuthor }} at{%
> endblocktrans %}
> 
> Bug?  By design?  Misconfiguration?
> 
> Stack trace of the error is
> 
> Traceback (most recent call last):
> File "c:\python24\lib\site-packages\django\template\__init__.py" in
> render_node
>   712. result = node.render(context)
> File "C:\Python24\lib\site-packages\django\templatetags\i18n.py" in
> render
>   73. result = translation.gettext(singular) % context
> File "c:\python24\lib\site-packages\django\template\context.py" in
> __getitem__
>   40. raise KeyError(key)
> 
>   KeyError at /planet/
>   'item.author'

We just ran into this on our site, which is running on 0.96.  I searched 
around in the Django tickets and changesets, and couldn't find a 
reference to this.

Is this an intended part of the I18N design?

Or, should a ticket be filed?  (Or, is a ticket already filed and I 
missed it?)

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sitemap questions (probably dumb ones)

2007-06-15 Thread John DeRosa

David Larlet wrote:
> 2007/6/13, John DeRosa <[EMAIL PROTECTED]>:
>> David Larlet wrote:
>>> 2006/12/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>>>> I've been playing with the sitemap stuff and am finding it to be quite
>>>> slick. I do, however, have some questions about some unusual cases.
>>>>
>>>> 1)It works beautifully for listing all the detail pages that make up a
>>>> list view, but what about the page that takes the list view? In my
>>>> case, For example, I've got all my guitar pages in there, but not the
>>>> "guitars" page itself.
>> An list of objects returned in a sitemap can be for any page on your
>> site.  The object will have an URL associated with it, as well as a
>> frequency of change and priority, etc.  So you can make a list of
>> objects that are entirely arbitrary, and as long as the URL returned for
>> each object corresponds to a page on your site (i.e., as long as the URL
>> returns a page on an HttpGet), everything works as you'd expect.
>>
> Is it possible that you just paste an example? Because I've tried with
> a DummyModel with a get_absolute_url function and it doesn't work...

Ah, that's your problem!  You need to define the method location(), not 
get_absolute_url()!

See http://www.djangoproject.com/documentation/0.96/sitemaps/.

An example:

sitemap_classes.py:
***
class BrowseTopicSitemap(Sitemap):
 """Browse topic page."""
 changefreq = "weekly"
 priority = 0.9

 def items(self):
 """Return a list of objects represent the browse topic page.

 The caller doesn't care what type of object these are; all that 
matters
 is that these objects get passed to the location(), lastmod(),
 changefreq() and priority() methods.
 """
 # Return a list containing the most recent topic on the site.
 return 
[Topic.objects.filter(visible=True).order_by("-creation_time")[0]]

 def location(self, obj):
 """Return the absolute URL for the browse topic page "object"."""
 return "/browse/"

 def lastmod(self, obj):
 """Etc..."""
 
 return result


def sitemap_dict():
 """Return the current sitemap dict."""
 # Prepare mapping info for the static mapping sections.  Each of these
 # sections aren't very large.
 class_list = [("index", IndexSitemap),
   ("browse", BrowseTopicSitemap),
   ("author", AuthorSitemap),
   
 ]


*


In the URL config:

urlpatterns += patterns('',
 (r'^sitemap.xml$', "django.contrib.sitemaps.views.index",
 sitemap_dict()),
 (r'^sitemap-(?P.+).xml$', 
"django.contrib.sitemaps.views.sitemap",
 sitemap_dict()),
 )



John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Sitemaps and large sites

2007-05-22 Thread John DeRosa

I've implemented sitemaps for my site (www.trenchmice.com), and I've run
into a problem because of my site's size.

TrenchMice has 275K pages, generated from 275K+ database objects. The 
sitemap classes return information on every object, which means they try 
to return information on 275K+ objects! And as a result, the sitemap.xml 
lookup never finishes.  (I gave up after waiting an hour...)

The sitemap classes dutifully return infrequently updated objects with a
low priority and frequency.  But because the classes look up 275K+
objects, and return _all_ the items in each set, it never finishes.

Unless I'm missing something obvious (and I might be), a straightforward
implementation of the sitemaps protocol doesn't work for large sites.

What do large sites do?  Do they return only the most recent N objects 
of every class?  If so, then how do the search engines find out about 
the infrequently updated objects?

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Sitemaps and large sites

2007-05-22 Thread John DeRosa

I've implemented sitemaps for my site (www.trenchmice.com), and I've run 
into a problem because of my site's size.

TrenchMice has 275K pages, generated from 275K+ database objects. (These 
are "topics" and "scoops".) The sitemap classes return information on 
every object, which means try to return information on 275K+ objects! 
And as a result, the sitemap.xml lookup never finishes.  (I gave up 
after waiting an hour...)

The sitemap classes dutifully return infrequently updated objects with a 
low priority and frequency.  But because the classes look up 275K+ 
objects, returning _all_ the items in each set, etc., it never finishes.

Unless I'm missing something obvious (and I might be), a straightforward 
implementation of the sitemaps protocol won't work for large sites.

So, what do large sites do?  Do they return only the most recent N 
objects of every class?  If so, then how do the search engines find out 
about the infrequently updated objects?

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How well should I know Python before using Django?

2007-05-09 Thread John DeRosa

(1) If you're making a simple web site.  (2) If you're making a site 
with a non-trivial use of authentication, session variables, complicated 
db lookups; or uses complicated algorithms under the hood.

$.02,

John

walterbyrd wrote:
> Before attempting to use Django, a person should have a Python
> programming skill level of:
> 
> 1) beginner
> 2) intermediate
> 3) expert
> 
> To use Django, a developer should have an  exceptionally strong
> knowledge of the following area(s) of Python: __
> 
> 
> > 
> 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Curious error with Session Variables

2007-05-08 Thread John DeRosa

Perhaps check your firewall, anti-hijack, anti-trojan, etc. software. 
You may have a cookie guard enabled.

For example, Webroot's Spy Sweeper has a set of "shields" for web 
browsers, and they include the blocking of certain tracking cookies and 
some IE security 'protection'.  Perhaps your system is running a similar 
product?

John

Diego pylorca wrote:
> m
> 
> I deployed my site, and in the admin when i try to login i get this message:
> 
> "Looks like your browser isn't configured to accept cookies. Please 
> enable cookies, reload this page, and try again."
> 
> the cookies is enabled.
> 
> my server is a debian etch stable (intalled modpython apache2 and mysql 
> from apt)
> 
> i ve run django/bin/daily_cleanup.py and flush the session table...
> 
> 
> PD: sory by me bad english
> 
> 
> On 4/4/07, *chasfs* <[EMAIL PROTECTED] > wrote:
> 
> 
> There are several things going on here. If you have multiple django
> sites
> all setting sessions cookies, make sure that the SESSION_COOKIE_NAME
> and SESSION_COOKIE_DOMAIN are unique in the respective settings.py
> files.
> 
> You also need to clean out old session rows in the django_session
> database.
> You can use django/bin/daily_cleanup.py to do this.
> 
> Good luck,
> -chasfs
> 
> On Apr 3, 1:36 pm, "Ramdas S" < [EMAIL PROTECTED]
> > wrote:
>  > Since last few days I am getting this error on Django web sites
> hosted.
>  > Obviously it is clashing with something.
>  >
>  > When I work on admin interface to add or delete content, I get
> logged off
>  > and it takes some time for me to login again.
>  >
>  > I get the following messages
>  >
>  > Please enter a correct username and password. Note that both
> fields are
>  > case-sensitive.
>  >
>  > If I keep on trying then the message changes to
>  >
>  > Looks like your browser isn't configured to accept cookies.
> Please enable
>  > cookies, reload this page, and try again.
>  >
>  > Later if I persist
>  >
>  > I get this error
>  >
>  > -
>  >
>  > SuspiciousOperation at /admin/ User may have tampered with session
>  > cookie. Request
>  > Method: POST  Request URL: http://developeriq.com/admin/
> Exception Type:
>  > SuspiciousOperation  Exception Value: User may have tampered with
> session
>  > cookie.  Exception Location:
>  >
> /usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py
> 
>  > in _decode_post_data, line 40
>  >
>  > I am using the latest development version Mod_Python, Apache and
> Ubuntu
>  > Linux
>  >
>  > What can be the reason
>  >
>  > Thanks
>  >
>  > Ramdas S
>  >
>  > The Server is a dedicated server, and it also runs PHP, MySQl and
> some PHP
>  > and Python software.
> 
> 
> 
> 
> 
> 
> 
> -- 
> Diego F. Toritto.
> > 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Securing the admin site

2007-04-04 Thread John DeRosa

trickyb wrote:
> This is a somewhat open-ended question: what are people doing to
> secure their admin sites against unwelcome visitors? On my site, what
> I've done is change the URL root from /admin/ to something else so
> that casual visitors do not know where to look.

Richard,

To change the URL root to something else, did you just have replace
r'^admin/' with something else in the URL conf file?  Or, did you have
to also do some other hacking?

I ask because we're thinking of doing the same thing.

John



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django as a platform for a commercial SaaS project?

2007-03-24 Thread John DeRosa

Lee Hinde wrote:
> 
> 
> On Mar 24, 8:03 pm, John DeRosa <[EMAIL PROTECTED]> wrote:
>> walterbyrd wrote:
>>> SaaS = Software as a service, just in case that was not clear.
>> What's the difference between SaaS and an ASP?  I don't quite get the
>> distinction between them.
> 
> The ASP provides the SaaS.

Yes and no.  The term "ASP" existed before "SaaS" came on the scene.  I 
think ASPs were selling something to their customers before SaaS was 
"invented."

The point of my original post was that the meaning of ASP and SaaS, and 
whether there's any real difference between them, depends on who's doing 
the talking.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django as a platform for a commercial SaaS project?

2007-03-24 Thread John DeRosa

walterbyrd wrote:
> SaaS = Software as a service, just in case that was not clear.

What's the difference between SaaS and an ASP?  I don't quite get the 
distinction between them.

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Designing for Speed - conditionals inside the view versus the template

2007-03-12 Thread John DeRosa

Merric Mercer wrote:
> I have  view that returns a whole bunch of different variables and 
> boolean flags.The state of these flags determine what the user 
> actually sees on their screen.
> 
>  From a design perspective I seem to have two options:-
> 
> 
> 1.   Design a template with lots of {% if %} conditional statements to 
> check the status of various flags, in order to display the appropriate 
> information to the user.
> 
> OR
> 
> 2.   Do the bulk of the work in the view,  by doing something like:-
[snip]
> 3.  Do a combination of the two above
> 
> Option number 2 lacks the flexibility of doing stuff in the template, 
> but would it make a big difference in speed?  I am concerned that having 
> a lot of conditional statements in the template might be slower than 
> doing the work in the view.
> 
> Can anybody shed some light on this and the trade off (if any) of speed 
> versus flexibility.

A view is Python code, which is compiled into bytecode and then executed 
by the Python interpreter.  Whereas a template is interpreted by the 
Python template engine, which is Python code executed by the Python 
interpreter.

A template will will always have that extra layer of interpretation. 
Think of it as a new language with a compiler written in Python.  (Which 
it is...)  So from the smallest perspective, an if-else in a template 
will always be slower than the equivalent {%if%}-{%else%}-{%endif%} in a 
view.

But before you pull out a stopwatch and move all of your application's 
decisions into the views, think about the long-term maintainability, 
likelihood of bugs, the goodness of separating of "what" code from "how" 
code, etc.  The history of software is littered with code that was 
extremely efficient but impossible to maintain or adapt to changing 
requirements.  You can double your application's performance by buying 
or leasing a new box + more memory next year.  What % improvement do you 
think code shifting from template to view will get you?

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



What's the proper use of LazyDate?

2007-01-04 Thread John DeRosa


What's the proper/recommended/improper/not-recommended use of 
models.LazyDate() in 0.95?


I'm working on a project that picked up its use in 0.91-based code. 
There's a passing reference to it in the 0.90 docs, but nothing since 
then. There are references to it all over the web...


E.g.:

class UserReadComment(models.Model):
  scoop = models.ForeignKey(Scoop,raw_id_admin=True)
  [...snip...]
  last_read = models.DateTimeField(default=models.LazyDate(),
   auto_now=True)

?

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Anal not Analog, Analysis: DB Question

2006-10-04 Thread John DeRosa

heh.  so do we get to guess what your django-based site is about?

Tom Smith wrote:
> If I am looking for titles like "Anal Sex" or "Being Anal" then how  
> do I construct this, ahem, query... to not return "Analysis" or  
> "Analog"?
> 
> I tried adding spaces to the end of the word but it doesn't seem to  
> help...
> 
> object_list = Product.objects.filter( Q(title__contains=word + " ")| Q 
> (title__contains=" " + word )  )
> 
> regards
> 
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Python 2.5 anyone

2006-09-20 Thread John DeRosa

Oliver Andrich wrote:
> Hi,
> 
> On 9/20/06, John DeRosa <[EMAIL PROTECTED]> wrote:
>> How'd you do it?
>>
>> I'm on Windows XP.  I installed Python 2.5 from python.org without a
>> problem.
>>
>> But then I found that pysqlite Windows binaries for Python 2.5 don't
>> exist, and neither does setuptools.  Trying to install Django 0.95 on
>> top of Python 2.5 gives me this:
> 
> I am running Django and Python on Mac OS X, but the situation was
> almost identical. I downloaded the ZIP Version of setuptools from
> cheeseshop.python.org and did a "python setup.py install". The same
> for MySQLdb.
> 
> Afterwards the install of Django worked fine and without errors.
> 
> And for pysqlite, I think you can just stick to Python 2.5. It
> includes the relevant library. May be a small patch to the Django
> sqlite backend is required, but this is something I have to check
> later.

Thanks Oliver.  I did as you suggest with setuptools, and it installed 
properly, and I then installed Django.  Super!

But I do seem to need pysqlite.  Even though the 2.5 documentation says 
that pysqlite has been added as "sqlite3", I get this when I try to 
start up Django 0.95:

---
Traceback (most recent call last):
   File "C:\Documents and Settings\John\My 
Documents\tm\SVN\trunk\src\webcode\initial_data_load.py", line 3, in 

 from webcode.edmonds.models import IS_Category
   File "C:\Documents and Settings\John\My 
Documents\tm\SVN\trunk\src\webcode\edmonds\models.py", line 1, in 
 from django.db import models
   File 
"c:\python25\lib\site-packages\Django-0.95-py2.5.egg\django\db\__init__.py", 
line 11, in 
 backend = __import__('django.db.backends.%s.base' % 
settings.DATABASE_ENGINE, '', '', [''])
   File 
"c:\python25\lib\site-packages\Django-0.95-py2.5.egg\django\db\backends\sqlite3\base.py",
 
line 10, in 
 raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading pysqlite2 
module: No module named pysqlite2
-

The code in db\backends\sqlite3\base.py does this:


try:
 from pysqlite2 import dbapi2 as Database
except ImportError, e:
 from django.core.exceptions import ImproperlyConfigured
 raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e


It seems a little screwy for a file in a directory called "sqlite3" to 
do an import from "pysqlite2".  But that's what it does.

Something's confused here with pysqlite, pysqlite2, pysqlite3... I've 
about reached my time limit on this experiment, so I'm going to revert 
to Python 2.4.  :-(

Thanks again.

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Python 2.5 anyone

2006-09-20 Thread John DeRosa

Oliver Andrich wrote:
> Hi,
> 
> I am running Django 0.95 . And so far I can't see any problems.

How'd you do it?

I'm on Windows XP.  I installed Python 2.5 from python.org without a 
problem.

But then I found that pysqlite Windows binaries for Python 2.5 don't 
exist, and neither does setuptools.  Trying to install Django 0.95 on 
top of Python 2.5 gives me this:


C:\Documents and Settings\John\Desktop\Django-0.95>setup.py install

---
This script requires setuptools version 0.6c1 to run (even to display
help).  I will attempt to download it for you (from
http://cheeseshop.python.org/packages/2.5/s/setuptools/), but
you may need to enable firewall access for this script first.
I will start the download in 15 seconds.

(Note: if this machine does not have network access, please obtain the file

 
http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6c1-py2.5.egg

and place it in this directory before rerunning this script.)
---
Downloading 
http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6c1-py2.5.egg
Traceback (most recent call last):
   File "C:\Documents and Settings\John\Desktop\Django-0.95\setup.py", 
line 2, in 
 ez_setup.use_setuptools()
   File "C:\Documents and 
Settings\John\Desktop\Django-0.95\ez_setup.py", line 72, in use_setuptools
 egg = download_setuptools(version, download_base, to_dir, 
download_delay)
   File "C:\Documents and 
Settings\John\Desktop\Django-0.95\ez_setup.py", line 126, in download_setup
tools
 src = urllib2.urlopen(url)
   File "C:\Python25\lib\urllib2.py", line 121, in urlopen
 return _opener.open(url, data)
   File "C:\Python25\lib\urllib2.py", line 380, in open
 response = meth(req, response)
   File "C:\Python25\lib\urllib2.py", line 491, in http_response
 'http', request, response, code, msg, hdrs)
   File "C:\Python25\lib\urllib2.py", line 418, in error
 return self._call_chain(*args)
   File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
 result = func(*args)
   File "C:\Python25\lib\urllib2.py", line 499, in http_error_default
 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
-

I poked around in http://cheeseshop.python.org/packages/2.5/, and an 
.egg file was nowhere to be found.

I could build pysqlite from the sources, but the setuptools problem is a 
little more daunting.

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Select all instances of a model that have a null ForeignKey value

2006-09-09 Thread John DeRosa

cyberco wrote:
> Given:
> 
> =Models==
> class T(models.Model):
> pass
> 
> class Y(models.Model):
> t = models.ForeignKey(T, blank=True, null=True)
> 
> 
> I want to select all instances of a Y that have a null value for t. I
> would say that it should be...
> 
> 
> Y.objects.filter(t_id=None)
> 
> 
> 
> ...but that returns all instances of T although some instances
> definitely have a value for t.

...filter(t__isnull=True)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin connection mysql problem

2006-06-27 Thread John DeRosa

Patrick Martini wrote:
> Thanks for the answer :)
> I have tries to start my site without installed application.
> But the admin give me always the same problem.
> 
> I have already broken two keyboards trying to risolve the problem :)
> 
> Have you another suggestion ?

nope, sorry!...


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin connection mysql problem

2006-06-26 Thread John DeRosa

When I've seen messages similar to this, it's usually because an 
identifier in the meta.Admin list_display list was not defined as a 
field in the class.  A good place to start would be to check the 
spelling of every field listed in meta.Admin.

John

Patrick wrote:
> Hi,
> when i go in my admin site (http://basetta.pupazzo.org/admin)
> I recieve always this
> 
> Mod_python error: "PythonHandler django.core.handlers.modpython"
> 
> Traceback (most recent call last):
> 
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in 
> HandlerDispatch
> result = object(req)
> 
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", 
> line 161, in handler
> return ModPythonHandler()(req)
> 
>   File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", 
> line 137, in __call__
> response = middleware_method(request, response)
> 
>   File 
> "/usr/lib/python2.3/site-packages/django/contrib/sessions/middleware.py", 
> line 81, in process_response
> session_key = request.session.session_key or 
> Session.objects.get_new_session_key()
> 
>   File "/usr/lib/python2.3/site-packages/django/contrib/sessions/models.py", 
> line 21, in get_new_session_key
> self.get(session_key=session_key)
> 
>   File "/usr/lib/python2.3/site-packages/django/db/models/manager.py", line 
> 70, in get
> return self.get_query_set().get(*args, **kwargs)
> 
>   File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 
> 202, in get
> obj_list = list(clone)
> 
>   File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 94, 
> in __iter__
> return iter(self._get_data())
> 
>   File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 
> 412, in _get_data
> self._result_cache = list(self.iterator())
> 
>   File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 
> 161, in iterator
> cursor = connection.cursor()
> 
>   File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", 
> line 90, in cursor
> self.connection = Database.connect(**kwargs)
> 
>   File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66, in 
> Connect
> return Connection(*args, **kwargs)
> 
>   File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, 
> in __init__
> self.converter[types.StringType] = string_literal
> 
> TypeError: object does not support item assignment
> 
> 
> but I canno't understand why.
> 
> Have you some suggestions to give ?
> 
> ciao ciao
> Patrick
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: html input tag width corresponding to CharFields always fixed

2006-05-26 Thread John DeRosa

[EMAIL PROTECTED] wrote:
> for a field defined as
>  spot =models.CharField(maxlength=250),
> or  band =models.CharField(maxlength=2),
> 
>  the input field in forms always has a fixed width. how to change that
> ?

Add length=.  Like so:

formfields.TextField(field_name="address_line1", maxlength=80, length=50),

John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---