検索

記事
· 6 hr 前 15m read

Introduction à l'interopérabilité sur Python (IoP) - Partie 2

Salut la Communauté,

Dans la première partie de cette série, on a vu les bases de l'interopérabilité sur Python Interoperability on Python (IoP), et surtout comment ça nous permet de construire des éléments d'interopérabilité comme des services métier, des processus et des opérations uniquement à l'aide de Python.

Maintenant, on est prêts à aller plus loin. Les scénarios d'intégration dans le monde réel vont au-delà du simple transfert de messages. Ils impliquent des interrogations programmées, des structures de messages personnalisées, une logique de décision, un filtrage et une gestion de la configuration. Dans cet article, on va se pencher sur ces fonctionnalités IoP plus avancées et montrer comment créer et exécuter un flux d'interopérabilité plus complexe uniquement à l'aide de Python.

Pour que ce soit plus concret, on va construire un exemple complet: La Reddit Post Analyzer Production (production d'analyseur de posts Reddit). Le concept est simple : récupérer en continu les dernières publications d'un subreddit choisi, les filtrer en fonction de leur popularité, leur ajouter des balises supplémentaires et les envoyer pour stockage ou analyse plus approfondie.

L'objectif final est ici de disposer d'un pipeline d'ingestion de données fiable et autonome. Tous les éléments principaux (service métier, processus métier et opération métier) sont implémentés en Python, ce qui montre comment utiliser l'IoP à l'aide de la méthodologie d'intégration axée sur Python.

ディスカッション (0)0
続けるにはログインするか新規登録を行ってください
記事
· 7 hr 前 3m read

Turkish Rug Supplier India: Traditional Patterns for Modern Interiors

 

Turkish rugs have long been admired for their rich heritage, intricate motifs, and timeless appeal. Known for their bold geometric patterns, elegant floral designs, and warm color palettes, Turkish rugs continue to inspire interior décor across the world. Today, India has emerged as a trusted destination for sourcing these masterpieces, offering high-quality craftsmanship combined with modern design sensibilities. A Turkish rug supplier in India brings together traditional Turkish aesthetics and contemporary styling, making these rugs ideal for modern interiors.

 


The Timeless Beauty of Turkish Rugs

Traditional Turkish rugs are deeply rooted in history, often featuring symbolic motifs, medallions, and symmetrical patterns woven with precision. These designs reflect cultural stories and artistic traditions passed down through generations. What makes Turkish rugs truly special is their ability to remain relevant—even in modern homes—thanks to their balanced patterns and harmonious colors.

Indian manufacturers and suppliers have mastered the art of recreating authentic Turkish designs while adapting them to contemporary spaces. This fusion allows classic rugs to complement minimalist, modern, and luxury interiors effortlessly.

Why Choose a Turkish Rug Supplier in India?

India is globally recognized for its handmade carpet industry, with skilled artisans capable of producing world-class rugs using traditional weaving techniques. Choosing a Turkish Carpets Manufacturer India offers several advantages:

  • Expert Craftsmanship: Indian weavers are highly skilled in hand-knotting, hand-tufting, and weaving techniques inspired by Turkish traditions.
  • Customization Options: Suppliers offer customized sizes, color palettes, and patterns to suit modern interior requirements.
  • Premium Materials: High-quality wool, silk, and blended fibers ensure durability, softness, and luxury.
  • Competitive Pricing: Indian suppliers provide exceptional quality at globally competitive prices.

These factors make India a preferred sourcing destination for designers, retailers, and homeowners worldwide.

Traditional Patterns Adapted for Modern Interiors

Modern interiors often demand simplicity, balance, and functionality. Indian Turkish rug suppliers skillfully adapt traditional motifs by refining color contrasts, softening patterns, or blending them with contemporary influences. This approach creates rugs that maintain their cultural essence while fitting seamlessly into modern homes, offices, and hospitality spaces.

Interestingly, many suppliers also work closely with abstract area rugs suppliers and Abstract Design Carpets Vendors, allowing them to blend Turkish motifs with abstract elements. This results in unique rugs that combine heritage patterns with modern artistic expression.

Craftsmanship Meets Innovation

A leading Turkish rug supplier in India often collaborates with experienced designers and skilled artisans to ensure each rug reflects both authenticity and innovation. Modern production techniques, design software, and sustainable dyeing processes are integrated without compromising the handmade nature of the rugs.

Some suppliers also operate as Turkish Rug Manufacturer India, producing contemporary collections alongside traditional rugs. This versatility allows buyers to source a diverse range of styles—from classic Turkish designs to modern abstract rugs—from a single trusted partner.

Supporting Ethical and Sustainable Practices

Many Indian rug suppliers emphasize ethical craftsmanship by ensuring fair wages, safe working environments, and sustainable production methods. Natural fibers and eco-friendly dyes are commonly used, aligning with global demand for responsible sourcing. This ethical approach adds value to every rug and supports the preservation of traditional weaving communities.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
ディスカッション (0)0
続けるにはログインするか新規登録を行ってください
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 19 hr 前 8m read

Debugging REST APIs using %CSP.Request and %CSP.Response

 

There are numerous excellent tools available for testing your REST APIs, especially when they are live. Postman, various web browser extensions, and even custom ObjectScript written with %Net.HttpRequest objects can get the job done. However, it is often difficult to test just the REST API without inadvertently involving the authentication scheme, the web application configuration, or even network connectivity. Those are a lot of hoops to jump through just to test the code within your dispatch class. The good news is that if we take our time to understand the inner workings of the %CSP.REST class, we will find an alternative option suited for testing only the contents of the dispatch class. We can set up the request and response objects to invoke the methods directly.

Understanding %request and %response

If you have ever worked with REST APIs in InterSystems, you have probably encountered the two objects that drive the entire process: %request and %response. To grasp their utility, we must recall our ObjectScript fundamentals regarding "percent variables." Typically, a variable in ObjectScript can only be accessed directly within the process that defines it. However, a variable prefixed with a percent sign is public within that process. It means that all methods within the same process can access it. That is why by defining those variables ourselves, we can trigger our REST API methods exactly as they would run when receiving a genuine incoming request in the API.

Consider the following basic %CSP.REST class. It features two routes and two corresponding methods. The first route accepts a request containing a date of birth in ODBC format and returns the age in days. The second one accepts a name as a URL parameter, makes sure the request method is correct, and simply echoes a hello message.

Class User.REST Extends %CSP.REST

{

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]

{

<Routes>

<Route Url="/calc/age" Method="POST" Call="CalcAge" />

<Route Url=”/echoname/:david” Method=”GET” Call=”EchoName” />

</Routes>

}

ClassMethod CalcAge() As %Status

{

    try{

        set reqObj = {}.%FromJSON(%request.Content)

        set dob = reqObj.%Get("dob")

        set today = $P($H,",",1)

        set dobh = $ZDH(dob,3)

        set agedays = today - dobh

        set respObj = {}.%New()

        do respObj.%Set("age_in_days",agedays)

        set %response.ContentType = “application/json”

        write respObj.%ToJSON()

        return $$$OK

    }

    catch ex{

        return ex.AsStatus()

    }

}

ClassMethod EchoName(name As %String) As %Status

{

    

    try{

        if %request.Method '= "GET"{

            $$$ThrowStatus($$$ERROR($$$GeneralError,"Wrong method."))

        }

        write "Hello, "_name

    }

    catch ex{

        write "I'm sorry, "_name_". I'm afraid I can't do that."

    }

}

}

