Tuesday, November 30, 2010

Django install on Apache server

Django doc on using with wsgi server.

Learned that the base wsgi file (django.wsgi) needs to be in a legal server path. On my machine that's c:/xampp/htdocs. Otherwise get 403 error. However, the wsgi file can refer to projects anywhere on computer. The project does need to be on the path, as the doc says (and shows how to do. However, the setting of DJANGO_SETTINGS_MODULE is a little misleading. I added my project to the path (c:/xampp/django/avppng). Then DJANGO_SETTINGS_MODULE = 'settings' because it is relative to the path. The doc shows setting path to django (c:/xampp/django) and DJANGO_SETTINGS_MODULE='avppng.settings'. But this makes some relative paths in the project not work.

Python errors produce 500 errors. Look at Apache error log file c:/xampp/apache/logs/error.log to see Python errors. The doc mentioned setting LogLevel info in httpd.conf, but the default warn setting worked fine for me. Tried to use sys.stderr.write to write to log file, but didn't work.

Now I see something disturbing. I just saw an error that my administration module couldn't be found in avppng.urls. So in wsgi file I changed the path to c:/xampp/django/avppng/ and DJANGO_SETTINGS_MODULE to settings. Shut down, made a change. Then it told me a django py couldn't find avppng.urls. So I changed path back to c:/xampp/django and DJANGO_SETTINGS_MODULE to avppng.settings and it worked! How can one way work then not and visa versa?? (Slash at end of path doesn't seem to make a difference.)


Django tag cloud

Tag clouds for Django. Stackoverflow post has info. Logarithmic tag algorithm. Napes intro to using tag clouds. Django-tagging package.

Django social authorization

Post about package to allow login through social media (Facebook, Google, etc) ids.

Sunday, November 28, 2010

Django lookups

Django or lookups.

Django list posts

QueryDict is used to handle lists (as dictionaries) in GET/POST forms.

Question: How is QueryDict set? Documentation just refers to it: q = QueryDict('a=1'). How does it know where to get info?

Django foo never uses QueryDict directly:
1def handle(request):
2 if request.method == 'POST':
3 artists = request.POST.getlist('artists') # now artists is a list of [1,2,3]


Really? I guess so. Appendix H says GET and POST are "dictionary-like" objects. Then how does this code work?
cur_cat = int(request.POST['CategorySelect'])

Does it convert the first key into an integer? No, that fails.

C:\xampp\django\avppng>python
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dict = {1:'a', 2:'b'}
>>> dict
{1: 'a', 2: 'b'}
>>> int(dict)
Traceback (most recent call last):
File "", line 1, in
TypeError: int() argument must be a string or a number, not 'dict'
>>>

So request.POST['CategorySelect'] must not be a dictionary. In fact, if post is a dictionary, then request.POST['CategorySelect'] is a value from a dictionary.

>>> dict3 = {'cs':'1', 'junk':'2'}
>>> dict3
{'cs': '1', 'junk': '2'}
>>> int(dict3['cs'])
1

So POST is a dictionary of item name vs. item value? D'oh! Now the QueryDict doc makes more sense: "QueryDict is a dictionary-like class customized to deal with multiple values for the same key." Django foo's example above makes more sense too. Finally, Appendix H has a full example at the end that makes this all clear!


Saturday, November 27, 2010

Design Patterns, Wikipedia

Reading Design Patterns on Wikipedia. Started in architecture, spread to computer.

Seminal book Design Patterns: Elements of Reusable Object-Oriented Software. Written by Gang of Four (GoF). Uses Unified Modeling Language (UML), which supersedes the Booch Method.

OK, regressing a lot. Need to learn UML. Overview of Book is interesting. Maybe get book to see details.

Enough for today.

Friday, November 26, 2010

Regression Testing

More on regression testing.

My brother discussed with me idea of two sets of developers: one writes app, one writes tests to same spec. Referring perhaps to the ISO 90003 standard.

See software to aid testing like HP Quality Center, Seapine QA Wizard, Borland Silktest, VectorCAST.