[ Essay - Technology, Essay - Intuition ] Chat GTP시대의 도래와 생각하는 방식에 대해 : 개발자의 미래에 대해

이미지
벌써 올해도 반쯤 지나 뜨거운 여름이 다가왔다. 굉장히 빠르게 지나간듯한 느낌이 드는데  아마 의미있는 시간을 보냈다는 이야기이기 때문에  그렇게 나쁜 신호는 아닐 것 이다. 괴로운 시간이였다면, 1초가 1년 같이 느껴졌을테니 말이다. 더위에 매우 약한 나에게 있어서는 지옥과 같은 시기이기도 하지만 늘 그렇던 것 처럼 에어컨 덕분에 어찌저찌 버틸 수 있을 것 같다. 어쨋든, 이번에는 저번의 에세이 주제, Chat GTP시대의 도래와 생각하는 방식에 대한 이야기에 이어서  과연 개발자의 미래는 어떻게 될 것인가에 대해 이야기를 나누어보려고 한다. 어쩌면 모두가 인식하고 있듯이 지금 2025년 현재,  꽤나 중요한 시기에 직면하고 있는지도 모른다. 왜냐하면, 생성AI의 발전 속도가 생각보다 빠르게 발전하고 있고,  그에 따라 실제 업무에서도 빠르게 사용되어지고 있기 때문이다. 이러한 상황에서 개발자에게 있어서 가장 두려운 점은  당연히 생성AI에 의해 개발자가 대체될 것 이라는 두려움일 것 이다. 이는 개발자에게만 한정된 이야기는 아니지만 말이다. 아마 필드에서 나와 같이 일하고 있거나  개발자로서 직업을 가지려는 생각이 있는 사람이라면  한번쯤은 생각해볼법한 주제라 생각 한다. 물론 미래가 정확히 어떻게 될 지는 알 수 없으나  이런 생각을 함으로써 몇 가지 힌트는 얻게 될지도 모르니  만약 얻게 된다면 미래에 대한 방향성을 조금이나마 올바른 쪽으로 돌릴 수 있을 것 이다. 이 글을 끝맽을 때는 조금이라도 힌트에 도달하기를 바란다. 과거의 역사 이러한 의문에 대한 해결책으로서 일반적으로 자주 사용하는 방법이 있다. 바로 역사를 보는 것 이다. 물론 이러한 역사를 해결책을 찾는거에 대한 전제조건은  우리가 '구 인류'라는 전제조건이 있었을 때 의미가 있다. 그러니깐 현대인도 기원전 8세기의 고대 로마인도  본질적으로 다르지 않다는 것을 인정해야만 한다. 예컨데...

[ Django, Python ] mozilla 튜토리얼 예제로 살펴보는 Django 분석 ⑧ : 나만의 추가 도전 과제 - 2

다음으로 추가, 수정, 삭제 기능을 구현해보자

추가 수정 삭제 기능의 청사진은 아래와 같다.


각 리스트는 옆에는 Update, Delete 하이퍼링크가 있으며,
누르면 해당하는 책, 작가에 대한 각 기능을 수행한다.

또한 Insert 부분은 대충 어딘가에 하이퍼 링크를 추가한다.

해야하는 것은 굉장히 적다.
왜냐하면 Insert, Udpate, Delete는
Django 에서 제공하는 제너릭 편집 View를 사용하면 되며
이에 관련된 솔루션은 이미 튜토리얼에서 해봤기 때문이다.

일단 화면에 위와 같이 나오게끔 해보자.

다만, 한 가지 문제점이 생겼다.

왜냐하면 각 Template 파일의 코드는 
공용 리스트를 extend 했기 때문이다.

내가 원하는 것은 권한에 따른 Template이다.

그렇기 때문에 이를 각 독립할 필요가 있다.


{% extends "base_generic.html" %}

{% block content %}
  <h1>author List</h1>
  {% if author_list %}
  <ul>
    {% for author in author_list %}
      <li>
        <a href="{{ author.get_absolute_url }}">{{ author }}</a>&nbsp;&nbsp;
        <a> Renew </a> &nbsp;&nbsp;
        <a> Delete </a>
      </li>
    {% endfor %}
  </ul>
  {% else %}
    <p>There are author in the library.</p>
  {% endif %}

  <a> insert </a>