If we attempt to call these methods from a terminal session, they will fail because %request is undefined.

USER>w $SYSTEM.Status.GetErrorText(##class(User.REST).CalcAge())

ERROR #5002: ObjectScript error: <INVALID OREF>CalcAge+2^User.REST.1

Normally, the %CSP.REST class creates this object from the received HTTP request as an instance of %CSP.Request. Likewise, the %response object is developed as an instance of %CSP.Response. Instead of sending an HTTP request, we will define these objects ourselves.

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Content = ##class(%CSP.CharacterStream).%New()

USER>do %request.Content.Write("{""dob"":""1900-01-01""}")

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).CalcAge()

{"age_in_days":45990}

In these few lines, we design the request and initialize its Content property to a %CSP.CharacterStream. This step is vital as otherwise that property will remain undefined and unable to be written to. Another valid alternative would be %CSP.BinaryStream. We populate the content stream with some JSON and initialize the %response to be a %CSP.Response without needing to do anything to it. It simply needs to be defined for the method to run. This time, when we call our class method, we can see the expected output. We could also issue a zwrite %response command to inspect the response content type or HTTP status code for assistance with troubleshooting any issues that might arise.

Testing the output of our class method takes only five lines. Tt is obviously an intentionally simplified example. However, it is far more efficient than navigating the System Management Portal to configure an application and creating the necessary HTTP requests to authenticate and call this method! It also allows us to verify the method in total isolation. When we send a request through the typical tools we employ to test REST APIs, we verify the entire stack: network connectivity, application configuration, authentication mechanism, request dispatching, and the method - all at once. The approach described above, on the other hand, allows us to test exclusively the method defined in the API, making it easier to find the problem during debugging.

