Re: New app - architecture

2014-10-19 Thread Avraham Serour
>  UI other: bootstrap / kendo UI / dojo / jquery UI / ... ?
whatever you feel more comfortable, get something working first, but I
wouldn't use jqueryUI and wouldn't pay for kendo at least to begin, after I
got something working and the situation proves I need kendo I would buy it.

> JS framework: angularJS / backbone.js / ember ? (btw, I prefer
declarative over algorithmic coding)
If you need to start learning something I would choose angularjs, but if
you are already familiar or prefer something just use what you like

> BE API for browser FE: just pure django views or anything else?
what other option would you have other than django views?

> BE API for web services integrations: TastyPie? (API will have to be
versioned, I would like to have the auto documentation, too)
I like tastypie, but use it only if you actually need it

> Cache: reddit? memcached?
how would you use reddit for cache?

> BE - app server: Django (for sure :), Celery / Rabit MQ?
It seems you are confusing the things here, none of them are application
servers
django is a framework, the application itself would be using it
to serve the application I would use nginx+uwsgi, nginx is a webserver,
uwsgi is the application server

> Authentication: (it is not a social app, therefore the own login is
acceptable. Eventually there will be needed some sort of SSO from corporate
environment - how to do that?) + eventually python-social-auth for public
SSO (e.g. for SMEs, who use GApps?)
So don't worry for now, worry then, there are django apps for that, you can
plug additional auth backends later or even write your own