{% endblock %}

{% extends "base_generic.html" %}

{% block content %}
  <h1>Book List</h1>
  {% if book_list %}
  <ul>
    {% for book in book_list %}
      <li>
        <a href="{{ book.get_absolute_url }}">{{ book.title }}</a> ({{book.author}}) &nbsp;&nbsp;
        <a> Renew </a> &nbsp;&nbsp;
        <a> Delete </a>
      </li>

    {% endfor %}
  </ul>
  {% else %}
    <p>There are no books in the library.</p>
  {% endif %}

  <a> insert </a>

{% endblock %}
따라서 위와 같이 단순하게 extend 했던 코드를
extend 했던 파일의 코드를 그대로 복사해 붙여 넣는다.

물론 애초에 원본을 수정하여 
권한을 부여하는 방법도 있지만, 
그렇게 만들면 종속성이 증가함과 동시에
가독성이 떨어지기 때문에 
따로 독립적으로 파일을 만들었다.

나는 이렇게 성능 또는 독립성과 가독성을 
선택해야 하는 상황이 온다면,
대개 독립성과 가독성을 선택하는 편이다.

위와 같이 기존의 Template 코드를 수정했다면



위와 같이 Renew, Delete, insert를 추가 했다.


Insert, Update, Delete 애플리케이션 작성


지금까지 청사진을 그렸다면
이제 Insert, Update, Delete 애플리케이션을 작성해보자.

이전과 동일하게 Model, View, Template 작성이 필요하겠으나
Model은 이미 작성되어 있기 때문에
View와 Template만 작성하면 된다.

① View


catalog/ 경로의 view.py 파일에


@permission_required('catalog.can_mark_returned')
class ManageAuthorCreate(CreateView):
    model = Author
    fields = '__all__'
    success_url = reverse_lazy('manage-author')

@permission_required('catalog.can_mark_returned')
class ManageAuthorUpdate(UpdateView):
    model = Author
    fields = '__all__'
    success_url = reverse_lazy('manage-author')

@permission_required('catalog.can_mark_returned')
class ManageAuthorDelete(DeleteView):
    model = Author
    success_url = reverse_lazy('manage-author')

@permission_required('catalog.can_mark_returned')
class ManageBookCreate(CreateView):
    model = Book
    fields = '__all__'
    success_url = reverse_lazy('manage-book')

@permission_required('catalog.can_mark_returned')
class ManageBookUpdate(UpdateView):
    model = Book
    fields = '__all__'
    success_url = reverse_lazy('manage-book')

@permission_required('catalog.can_mark_returned')
class ManageBookDelete(DeleteView):
    model = Book
    success_url = reverse_lazy('manage-book')
위와 같은 코드를 추가 하자.

권한을 가지고 있지 않는 User가 
해당 URL을 알고 있다면 접근할 수 있기 때문에
권한을 부여해서 해당 기능을 사용하지 못하게 막았다.

② Template


Template의 경우는 먼저
Delete할 시에 보여줄 Template

  <!-- book_confirm_delete.html -->
{% extends "base_generic.html" %}

{% block content %}

<h1>Delete Book</h1>

<p>Are you sure you want to delete the Book: {{ book }}?</p>

<form action="" method="POST">
  {% csrf_token %}
  <input type="submit" value="Yes, delete.">
</form>

{% endblock %}
위와 같이
book_confirm_delete.html 파일 추가 및 코드를 편집하고 


{% extends "base_generic.html" %}


{% block content %}
{% if perms.catalog.can_mark_returned == False %}
  <p>You have not permission.</p>

{% elif perms.catalog.can_mark_returned %}
  <h1>author List</h1>
  {% if author_list %}
  <ul>
    {% for author in author_list %}
      <li>
        <a href="{{ author.get_absolute_url }}">{{ author }} </a>&nbsp;&nbsp;
        <a href="{% url 'manage-author-update' author.id %}">
          <font color = "red">
            Renew
          </font>
        </a> &nbsp;&nbsp;
        <a href="{% url 'manage-author-delete' author.id %}">
          <font color = "red">
            Delete
          </font>
        </a>
      </li>
    {% endfor %}
  </ul>
  {% else %}
    <p>There are author in the library.</p>
  {% endif %}
  <a href="{% url 'manage-author-create' %}">
    <font color = "red">
      Insert
    </font>
  </a>
{% endif %}
{% endblock %}
기존 manage_author_list.html 파일을 위와 같이