Similarly, we can test the second method by setting the appropriate %request object and then calling it. In this case, we will pass the name the same way we would for any other class method.

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Method = “GET”

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).EchoName(“Dave”)

Hello, Dave

Dispatching Requests

We can take this a step further and test the dispatching as well. You may have noticed that I manually checked the CSP request’s HTTP method in the EchoName example. I did it because direct method calls bypass the routing rules, which typically prevents incorrect mapping. 

If we decide to continue with our terminal session with the %request we have defined, we can determine its HTTP method as follows:

USER>set %request.Method = “GET”

To test the dispatch, we should simply call the class DispatchRequest method, and if it is successful, we will see the output from our method again:

USER>do ##class(User.REST).DispatchRequest(“/calc/age/Dave”,%request.Method)

Hello, Dave

With the %request object properly configured, including the HTTP method, we can validate our routes. We can perform a similar test for the age calculation endpoint by setting up our %request again as we did before and employing the POST method

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Content = ##class(%CSP.CharacterStream).%New()

USER>do %request.Content.Write("{""dob"":""1900-01-01""}")

USER>set %request.Method = “POST”

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).CalcAge()

USER>do ##class(User.REST).DispatchRequest(“/calc/age”,%request.Method)

{"age_in_days":45990}

Note that we have defined the URL argument for the DispatchRequest method to be only the part of the URL located in the route node defined in the dispatch class’s XData. his is all we need to test the dispatching! This allows us to test things independently without needing to know the final deployment URL or its web application's configuration. Thus, we have been able to test everything that we typically define within a %CSP.REST class without having to worry about the usual external concerns surrounding it.

By the way, I have been starting the sessions by setting %request to a new instance of %CSP.Request. However, if you plan to do multiple tests in a row, you could also utilize the %request.Reset() method to start over with your request object. The same is true for the %response object.

Since your request might be more complicated than this one, you should familiarize yourself with the properties and methods of the %CSP.Request class. For instance, it is quite common for your API to check the content type of the request and ensure that it is whatever the API expects. In this case, you can set %request.ContentType to be application/json or whatever else is appropriate for your usage. You can configure cookies, mime data, and request data. You can also set the Secure property to simulate whether the request used HTTPS or not. 

A Couple of Caveats

There are two primary considerations to keep in mind when testing this way. First, if our API returns a file, the terminal output can become a bit unwieldy. In such instances, you should redirect the output to a file. We can accomplish that with the following commands:

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Method = "GET"

USER>set io = "C:\Users\DavidHockenbroch\Desktop\output.txt"

USER>open io:"NW":10

USER>write $TEST

1

USER>use io do ##class(User.REST).DispatchRequest("/echoname/Dave",%request.Method)

USER>close io

I now have a text file on my desktop that says “Hello, Dave.” Using N and W in the open command will create the file if it does not exist yet, and open it for writing. Note that we check $TEST. If that variable is 0 when we check it, there has been a problem opening the file as a device for writing. This could indicate a file permission issue, or the file may already be opened and locked by another process. As a matter of good practice, we should always remember to close the device.

The second catch is that if we plan on setting a special session event class in the web application configuration, and those custom events will impact the way our REST methods work, it can cause problems since we are bypassing those methods. We will have to call them as class methods manually in the terminal.

Onward!

Now that we have established some means for testing our API without any extra baggage, we are ready to move to our true goal: unit testing. Stay tuned for the next article!

1件の新着コメント
ディスカッション (1)3
続けるにはログインするか新規登録を行ってください