> Search: Whoosh? (there will be searchable cca 100 000 records, every
record is ala github ticket. Nevertheless search should form some sort of
group-based selection wizard, therefore I do not like the Haystack
limitations. Solr etc. seams to be overkill now.
My suggestions here is to create a stage server, populate and test with
some of the most popular, it looks like you already ruled out haystack
In any case this shouldn't influence on the alpha version, use the DB for
search for now, while you are only making the prototype after you start
seeing performance problems start looking for a dedicated engine, remember
the first 3 rules on optimizing

> BE - DB: PostgreSQL?
I like postgres, I strongly recommend it

> Deployment: Fabric?
yes, but on the other hand this doesn't have much meaning, fabric just
makes easier automating ssh commands, it doesn't provide recipes for
deployment, you still have to plan this

> Supporting: Sentry, New Relic?
what kind of support are you talking about?

> BE autotests: ???
>FE autotests: selenium?
unit tests are very nice, but if you have no experience on it you may waste
too much time learning this instead of making the product itself, ideally
you should have them before making a release, but make an alpha version
first and start thinking about them during beta

> CDN: google, maxcdn, other? (for JS, fonts etc.)
just serve them from your server, if you see performance problems after
releasing the first version you can consider them, and test.
this depends on your users location, before using CDN's make the content
cachable, in any case refer to the first 3 rules on optimizing

On Sat, Oct 18, 2014 at 1:01 PM, Radek Svarz  wrote:

> Hi,
>
> just imagine you have a chance to create a new application - on the
> greenfield (hurray! :)
>
> The application would be *Software as a Service ala Github, Bitbucket,
> JIRA, Mailchimp, Zendesk, Freshdesk*.
>
> I.e. friendly, direct frontend + some background tasks (initiated both by
> cron and users) + API for webservices integrations.
>
> Users are from corporates and SMEs. App has designed architecture for
> ideal zero downtime.
>
> App would have both URL separated parts and SPA (Single Application parts
> for modules) via # in URL. UI should behave like Mailchimp.
>
> Due to the continuous development the app would have configurable feature
> flipping (for both FrontEnd, and BackEnd, might also have for webservice
> APIs).
>
> Usage is on PC browser (IE9+ and others - yes corporates:( ), also for
> browsers in tablets (Android Chrome, Ipad Safari).
>
> *# How would you design the app architecture TODAY? #*
>
> ---
>
> Browser Front End (*please answer at least this*):
>
>   UI for interactive special graphs: D3JS (we have tested several others -
> conclusion we must use it)
>
>   UI other: bootstrap / kendo UI / dojo / jquery UI / ... ?
>
>   JS framework: angularJS / backbone.js / ember ? (btw, I prefer
> declarative over algorithmic coding)
>
>
> Other::(back end,...)::
>
> BE API for browser FE: just pure django views or anything else?
>
> BE API for web services integrations: TastyPie? (API will have to be
> versioned, I would like to have the auto documentation, too)
>
> Cache: reddit? memcached?
>
> BE - app server: Django (for sure :), Celery / Rabi

Re: NoReverseMatch error

2014-10-19 Thread Daniel Grace
You were right Vijay.  I worked this out.  I needed to set type and state 
via the context as follows:

def get_context_data(self, **kwargs):
context = super(TestFlow, self).get_context_data(**kwargs)
context.update({'type': self.kwargs['type'], 'state': 
self.kwargs['state']})
return context

... then reference type and state in the url template tag:


-- 
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/ea14bda3-1e09-471f-bb2a-aacbc74e8b48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best way to display master detail data, with class based view or function based view?

2014-10-19 Thread Daniel Grace
I have implemented a model where one flow has many events as follows:
class Event(models.Model):
flow = models.ForeignKey(Flow)
...

I need a page to display one or two fields from a single flow and a list of 
all related events.
Should I implement this with a DetailView, a ListView (if either is 
possible) or just a plain function based view?

-- 
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/c2266570-1806-4778-99ec-666f87f11ec5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New app - architecture

2014-10-19 Thread Scot Hacker

All good advice from Avraham Serour - just a couple of additional comments:

On Sunday, October 19, 2014 1:06:55 AM UTC-7, Avraham Serour wrote:
>
>
>
> > BE API for web services integrations: TastyPie? (API will have to be 
> versioned, I would like to have the auto documentation, too)
> I like tastypie, but use it only if you actually need it
>

Django REST Framework eclipses the functionality and ease of use of 
Tastypie, IMO, and has become the de facto standard for Django API 
generation. Its documentation is stellar and it is quite actively 
developed. I'm hoping that, now that migrations are in core, a discussion 
about integrating API generation into core is a next big topic for Django 
core (this is an area where Django lags behind Rails).

 

> > Deployment: Fabric?
> yes, but on the other hand this doesn't have much meaning, fabric just 
> makes easier automating ssh commands, it doesn't provide recipes for 
> deployment, you still have to plan this
>

Fabric is awesome, but as you move past the "automating ssh commands" into 
"we need a real build system," check out Ansible.

./s
 

>
>

-- 
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/e484397c-b665-4fa0-84a9-e21d40a39d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: entering data directly into a postgreSQL database

2014-10-19 Thread Scot Hacker


On Saturday, October 18, 2014 10:05:11 PM UTC-7, Jon Joseph wrote:
>
>
> def __str__(self):
> return self.problem_number + '\n' + self.problem_statement
>

I don't like this idea of sticking a new line into a string representation. 
Do you really want a new line crammed into every possible situation where a 
string repr might appear? Feels like "code smell" to me. Does the problem 
go away if you replace the \n with a hyphen or something? 
 

>
> I would like to populate the database by using the PostgreSQL specific 
> command:
>
> COPY solutions_problemlist from 'filename'  
>

Rather than using pg's COPY command, I recommend writing an actual Django 
import script to parse your tab-delim file and import via the ORM. It'll be 
more automatable, part of your code repo, and more Django-like. You could 
also do it as a migration if you just need it to happen once.

./s

-- 
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/d350010b-20a9-4821-9a0a-0f8f6ca7b6a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New app - architecture

2014-10-19 Thread Radek Svarz
@Avraham - thanks a lot

To clarify some of my mistakes. Overall we have our 1st version prototype 
done. Now I would like to change it to the better architecture.

>>>what other option would you have other than django views?
API JSON responses made views - ala Tastypie  for SPA parts

>>> how would you use reddit for cache?
typo: I meant Redis
SO discussion: 
http://stackoverflow.com/questions/10558465/memcache-vs-redis 

>>> > BE - app server: Django (for sure :), Celery / Rabit MQ?
>It seems you are confusing the things here, none of them are application 
servers
>django is a framework, the application itself would be using it
t>o serve the application I would use nginx+uwsgi, nginx is a webserver, 
uwsgi is the application server

Correct, I just abstracted that into one box ;) So if I split it:

framework: django :)
app server: uwsgi
http server: nginx (also depending on the PaaS env. we will use)

bkg tasks:  Celery or Rabit MQ?

>>> SSO + open auth.
>>> So don't worry for now, worry then, there are django apps for that, you 
can plug additional auth backends later or even write your own
It will come sooner than later (cca 2 months to demonstrate).