{% extends "base_generic.html" %}

{% block content %}
{% if perms.catalog.can_mark_returned == False %}

  <p>You have not permission.</p>

{% elif perms.catalog.can_mark_returned %}
  <h1>Book List</h1>
  {% if book_list %}
  <ul>
    {% for book in book_list %}
      {% if perms.catalog.can_mark_returned %}
      <li>
        <a href="{{ book.get_absolute_url }}" >{{ book.title }}</a> ({{book.author}}) &nbsp;&nbsp;
        <a href="{% url 'manage-book-update' book.id %}">
          <font color = "red">
            Renew
          </font>
        </a> &nbsp;&nbsp;
        <a href="{% url 'manage-book-delete' book.id %}">
          <font color = "red">
            Delete
          </font>
        </a>
      </li>
      {% endif %}
    {% endfor %}
  </ul>
  {% else %}
    <p>There are no books in the library.</p>
  {% endif %}

  <a href="{% url 'manage-book-create' %}">
    <font color = "red">
      Insert
    </font>
  </a>

{% endif %}
{% endblock %}
그리고 
manage_book_list.html 파일을 위와 같이 수정 한다.

③ Test


기본적인 Insert, Update, Delete는 중복되기 때문에 
따로 여기서 하지는 않겠지만,

Permission 기능이 정상적으로 
작동하는지 테스트 할 필요는 있을 것이다.

이 상태에서 로그아웃을 하면 

위와 같이 의도한대로 
You have not Permission이라는 텍스트가 페이지에 표시된다.

사실 Logout 을 누르면 홈 페이지로 
리다이렉트 되게끔 하는 것이 좋기 때문에 
이 부분은 따로 수정하기로 하겠다.

이 것으로 이번 나만의 추가 도전 과제는 끝이 났다.

다시 한번 Django의 강력함을 느낄 수 있었다.



2020.08.26 추가


이 글을 작성한 다음날에 
다시 작업을 하려고 서버를 작동했는데


위와 같이 함수 객체에 as._view()가 없다며 에러가 나타 났다.

이에 대해 검색해본 결과 이는 Permission 디코레이터의 문제

해결 방법은 View를 수정하거나 url을 수정하는 방법
이 두 가지가 있다.

먼저 View를 수정하는 방법은 

    # Admin Management Generic Edit View Page URLS
    path('author/manage-create/', views.ManageAuthorCreate, name='manage-author-create'),
    path('author/<int:pk>/manage-update/', views.ManageAuthorUpdate, name='manage-author-update'),
    path('author/<int:pk>/manage-delete/', views.ManageAuthorDelete, name='manage-author-delete'),

    path('book/manage-create/', views.ManageBookCreate, name='manage-book-create'),
    path('book/<int:pk>/manage-update/', views.ManageBookUpdate, name='manage-book-update'),
    path('book/<int:pk>/manage-delete/', views.ManageBookDelete, name='manage-book-delete'),

    # Admin Management All Output Page URLS
    path('manage-book/', views.ManagementBookListView, name='manage-book'),
    path('manage-author/', views.ManagementAuthorListView, name='manage-author'),
위와 같이 .as_view()를 모두 삭제 하면 문제를 해결 할 수 있다.

어느 것으로 하던 크게 상관은 없어 보이지만
나는 첫 번째 방법을 선택했다.


이 블로그의 인기 게시물

[ Web ] 웹 애플리케이션 아키텍처 (Web Application Architecture)

[ Web ] 서버 사이드(Sever Side) ? 클라이언트 사이드(Client Side)? 1 [서론, 클라이언트 사이드(Client Side)]

[ Web ] 웹 애플리케이션 서버 아키텍처의 정의 및 유형 ( Define and Types of Web Application Server Architecture )