February 07, 2007

Julio César Carrascal Urquijo wrote:
> Antti Holvikari wrote:
>> On 1/22/07, Hasan Aljudy <hasan.aljudy@gmail.com> wrote:
>>> I wish we'd have a framework similar to Django, however, come to think
>>> of it .. I'd rather use Django than wait for a D clone .. which I don't
>>> think can be more powerful since D doesn't have any dynamic reflection
>>> capabilities.
>>
>> Hmm, hope I'm not missing something here but why would you need
>> reflection for that?
>>
> 
> Django uses python's reflections capabilities to bind classes to SQL tables and build administration interfaces in ways that I don't thing even the compile time reflection capabilities of D can implement.
> 
> The following code taken from the Django tutorial admin interfaces for this Master/Details model with all the features you will expect: Pagination, searching, basic validation and form field grouping. Adding filtering and custom validation is really easy.
> 
> from django.db import models
> 
> class Poll(models.Model):
>     question = models.CharField(maxlength=200)
>     pub_date = models.DateTimeField('date published')
> 
>     class Admin:
>         fields = (
>             (None, {'fields': ('question',)}),
>             ('Date information', {'fields': ('pub_date',)}),
>         )
> 
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(maxlength=200)
>     votes = models.IntegerField()
> 
>     class Admin:
>         pass
> 
> As you can see, Django uses reflection to build all of this functionality with just some hints from the programmer.


I'm wondering whether this can be achieved now with the new mixin semantics.

The usage maybe ugly:

mixin(
        models.Model!("poll",
            models.CharField!("question"),
            models.DateTimeField!("pubdate")
            )
            );


But maybe this can generate some rich code .. I wish had the time and experience to take on this.

Anyone willing to give it a try?
February 07, 2007
Hasan Aljudy wrote:
> 
> 
> Julio César Carrascal Urquijo wrote:
>> Antti Holvikari wrote:
>>> On 1/22/07, Hasan Aljudy <hasan.aljudy@gmail.com> wrote:
>>>> I wish we'd have a framework similar to Django, however, come to think
>>>> of it .. I'd rather use Django than wait for a D clone .. which I don't
>>>> think can be more powerful since D doesn't have any dynamic reflection
>>>> capabilities.
>>>
>>> Hmm, hope I'm not missing something here but why would you need
>>> reflection for that?
>>>
>>
>> Django uses python's reflections capabilities to bind classes to SQL tables and build administration interfaces in ways that I don't thing even the compile time reflection capabilities of D can implement.
>>
>> The following code taken from the Django tutorial admin interfaces for this Master/Details model with all the features you will expect: Pagination, searching, basic validation and form field grouping. Adding filtering and custom validation is really easy.
>>
>> from django.db import models
>>
>> class Poll(models.Model):
>>     question = models.CharField(maxlength=200)
>>     pub_date = models.DateTimeField('date published')
>>
>>     class Admin:
>>         fields = (
>>             (None, {'fields': ('question',)}),
>>             ('Date information', {'fields': ('pub_date',)}),
>>         )
>>
>> class Choice(models.Model):
>>     poll = models.ForeignKey(Poll)
>>     choice = models.CharField(maxlength=200)
>>     votes = models.IntegerField()
>>
>>     class Admin:
>>         pass
>>
>> As you can see, Django uses reflection to build all of this functionality with just some hints from the programmer.
> 
> 
> I'm wondering whether this can be achieved now with the new mixin semantics.
> 
> The usage maybe ugly:
> 
> mixin(
>         models.Model!("poll",
>             models.CharField!("question"),
>             models.DateTimeField!("pubdate")
>             )
>             );
> 
> 
> But maybe this can generate some rich code .. I wish had the time and experience to take on this.
> 
> Anyone willing to give it a try?

I was playing with this a couple weeks ago, even without these new mixins. I started playing with a proof-of-concept, but got distracted by other things. I described some of my efforts in this forum thread:

http://dsource.org/forums/viewtopic.php?t=2283

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org
1 2
Next ›   Last »