>>> Search - remember the first 3 rules on optimizing
Do you mean 1) do not optimize 2) do not optimize 3) do not optimize yet ? 
:)

Btw, notes from other sources: 

Deployment Ansible - seams to be more flexible than Fabric.
Local tasks directly in Django mng. commands, FE tasks via Grunt.
Tests in Pytest with Django dynamic fixtures. 
Splinter as a frontend for Selenium. Karma runner for running tests written 
in Jasmine.
E2E tests in Protractor.

Radek

On Sunday, October 19, 2014 10:06:55 AM UTC+2, Avraham Serour wrote:
>
> >  UI other: bootstrap / kendo UI / dojo / jquery UI / ... ?
> whatever you feel more comfortable, get something working first, but I 
> wouldn't use jqueryUI and wouldn't pay for kendo at least to begin, after I 
> got something working and the situation proves I need kendo I would buy it.
>
> > JS framework: angularJS / backbone.js / ember ? (btw, I prefer 
> declarative over algorithmic coding)
> If you need to start learning something I would choose angularjs, but if 
> you are already familiar or prefer something just use what you like
>
> > BE API for browser FE: just pure django views or anything else?
> what other option would you have other than django views?
>
> > BE API for web services integrations: TastyPie? (API will have to be 
> versioned, I would like to have the auto documentation, too)
> I like tastypie, but use it only if you actually need it
>
> > Cache: reddit? memcached?
> how would you use reddit for cache?
>
> > BE - app server: Django (for sure :), Celery / Rabit MQ?
> It seems you are confusing the things here, none of them are application 
> servers
> django is a framework, the application itself would be using it
> to serve the application I would use nginx+uwsgi, nginx is a webserver, 
> uwsgi is the application server
>
> > Authentication: (it is not a social app, therefore the own login is 
> acceptable. Eventually there will be needed some sort of SSO from corporate 
> environment - how to do that?) + eventually python-social-auth for public 
> SSO (e.g. for SMEs, who use GApps?)
> So don't worry for now, worry then, there are django apps for that, you 
> can plug additional auth backends later or even write your own
>
> > Search: Whoosh? (there will be searchable cca 100 000 records, every 
> record is ala github ticket. Nevertheless search should form some sort of 
> group-based selection wizard, therefore I do not like the Haystack 
> limitations. Solr etc. seams to be overkill now.
> My suggestions here is to create a stage server, populate and test with 
> some of the most popular, it looks like you already ruled out haystack
> In any case this shouldn't influence on the alpha version, use the DB for 
> search for now, while you are only making the prototype after you start 
> seeing performance problems start looking for a dedicated engine, remember 
> the first 3 rules on optimizing
>
> > BE - DB: PostgreSQL?
> I like postgres, I strongly recommend it
>
> > Deployment: Fabric?
> yes, but on the other hand this doesn't have much meaning, fabric just 
> makes easier automating ssh commands, it doesn't provide recipes for 
> deployment, you still have to plan this
>
> > Supporting: Sentry, New Relic?
> what kind of support are you talking about?
>
> > BE autotests: ???
> >FE autotests: selenium?
> unit tests are very nice, but if you have no experience on it you may 
> waste too much time learning this instead of making the product itself, 
> ideally you should have them before making a release, but make an alpha 
> version first and start thinking about them during beta
>
> > CDN: google, maxcdn, other? (for JS, fonts etc.)
> just serve them from your server, if you see performance problems after 
> releasing the first version you can consider them, and test.
> this depends on your users locat

Re: Best way to display master detail data, with class based view or function based view?

2014-10-19 Thread Daniel Grace
I found the following thread at stackoverflow:
http://stackoverflow.com/questions/9777121/django-generic-views-when-to-use-listview-vs-detailview

I may want to paginate the list so it would seem to make sense to use the 
list view (for the events) and just display the flow fields at the top of 
the page.

-- 
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/07797963-4a23-42c2-b32c-91f6fe7646ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic Views and Django.contrib.auth

2014-10-19 Thread Rootz
Thanks.

On Thursday, October 16, 2014 11:54:45 AM UTC-5, Vijay Khemlani wrote:
>
> If you are usign class based generic views you can use the decorators in 
> the URL config of your app, for example
>
> urlpatterns = patterns('',
> (r'^about/', login_required(AboutView.as_view())),
> )
>
>
> On Thu, Oct 16, 2014 at 12:49 PM, Rootz > 
> wrote:
>
>> Can I use both Generic View and the Django.contrib.auth features (such as 
>> login_required decorator and other auth interface tool)? And if it is not 
>> possible to integrate auth into Generic Views then can you recommend 
>> alternative way of making the two work together? Adding to this I am using 
>> Django 1.7v and python 3.4v. 
>>
>> Thank you
>>
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/09fe215a-4572-418c-959f-567e9ab05b0b%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/7fdf3ecf-381b-4aa7-9e30-46a1043a7694%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting started with django templatetags

2014-10-19 Thread Tom Lockhart

On Oct 18, 2014, at 2:24 AM, Scipion  wrote:

> Hey,
> 
> I have started to use Django (1.6) few weeks ago and I have the following 
> problem to resolve by using templatetags. (this is my very first templatetags 
> draft, so I may be wrong in the way of designing it, do not hesitate to 
> highlight anything weird).
> In my template, I have a list of elements (defined in the context) : items 
> (among 6 different django models).
> According to which class an item belongs, I have to display an image or a 
> title specific to this class (these informations can't be stored in the 
> models). 
> So basically, in my template I would like to have something like : 
> 
> {% for item in items %}
>  {% show_title_tag item %} 
> myPath/{% show_image_name_tag %}
> {% endfor %}
> 
> 
> I can't have more than that.
> 
>
>  @register.tag
> def show_title_tag(parser,token):
> tag_name, item = token.split_contents()
> if isinstance(item,class1):
> return MyNode(item.quote)
> elif isinstance(item,class2):
> return MyNode(item.subtitle)
> elif isinstance(item,class3):
> return MyNode(item.title)
> ...
> # basically, the field to use change for each class
>  
> @register.tag
> def show_image_name_tag(parser,token):
> tag_name, item = token.split_contents()
> if isinstance(item,class1):
> return MyNode("specific image name linked to class 1")
> elif isinstance(item,class2):
> return MyNode("specific image name linked to class 2")
> ...
> # the name change at each class, and is not stored in the object
> 
>  
> class MyNode:
> def __init__(self, image_or_title_string):
> self.image_or_title_string = image_or_title_string
> def render(self, context):
> return image_or_title_string.resolve(context)
> 
> 
> 
> 
> 
> Two main questions :  
> 
>  1. I am duplicated the if-elif code. Any idea how I could do it without
> duplicating it ? I could maybe only use one tag and add an extra
> parameter (in the tag and in the render) to specify which
> information I need (either the image or the title). Really not sure
> about this ...

This should not count as a suggestion of "best practices". At all.

But if you really cannot associate your related data with a model, then I might 
try setting up a lookup table with the classes as the lookup key. Something like

imagelookups.py

include .models

image_table = {class1: specific_image_url_for_class1,
class2: specific_image_url_for_class2,
...}

I'm not sure that the template tag is particularly useful here; why not just 
cough up the image URL itself rather than an entire piece of template?

So your template tag can just set a variable to be used in your templates:

@register.simple_tag
def show_title_tag(parser, token):
tag_name, item = token...
return image_table[item]

hth

- Tom


> 
>  
>  2. Can I have access to the variable and not the string in the tag code
> (after doing : tag_name, item = token.split_contents()). I imagine
> that item will be a string and not my django object. How can I
> resolve this ?
> 
> Also, here are the requirements I have to enforce : 
> 
>  - keep template very simple
>  - use templatetags to solve it
>  - can't modify models
>  - check to which class an item belongs with a function as isinstance in
>the templatetags (not in the template)
> 
>  
> Please, any suggestions are welcome here, as long as they respect the 
> requirements. Also, remind that I am a django beginner, I am just trying to 
> do it simple and readable, not highly effective.
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/7b4b4803-dd5b-44ce-a785-b9a0d5fe6abb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Please consider the environment before printing this message.
This message may be privileged and/or confidential, and the sender does not 
waive any related rights and obligations.  Any distribution, use or copying of 
this message or the information it contains by other than an intended recipient 
is unauthorized.  If you received this message in error, please immediately 
advise me by return e-mail or phone.  All information, references, images, 
programs, source code, or other materials whatsoever contained in, or supplied 
with, this document are TRADE SECRETS and governed by the Uniform Trade Secrets 
Act.  User assumes all direct and consequential liabilities and costs that 
result from any unauthorized disclosure or use of this info